Face Mask Detection using OpenCV Python

 Face Mask Detection using OpenCV Python

The world is fighting with Covid19 pandemic. There are so many essential equipment’s needed to fight against Corona virus. One of such most essential is Face Mask. Firstly, face mask was not mandatory for everyone but as the day progresses scientist and Doctors have recommended everyone to wear face mask. Now To detect whether a person is wearing Face Mask or not, we will use Face Mask Detection Technique. Face Mask Detection Platform utilizes Artificial Network to perceive if a person does/doesn’t wear a mask. The application can be associated with any current or new IP cameras to identify individuals with/without a mask.

           

There are two main steps in this project:

1.     Identify human Face and mouth in each frame of input video

2.     Identify Person is using mask or not

 

Step 1: Identify Face and Mouth

Steps for Face Prediction using python and OpenCV are:

1.Creatr HAAR Cascade object using ‘CascadeClassifier’ function and ‘harrcascade_frontalface_default.xml’ 

2. Read image using function ‘imread’ (or ‘read’ for    Video/camera input) function.

3. Convert in gray scale using ‘cvtColor’ function.

4. Detect face using ‘detectMultiScale’ function

Step 2: Identify Person is Using Mask or not.

There are three rectangle objects:

1.     ‘Gray’ image face rectangle

2.     ‘Black & White’ image face rectangle

3.     ‘Gray’ image Mouth rectangle

 

Based on number of rectangles and rectangle position of mouth and face, we can create rule to detect mask.

  

                                 Figure 1: Conditions for with mask/ without mask




Result

Possible Outputs:

Fig 2: Output- without face: No Face Found


Fig 3: Output- with face but without Mask: Please wear Mask to defeat Corona

Fig:4 Output- with face and with Mask: Thank you for wearing Mask.



 

Comments