OpenCV:使用霍夫圆变换来检测虹膜

时间:2012-09-24 14:52:34

标签: c++ opencv image-processing hough-transform iris-recognition

我是openCV的新手,但我想创建虹膜识别程序。虽然带网络摄像头的系统可以检测到眼睛,但是它不能检测到圆形虹膜。我正在使用Hough Circle Transformation。但是如果图像中的光圈不够圆,系统就无法检测到它。有什么解决方案吗?

使用的算法是Hough Circle Transformation。

IplImage *capturedImg = cvLoadImage("circle.jpg",1);
IplImage *grayscaleImg = cvCreateImage(cvGetSize(capturedImg), 8, 1);

cvCvtColor(capturedImg, grayscaleImg, CV_BGR2GRAY);

// Gaussian filter for less noise
cvSmooth(grayscaleImg, grayscaleImg, CV_GAUSSIAN,9, 9 );

//Detect the circles in the image
CvSeq* circles = cvHoughCircles(grayscaleImg,
                         storage,
                         CV_HOUGH_GRADIENT,
                         2,
                         grayscaleImg->height/4,
                         200,
                     100 );

for (i = 0; i < circles->total; i++) 
{
     float* p = (float*)cvGetSeqElem( circles, i );
     cvCircle( capturedImg, cvPoint(cvRound(p[0]),cvRound(p[1])), 
        3, CV_RGB(0,255,0), -1, 8, 0 );
     cvCircle( capturedImg, cvPoint(cvRound(p[0]),cvRound(p[1])), 
         cvRound(p[2]), CV_RGB(0,0,255), 3, 8, 0 );
}
// cvCircle( img,cvPoint( r->x, r->y ),67, CV_RGB(255,0,0), 3, 8, 0 );      
cvNamedWindow( "circles", 1 );
cvShowImage( "circles", capturedImg );

1 个答案:

答案 0 :(得分:6)

cvCanny()cvSmooth()之间添加对cvHoughCircles()的通话。这将执行边缘检测算法,该算法将为cvHoughCircles()提供更好的输入图像,并可能会改善您的结果。

Stackoverflow上有很多similar个问题,我建议你use the search box