Ask Your Question

Finding Largest Circle Contained Within A Contour

asked 2017-01-21 21:01:36 -0600

jpistorino gravatar image

I know that there is an OpenCV function that will find the minimum circle that will contain a contour (minEnclosing Circle).

I am looking for the reverse, i.e., a way to determine the largest circle that will fit within a contour. Really, I just want the center of that circle.

Thanks for any help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-01-21 21:20:42 -0600

Tetragramm gravatar image

That is not a well-formed problem. Namely, there can be more than one largest circle within a contour, but there is only one minimum enclosing circle.

You could brute force it, but it would be slow.

edit flag offensive delete link more


Thanks for your response. Your link used phrasing that led me to what I was looking for. Here is a previous OpenCV question with code. It is true that this will be slow but it is good enough for my purpose (finding the point in the template image used in Generalized Hough Transform). Having found this in the template image, you should be able to find it in the query image using the GHT results without recalculating. This result would be useful for target tracking/grip planning, etc. While I agree that there may be more than one circle of the same size, finding one of them is useful. A maxInscribedCircle function maybe something to consider adding as a complement to minEnclosingCircle.

jpistorino gravatar imagejpistorino ( 2017-01-22 09:49:18 -0600 )edit

Question Tools

1 follower


Asked: 2017-01-21 21:01:36 -0600

Seen: 2,470 times

Last updated: Jan 21 '17