TechEnhance

Real-time Face Recognition System Using LBPH and OpenCV

Real-time Face Recognition System Using LBPH and OpenCV

Face Detection AI Use case by Techenhance

Problem Statement

Face recognition has become an absolute necessity in today’s day and age because of the rising number of identity thefts and other identity related crimes. There has to be a system that reliably recognises the employees or members of an organization so that no-one can exploit any gaps.

To solve this problem, we leveraged AI development services from our company and considered the following problem statement as the focus for this case study- To detect and identify if the captured image of the individual’s face is from the employee database (DB).

Solution Description

For thiscustom AI development project, we utilised technologies and libraries like OpenCV, LBPH algorithm, SQLite database, and even PIL or Python Imaging library. We brought these technologies and tools together to build a system that can recognize people accurately. The system uses the following workflow.

Detailed Workflow

Now that we have understood the concept of the system on a more superficial basis let’s also shed some light on the exact steps our system utilizes to ensure accurate face recognition.

  1. Dataset Creation

Step 1: Enter Details

  • The user (typically an administrator) enters the details of the employee, such as name, ID, and department.

Step 2: Capture Image

  • The system captures images of the employee using the webcam.
  • Multiple images may be captured to account for different facial expressions and angles.

Step 3: Store Image in Dataset Folder

  • The captured images are stored in a designated folder, with each image labeled according to the employee’s ID.

Step 4: Insert Details in DB

  • The employee’s details and image paths are inserted into the SQLite database for future reference.
  1. Model Training

Step 1: Load Dataset

  • The system loads the images and corresponding IDs from the dataset folder.

Step 2: Train LBPH Recognizer

  • The LBPH recognizer is trained using the loaded dataset.
  • The training process involves converting the images into grayscale, extracting features, and creating a feature vector for each image.

Step 3: Save Trained Model

  • The trained model is saved for later use in the recognition phase.
  • Saving the model ensures that the training process does not need to be repeated every time the system starts.
  1. Real-Time Recognition

Step 1: Open Camera

  • The system activates the webcam and begins capturing video frames.

Step 2: Face Recognition Loop

  • A continuous loop processes each frame captured by the webcam.

Step 3: Capture Frame from Camera

  • Each frame is captured and processed individually.

Step 4: Detect Faces

  • The Haar Cascade classifier detects faces in the current frame.
  • If no face is detected, the system continues to the next frame.

Step 5: Retrieve Details

  • If a face is detected, the system uses the LBPH recognizer to identify the face.
  • The system retrieves the associated profile details from the SQLite database.

Step 6: Display Results

  • The recognized face and profile information are displayed on the screen.
  • If the face is not recognized, the system may prompt to add the new face to the database or simply notify that the individual is not an employee.

Using the following steps, our LBPH and OpenCV-based face recognition system protects organizations from unauthorized access from people with bad intent.