Tuesday, March 31st, 2009, 1042 days ago

Recognizing circles accurately

accuratecirclerecognition

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);
}


Leave a Reply

You can use these XHTML tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>