January 2018
Intermediate to advanced
268 pages
6h 20m
English
As we discussed earlier, we are not going to use Haar cascade to detect pupils. If we can't use a pre-trained classifier, then how are we going to detect the pupils? Well, we can use shape analysis to detect the pupils. We know that pupils are circular, so we can use this information to detect them in the image. We invert the input image and then convert it into a grayscale image as shown in the following line:
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
As we can see here, we can invert an image using the tilde operator. Inverting the image is helpful in our case because the pupil is black in color, and black corresponds to a low pixel value. We then threshold the image to make sure that there are only black and ...
Read now
Unlock full access