Getting eyes images with dlib [closed]

asked 2017-01-09 08:36:42 -0500

Tiaguituh05 gravatar image

Hello, once again my question resumes to the following: I got the landmarks, and after that I want to get and save only the images of the eyes (separately) Im using the following scrip:

import sys
import os
import dlib
import glob
from skimage import io

if len(sys.argv) != 3:
        "Give the path to the trained shape predictor model as the first "
        "argument and then the directory containing the facial images.\n"
        "For example, if you are in the python_examples folder then "
        "execute this program by running:\n"
        "    ./ shape_predictor_68_face_landmarks.dat ../examples/faces\n"
        "You can download a trained facial shape predictor from:\n"

predictor_path = sys.argv[1]
faces_folder_path = sys.argv[2]

detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predictor_path)
win = dlib.image_window()

for f in glob.glob(os.path.join(faces_folder_path, "*.jpg")):
    print("Processing file: {}".format(f))
    img = io.imread(f)


    # Ask the detector to find the bounding boxes of each face. The 1 in the
    # second argument indicates that we should upsample the image 1 time. This
    # will make everything bigger and allow us to detect more faces.
    dets = detector(img, 1)
    print("Number of faces detected: {}".format(len(dets)))
    for k, d in enumerate(dets):
        print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(
            k, d.left(),, d.right(), d.bottom()))
        # Get the landmarks/parts for the face in box d.
        shape = predictor(img, d)
        print("Part 0: {}, Part 1: {} ...".format(shape.part(0),
        # Draw the face landmarks on the screen.


I tried all sort of things but I cant get the eyes images, does any1 know how to do so?

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by LorenaGdL
close date 2017-01-09 09:11:06.918362



Reason for closing: this is the OpenCV forum, not the dlib one. Please, refer to the proper forum or github page

LorenaGdL gravatar imageLorenaGdL ( 2017-01-09 09:10:44 -0500 )edit