Rocketmagnet
Rocketmagnet

Reputation: 5880

Measure exact position of known circle using Python OpenCV

I have an image containing a bunch of circular features. I'd like to know exactly the exact location of the centre of a particular circle and its radius (preferably with sub-pixel accuracy).

Calibration circle

Rather than using a circle detector, which will try to find all of the circles, is there a method in OpenCV for fitting a circle to the image? Like this:

Calibration circle detected


Update:

I have tried using the Hough circle detection method, and it seems to get confused about whether the circle should be on the inside or outside edge of the black line. The circle jumps around between the inside and outside edges, or sometimes tries to do both.

Hough circle detection problem

Upvotes: 1

Views: 436

Answers (1)

AlanWik
AlanWik

Reputation: 322

All I can think of now is, if you know the approximate centre and radius, search for all the circles and use least fitting squares with the circle equation to find the one you are looking for.

Upvotes: 1

Related Questions