# Get a single frame. success = False while not success: t0 = time.time() success, frame = tracker._get_frame() # Close the connection with the tracker. tracker.close() # Cascades face_cascade = cv2.CascadeClassifier(_FACECASCADE) eye_cascade = cv2.CascadeClassifier(_EYECASCADE) # Crop the face and the eyes from the image. success, facecrop = generic._crop_face(frame, face_cascade, \ minsize=(30, 30)) success, eyes = generic._crop_eyes(facecrop, eye_cascade, \ Lexpect=(0.7,0.4), Rexpect=(0.3,0.4), maxdist=None, maxsize=None) # Find the pupils in both eyes B = generic._find_pupils(eyes[0], eyes[1], glint=True, mode='diameter') t1 = time.time() # Process results print("Elapsed time: %.3f ms" % (1000 * (t1 - t0))) pyplot.figure() pyplot.imshow(facecrop, cmap='gray') pyplot.figure() pyplot.imshow(eyes[0], cmap='gray') pyplot.figure() pyplot.imshow(eyes[1], cmap='gray') # # # # #
else: # Initialise a new tracker instance. tracker = ImageTracker(imgdir=IMGDIR, mode=MODE, debug=DEBUG) # Get a single frame. success = False while not success: t0 = time.time() success, frame = tracker._get_frame() # Close the connection with the tracker. tracker.close() # Cascades face_cascade = cv2.CascadeClassifier(_FACECASCADE) eye_cascade = cv2.CascadeClassifier(_EYECASCADE) # Crop the face and the eyes from the image. success, facecrop = generic._crop_face(frame, face_cascade, \ minsize=(30, 30)) success, eyes = generic._crop_eyes(facecrop, eye_cascade, \ Lexpect=(0.7,0.4), Rexpect=(0.3,0.4), maxdist=None, maxsize=None) # Find the pupils in both eyes B = generic._find_pupils(eyes[0], eyes[1], glint=True, mode='diameter') t1 = time.time() # Process results print("Elapsed time: %.3f ms" % (1000*(t1-t0))) pyplot.figure(); pyplot.imshow(facecrop, cmap='gray') pyplot.figure(); pyplot.imshow(eyes[0], cmap='gray') pyplot.figure(); pyplot.imshow(eyes[1], cmap='gray') # # # # #