【发布时间】:2015-11-07 15:10:41
【问题描述】:
我在 Java 中使用 opencv 尝试检测带有眼睛的图像中的圆圈(虹膜和瞳孔),但没有得到预期的结果。
这是我的代码
// 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)和原始图像。而且我认为模糊步骤是没有必要的,因为你想要有锐利的边缘。
-
@FiReTiTi ,我在上面编辑了我的问题并添加了原始图像和精明的结果。实际上我删除了霍夫圆结果,因为我在这里添加链接或照片有限制(不超过两个链接)
-
我在用霍夫圆定位瞳孔时遇到了同样的问题,结果证明霍夫圆不适合这种情况,因为瞳孔不是精确的圆。
标签: java opencv android-studio image-segmentation iris-recognition