This repository contains the Python scripts developed for a bachelor thesis project focused on face liveness detection. The project aims to utilize various image processing and machine learning techniques to reliably detect live faces in real-time video feeds. Each script in this repository performs specific functions that contribute to the overarching goal of enhancing face liveness detection accuracy and efficiency.
Detects faces in real-time video feeds using a YOLOv8 model and saves the cropped face images. This is the central script for face liveness detection. After installing the required dependencies, users need to run only this script to activate the face detection functionality. No additional scripts or setup are necessary.
- Requirements: os, numpy, cv2, ultralytics (YOLO), time, dlib, pathlib
Enhances a dataset by applying a series of image transformations to increase variability, including random rotations and brightness adjustments.
- Requirements: os, imgaug, pathlib, imageio
Extracts detailed facial features for recognition or analysis tasks using pre-trained models.
- Requirements: numpy, cv2, dlib
Implements the Hough Line Transform method to detect lines in images.
- Requirements: cv2, numpy
Classifies images using PCA-transformed features with an SVM classifier, focusing on color spaces combined features.
- Requirements: numpy, joblib, os
The /src/dev directory contains additional scripts and tools used during the development of this project. These include experimental and utility scripts that are not necessary for the main functionality of the application but were crucial during the developmental stages.
Generates and visualizes confusion matrices for classification results, primarily useful for assessing model performance.
Normalizes face images by aligning and scaling them to a standard format, improving the consistency of input data for facial recognition systems.
Applies edge detection to images, utilizing techniques such as Canny edge detection and other algorithms.
This script is adapted from Adrian Rosebrock’s tutorial on LBP with OpenCV, focusing on the practical application and visualization of LBP. The script includes functionality to display the original grayscale image, the transformed LBP image, and the histogram of LBP values.
To run these scripts, ensure you have Python installed along with the necessary libraries. Each script can be executed individually via the command line. To initiate a script, use the following command:
python <script_name>.pyFor face liveness detection, run the face_detection.py script. This is the primary script and does not require running any other scripts or additional setup post-installation of the required libraries. Simply execute the script as follows to start the face detection process:
python face_detection.pyYou can install all required dependencies using pip:
pip install -r requirements.txtDownload the YOLOv8 model file from the official repository or source:
https://github.com/noorkhokhar99/face-detection-yolov8
Download the .dat file and store it in your project directory where the scripts can easily access it:
Tomáš Homola