Find circles in image without using Hough transfor

2019-07-22 03:08发布

问题:

I want to find the circles in the below image.I tried using OpenCV's Hough circle detection but it is not giving the proper results.

Is there any other way to find circles?

Here is sample code

vector<Vec3f> circles;
Mat src_gray,te; 
cvtColor(tImg, src_gray, CV_BGR2GRAY);
GaussianBlur(src_gray, src_gray, Size(9, 9), 2, 2);
Canny(src_gray, te, 40, 240, 3);
/// Apply the Hough Transform to find the circles 
HoughCircles(te, circles, CV_HOUGH_GRADIENT, 1, te.rows / 10, 120, 9, 5, 25); 

回答1:

Take contour,
1. find the centroid of the contour
2. find distance from the centroid to each contour pixels.
3. if this distance is almost same then it will be a circle.

See This link