Detect Eyeglasses

Let’s learn to automatically detect glasses on digital face images.

Introduction

Automatic detection of glasses on digital face images remains challenging because of different kinds of eyewear like sports glasses, frames that block the eyes, sunglasses and other variations that are not clearly distinguishable.

Recent studies revealed that wearing glasses largely affects biometric systems, especially diminishing the accuracy of iris recognition systems. Moreover, glasses introduce occlusions that can deteriorate the performance of automatic face recognition systems. The automatic recognition of eyeglasses on facial images is considered a possible solution to this problem.

Objective

This lesson shows the steps required to develop a lightweight glasses detector written in the Python programing language. To cope with the glasses detection problem, this lesson proposes an approach to investigate regions close to the eyes that are spotted in facial images, as exhibited below:

Dependencies

We’ll be using the following external Python libraries:

Library

Version

MediaPipe

0.8.9

opencv-python

4.4.0.46

NumPy

1.19.4

filetype

1.0.7

Let’s code this utility!

Let’s take a look at the principal functions of this utility.

The grab_roi function

This function will collect the minimum and maximum ...