Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV: Using Hough Circle Transformation to detect iris

I am newbie to openCV, but I want to create iris recognition program. Although the system with webcam can detect the eyes, it cannot, however, detect the circular iris. I am using the Hough Circle Transformation. But in case iris in an image is not circular enough, system can't detect it. Any solution for it?

the algorithm used is 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 );
like image 401
Din Hee Avatar asked Sep 24 '12 14:09

Din Hee


People also ask

How does Hough circle detection work?

The circle Hough Transform (CHT) is a basic feature extraction technique used in digital image processing for detecting circles in imperfect images. The circle candidates are produced by “voting” in the Hough parameter space and then selecting local maxima in an accumulator matrix.

How do I find circles in OpenCV?

Use the OpenCV function HoughCircles() to detect circles in an image.

How do you detect an ellipse in OpenCV?

To identify circles, ellipses, or in general, any shape in which the pixels are connected we use the SimpleBlobDetector() function of OpenCV.

How do I find an image in a circle in Python?

cv2. HoughCircles(image, method, dp, minDist) Where Image is the image file converted to grey scale Method is the algorithm used to detct the circles. Dp is the inverse ratio of the accumulator resolution to the image resolution. minDist is the Minimum distance between the center coordinates of detected circles.


1 Answers

Add a call to cvCanny() between cvSmooth() and cvHoughCircles(). This will execute an edge detection algorithm which is going to provide a better input image for cvHoughCircles() and will probably improve your results.

There's a lot of similar questions on Stackoverflow, I suggest you use the search box.

like image 144
karlphillip Avatar answered Oct 16 '22 06:10

karlphillip