The Face Recognition process in this tutorial is divided into three steps.
#Prepare training data: In this step we will read training images for each person/subject along with their labels, detect faces from each image and assign each detected face an integer label of the person it belongs to.
#Train Face Recognizer: In this step we will train OpenCV's LBPH face recognizer by feeding it the data we prepared in step 1.
#Testing: In this step we will pass some test images to face recognizer and see if it predicts them correctly.
*****************************************
Requirements
*****************************************
You need Python 3.6 64bit to run facerecognition Dlib libraries as these are not available in version latest then 3.6.
******************************
Installations Quick start
******************************
Import Required Modules
import OpenCV module
import cv2
import os module for reading training data directories and paths
import os
import numpy to convert python lists to numpy arrays as
icon_path='path/to/image/file/icon.png', # On Windows .ico is required, on Linux - .png
duration=5, # Duration in seconds
urgency=Notification.URGENCY_CRITICAL
).send()
**************************************
#Detector
***************************************
Loading Recognizer Lets start the main loop and do the following basic steps Starts capturing frames from the camera object Convert it to Gray Scale Detect and extract faces from the images Use the recognizer to recognize the Id of the user Put predicted Id/Name and Rectangle on detected face.
#function to detect face using OpenCV
def detect_face(img):
#convert the test image to gray image as opencv face detector expects gray images