关于在java opencv中使用霍夫圆检测虹膜和瞳孔圆 [英] about detecting iris and pupil circles using hough circle in java opencv

查看:28
本文介绍了关于在java opencv中使用霍夫圆检测虹膜和瞳孔圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Java 中使用 opencv 尝试检测眼睛图像中的圆圈(虹膜和瞳孔),但没有得到预期的结果.

I'm using opencv in Java to try to detect circles (iris, and pupil) in images with eyes, but I didn't get the expected results.

这是我的代码

// convert source image to gray
org.opencv.imgproc.Imgproc.cvtColor(mRgba, imgCny, Imgproc.COLOR_BGR2GRAY);
//fliter

org.opencv.imgproc.Imgproc.blur(imgCny, imgCny, new Size(3, 3));
//apply canny

org.opencv.imgproc.Imgproc.Canny(imgCny, imgCny, 10, 30);
//apply Hough circle

Mat circles = new Mat();
Point pt;

org.opencv.imgproc.Imgproc.HoughCircles(imgCny, circles, Imgproc.CV_HOUGH_GRADIENT, imgCny.rows() / 4, 2, 200, 100, 0, 0);
//draw the found circles
for (int i = 0; i < circles.cols(); i++) {
    double vCircle[] = circles.get(0, i);

    pt = new Point((int) Math.round((vCircle[0])), (int) Math.round((vCircle[1])));

    int radius = (int) Math.round(vCircle[2]);
    Core.circle(mRgba, pt, radius, new Scalar(0, 0, 255), 3);
}

原图

canny 结果

我不知道是什么问题.问题是出在找到的圆函数的参数上还是别的什么.

I don't know what is the problem. Whether the problem is in the parameters of the found circle function or something else.

有没有人遇到过这样的问题或知道如何解决?

Has anyone faced such problem or knows how to fix it?

推荐答案

在这个精明的结果中,霍夫变换无法检测到您想要的圆!边缘太多了.您必须先清理图像.

There is no way that the Hough transform will detect THE circle you want in this canny result! There are too many edges. You must clean the image first.

从黑色(瞳孔、虹膜内部)和白色检测开始.这两个区域将界定投资回报率.

Start with black (the pupil, iris inner part) and white detection. These two zones will delimitate the ROI.

此外,我还会尝试执行皮肤检测(HSV 颜色空间的简单阈值.它将消除 90% 的研究区域.

Moreover, I would also try to perform a skin detection (simple threshold into HSV color space. It will eliminate 90% of the research area.

这篇关于关于在java opencv中使用霍夫圆检测虹膜和瞳孔圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆