繁体   English   中英

为什么HoughCircles在尝试检测虹膜时会返回0个圆圈?

[英]Why HoughCircles returns 0 circles while trying to detect irises?

我试图检测眼睛的虹膜,但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;

所以最终的灰色图像看起来像这样:

输出图像

我发现这个问题使用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()

检测到虹膜区域

或者,您可以尝试卷积滤镜。

编辑:对于那些有c ++ MSER问题的人, 是一个基本的要点。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM