How to detect white pixels in eye region using java
I've detected the eye region & trying to convert it into ROI & then process the image pixel by pixel . But unfortunately I'm in no luck to process the image only the frame rows,cols & channels have been detected.I'm processing a live video streaming .Here's a code snippet : MatOfRect eyes = new MatOfRect(); cascadeEyeClassifier.detectMultiScale(frame, eyes); for (Rect rect : eyes.toArray()) {
Core.rectangle(frame, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height),
new Scalar(200, 200, 100),2);
System.out.println("Channels = "+frame.channels()+"Rows = "+frame.rows()+"Columns = "+frame.cols()+"Eye pixels"+ new Point(rect.x, rect.y)+
""+new Point(rect.x + rect.width, rect.y + rect.height));
int buffer[] = new int[(int) (frame.channels()*frame.total())];
Mat gray = frame.submat(rect);
Mat temp = new Mat();
Imgproc.cvtColor(gray, temp, Imgproc.COLOR_BGRA2GRAY,0);
Mat whitepixels = new Mat();
Core.inRange(temp, new Scalar(255,255,255), new Scalar(255,255,255),whitepixels);
}
Any help is appreciated.Thanks in advance!!!
How sure are you it's perfectly white? You're keeping only the pixels that are exactly (255,255,255). Try lowering the bound a bit, and see if that helps.