alb*_*pod 3 opencv detection hough-transform iris-recognition
我试图检测眼睛的虹膜,但HoughCircles返回0圈。
输入图像(眼睛)为:
然后,使用此图像进行以下操作:
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;
Run Code Online (Sandbox Code Playgroud)
因此,最终的灰色图像如下所示:
我已经发现了使用HoughCircles来检测和测量瞳孔和虹膜的问题,但尽管与我的问题相似,但它并没有帮助我。
那么为什么HoughCircles在尝试检测虹膜时返回0圈呢?如果有人知道找到虹膜的更好方法,欢迎您。
对于相同的问题,我已经遇到了完全相同的问题。事实证明,houghcircles并不是检测不太理想的圆的好方法。
在这些情况下,像MSER这样的功能检测方法会更好地工作。
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()
Run Code Online (Sandbox Code Playgroud)
另外,您可以尝试卷积滤波器。
编辑: 对于那些与c ++ MSER有问题的人,这是一个基本要点。
| 归档时间: |
|
| 查看次数: |
2073 次 |
| 最近记录: |