localize the eyes using ROI
I have used face-cascade classifier and found the face and found eyes region using ROI without using eye cascade
as shown in the image .
Now I want to apply ROI to detect eyes region exactly from given face coordinates
how can I get this result ?
This is my code for the first image :
cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
equalizeHist(frame_gray, frame_gray);
// Detect faces
face_cascade.detectMultiScale(frame_gray, faces, 1.1, 4, CASCADE_SCALE_IMAGE, Size(20, 20));
// Set Region of Interest
size_t i = 0;
for (i = 0; i < faces.size(); i++) // Iterate through all current elements (detected faces)
{
Point pt1(faces[i].x, faces[i].y); // Display detected faces on main window - live stream from camera
Point pt2((faces[i].x + faces[i].height), (faces[i].y + faces[i].width));
rectangle(frame, pt1, pt2, Scalar(0, 255, 0), 2, 8, 0);
// set ROI for the eyes
Rect Roi = faces[i];
Roi.height = Roi.height / 4;
Roi.y = Roi.y + Roi.height;
Mat eye_region = frame(Roi).clone();
Mat eye_gray = frame(Roi).clone();
imshow("video main frame", eye_region);
@tofi@elp14sma not a good move to re-open questions with a duplicate user
why you don't want to use eye cascade?
It was not accurate when there is head movement and I want only eye location even if one of them
OK. i suggest trying to find contours of biggest two white areas and with analyzing them try to find pupils.
Can I modify the Rect Roi (x,y, height and width) parameters to find the eyes separately or either left ,right eye ?