1 | initial version |

-Find width and height of the contour with a bounding box, like this link bounding_rects.

-Also find the area (A1) of the contour with this link contour_area

-Using either width, height or an average, assume that is the diameter of your circle (D) where the radius (r = D/2)

-Calculate the ideal area (A2) = Pi X r^2; this is the ideal area you are after.

-Compare A1 and A2 with something like: circular = 1 - (abs(A1-A2)/A2)

The circular value calculated should be a percentage how circular the contour is, if this number is high you can use width or height as the diameter, if not its not a circle.

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.