about detecting iris and pupil circles using hough circle in java opencv

放肆的年华 提交于 2019-12-06 15:16:14

问题


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.

Here is my code

// 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);
}

the original image

canny result

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?


回答1:


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.

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



来源:https://stackoverflow.com/questions/33584262/about-detecting-iris-and-pupil-circles-using-hough-circle-in-java-opencv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!