March 2020
Intermediate to advanced
366 pages
9h 8m
English
Fortunately, OpenCV comes with a few eye cascades that can detect both open and closed eyes, such as haarcascade_eye.xml. This allows us to calculate the angle between the line that connects the center of the two eyes and the horizon so that we can rotate the face accordingly.
In addition, adding eye detectors will reduce the risk of having false positives in our dataset, allowing us to add a data sample only if both the head and the eyes have been successfully detected.
After loading the eye cascade from the file in the FaceDetector constructor, it is applied to the input image (head), as follows:
try: eye_centers = self.eye_centers(head) except RuntimeError: return False, head
If we are unsuccessful and the cascade classifier ...
Read now
Unlock full access