Reema
Reema

Reputation: 11

about detecting iris and pupil circles using hough circle in 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.

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?

Upvotes: 1

Views: 1126

Answers (1)

FiReTiTi
FiReTiTi

Reputation: 5888

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.

Upvotes: 0

Related Questions