Why does HoughCircles return 0 laps trying to spot irises?

I am trying to detect irises in my eyes, but HoughCircles returns 0 laps.

Input Image (eyes):

Input image

Then I did the following with this image:

 cvtColor(eyes, gray, CV_BGR2GRAY); morphologyEx(gray, gray, 4,cv::getStructuringElement(cv::MORPH_RECT,cv::Size(3,3))); threshold(gray, gray, 0, 255, THRESH_OTSU); vector<Vec3f> circles; HoughCircles(gray, circles, CV_HOUGH_GRADIENT, 2, gray.rows/4); if (circles.size()) cout << "found" << endl; 

So, the last gray image looks like this:

Output image

I found this question. Using HoughCircles to detect and measure the pupil and iris , but this did not help me, despite the similarity with my problem.

So why does HoughCircles return 0 laps when trying to spot irises? If someone knows the best way to find irises, please.

+2
source share
1 answer

I ran into the same problem for the same problem. It turns out that houghcircles are not a good method for detecting not very well formed circles.

In these cases, object detection methods such as MSER work best.

 import cv2 import math import numpy as np import sys def non_maximal_supression(x): for f in features: distx = f.pt[0] - x.pt[0] disty = f.pt[1] - x.pt[1] dist = math.sqrt(distx*distx + disty*disty) if (f.size > x.size) and (dist<f.size/2): return True thresh = 70 img = cv2.imread(sys.argv[1]) bw = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) detector = cv2.FeatureDetector_create('MSER') features = detector.detect(bw) features.sort(key = lambda x: -x.size) features = [ x for x in features if x.size > 70] reduced_features = [x for x in features if not non_maximal_supression(x)] for rf in reduced_features: cv2.circle(img, (int(rf.pt[0]), int(rf.pt[1])), int(rf.size/2), (0,0,255), 3) cv2.imshow("iris detection", img) cv2.waitKey() 

detected areas of the diaphragm

Alternatively, you can try convolutional filters.

EDIT: For those who have problems with C ++ MSER, this is the main point.

+3
source

Source: https://habr.com/ru/post/1242600/


All Articles