I want to detect eye irises and their centers using the Hough Circle algorithm.
I am using this code:
private void houghCircle() { Bitmap obtainedBitmap = imagesList.getFirst(); Mat mat = new Mat(obtainedBitmap.getWidth(),obtainedBitmap.getHeight(), CvType.CV_8UC1); Mat grayMat = new Mat(obtainedBitmap.getWidth(), obtainedBitmap.getHeight(), CvType.CV_8UC1); Utils.bitmapToMat(obtainedBitmap, mat); int colorChannels = (mat.channels() == 3) ? Imgproc.COLOR_BGR2GRAY : ((mat.channels() == 4) ? Imgproc.COLOR_BGRA2GRAY : 1); Imgproc.cvtColor(mat, grayMat, colorChannels); Imgproc.GaussianBlur(grayMat, grayMat, new Size(9, 9), 2, 2);
But he does not detect the iris in all images correctly. Especially if the iris is dark in color, such as brown. How can I fix this code to correctly identify irises and their centers?
EDIT: Here are a few sample images (which I got from the Internet) that show the performance of the algorithm (please ignore the landmarks that are represented by red squares):
In these images, the algorithm does not detect all irises:


This image shows how the algorithm could not detect irises:

EDIT 2: Here is the code that uses Canny edge detection, but this causes the application to crash:
private void houghCircle() { Mat grayMat = new Mat(); Mat cannyEdges = new Mat(); Mat circles = new Mat(); Bitmap obtainedBitmap = imagesList.getFirst(); Mat originalBitmap = new Mat(obtainedBitmap.getWidth(),obtainedBitmap.getHeight(), CvType.CV_8UC1);
This is the error I get in the log
FATAL EXCEPTION: Thread-28685 CvException [org.opencv.core.CvException: cv::Exception: /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/imgproc/src/color.cpp:3739: error: (-215) scn == 3 || scn == 4 in function void cv::cvtColor(cv::InputArray, cv::OutputArray, int, int) ] at org.opencv.imgproc.Imgproc.cvtColor_1(Native Method) at org.opencv.imgproc.Imgproc.cvtColor(Imgproc.java:4598)
What is caused by this line: Imgproc.cvtColor(originalBitmap,grayMat,Imgproc.COLOR_BGR2GRAY);
Can anyone tell me how this error can be resolved? Perhaps adding canny edge detection will improve the results.