Circle Detection Issues

stay away from Hough and Canny. they are newbie traps.

there are some algorithms to locate circular features. some of them are Hough-based (among them the “radial symmetry transform” family). others are not.

resolution looks marginal.

if you can, work with absolute contrast instead of edges: change lighting, scene, anything physical, such that background is white/black and foreground is black/white.

don’t try to locate two circles for the same object. I don’t see any point in that.

you want optical inspection, right? then you need to approach this more like Machine Vision.

that means fixing the position of your object, so it has very little variation. then you can locate it precisely with very little effort. typical MV applies 1D line sampling on the picture (from multiple sampling lines arranged like rays in a circle) and then extracts relevant features from those 1D signals, such as maximum gradients. then those points are passed to a circle fitting function, which runs quickly because it’s just a few points.