Finding a circle with a defective contour
Hello everyone, I need help with detecting defective circles and defective areas like shown on images below:
Above picture is a simplified example of what real problem would look like. Bad circle has indents or/and outdents.
And this pitcture displays the result I would like to get with OpenCV. So basically, outdents and indents are marked with one color and the area between good cirle line and defected line is marked with another color.
Algorithm I will hopefully make with your help would be applied to broken soda cans pictures like the one above.
So far I've been able to apply Hough Circle transform algorithm which works fine, but now I need help to find broken parts of circle (soda can) and to mark them. I assumed I would need to apply a countour detection and then somewhat calculate the difference between perfect circle and detected contour. But what I've noticed is that a findCountour function saves pixsel data as a set of each point of a contour while Hough circle transform saves pixsel data only for a circle center and not for circle ouotline, therefore I cannot simply subtract one from another to get that desired difference.
Some guidance please. Thank you.
You can compute the pixel coordinates of the circle outline from the center/radius given by the Hough transform; so you can compare it with the contour given by findContour.
so:
where
xc
andyc
are the center coordinates andr
the radius. Loopy
from-r
tor
to get the x coordinates for each line.