January 2018
Intermediate to advanced
268 pages
6h 20m
English
We are going to take a different approach here. Pupils are too generic to take the Haar cascade approach. We will also get a sense of how to detect things based on their shape. The following is what the output will look like:

Let's see how to build the pupil detector:
import math import cv2 eye_cascade = cv2.CascadeClassifier('./cascade_files/haarcascade_eye.xml')if eye_cascade.empty(): raise IOError('Unable to load the eye cascade classifier xml file')cap = cv2.VideoCapture(0)ds_factor = 0.5ret, frame = cap.read()contours = []while True: ret, frame = cap.read() frame = cv2.resize(frame, None, fx=ds_factor, fy=ds_factor, ...Read now
Unlock full access