Recognizing circles accurately


According to the algrithms of  HOUGH, that is more accurate to line detection rather than circle detection, although some times it looks not so much different in theory. Actually, if detecting circles in a black-white picture, it will be obviously not so accurate as detection for lines. Detected circles are always flashing in different possible positions.

To solve this problem and low the mistake detection, the target picture should do some filter: SMOOTH.

cvSmooth( gray, gray, CV_GAUSSIAN, 11, 11 );
cvCanny(gray, edge, (float)edge_thresh, (float)edge_thresh*3, 5); //get the circle edges
CvSeq* circles =  cvHoughCircles( gray, cstorage, CV_HOUGH_GRADIENT, 2, gray->height/50, 5, 35 );
cout << circles->total <<endl; //check how many circles detected
int i;
for( i = 0; circles->total>=2?i<2:i < circles->total; i++ ){
float* p = (float*)cvGetSeqElem( circles, i );
cvCircle( src, cvPoint(cvRound(p[0]),cvRound(p[1])), 3, CV_RGB(255,0,0), -1, 8, 0 );
cvCircle( src, cvPoint(cvRound(p[0]),cvRound(p[1])), cvRound(p[2]), CV_RGB(200,0,0), 1, 8, 0);

Author: Andol Li

A HCI researcher, a digital media lecturer, an information product designer, and a python/php/java coder.

Leave a comment
Due to technical adjustments, the comment function is shortly closed and will be re-openning soon. Thanks.

Copyrights 2006-2018 © All rights reserved
Theme Tree2, re-designed by Andol Li, powered by WordPress and Bootsrap
WWW.ANDOL.ME | 浙ICP备15040508号-1
公安备案图标 浙公网安备33010602004018号
Back to top