localize the eyes using ROI

asked 2015-11-22 11:14:04 -0600

tofi gravatar image

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 Image.

Now I want to apply ROI to detect eyes region exactly from given face coordinates

how can I get this result ?

image description

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);
edit retag flag offensive close merge delete

Comments

LorenaGdL gravatar imageLorenaGdL ( 2015-11-22 11:34:42 -0600 )edit

why you don't want to use eye cascade?

sturkmen gravatar imagesturkmen ( 2015-11-22 12:47:22 -0600 )edit

It was not accurate when there is head movement and I want only eye location even if one of them

tofi gravatar imagetofi ( 2015-11-22 12:59:01 -0600 )edit
1

OK. i suggest trying to find contours of biggest two white areas and with analyzing them try to find pupils.

sturkmen gravatar imagesturkmen ( 2015-11-22 13:05:11 -0600 )edit

Can I modify the Rect Roi (x,y, height and width) parameters to find the eyes separately or either left ,right eye ?

tofi gravatar imagetofi ( 2015-11-22 13:18:57 -0600 )edit