October 2016
Intermediate to advanced
558 pages
12h 39m
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. Following is what the output will look like:

Let's see how to build the pupil detector:
import math import cv2 import numpy as np img = cv2.imread('input.jpg') scaling_factor = 0.7 img = cv2.resize(img, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA) cv2.imshow('Input', img) gray = cv2.cvtColor(~img, cv2.COLOR_BGR2GRAY) ret, thresh_gray = cv2.threshold(gray, 220, 255, cv2.THRESH_BINARY) contours, hierarchy = cv2.findContours(thresh_gray, ...Read now
Unlock full access