Face Spoofing Detection Using Colour Texture Analysis
Most of the existing face recognition systems currently available are vulnerable to spoofing attacks. A spoofing attack occurs when someone tries to bypass a face recognition biometric system by presenting a fake face in front of the camera. The fake face can be obtained in different ways, from the naivest ones, like showing to the camera a picture or a video of the subject (using a printed sheet or another device screen), to the most elaborated, as building a 3D mask of the interested subject. Face Spoofing Detection, also known as Presentation Attack Detection (PAD), aims at identifying when someone is trying to perform a Presentation Attack, avoiding this person to gain access to the desired data. PAD systems can rely on a wide group of possible approaches to counteract attackers and are generally more efficient when coupled together.
This repository is a student project developed by Kevin Depedri and Matteo Brugnera for the "Signal, Image and Video" course of the Master in Artificial Intelligent Systems at the University of Trento, a.y. 2021-2022.
The repository is composed of:
The execution of the code is divided in phases as follows:
The SVM classifier has been trained on a restricted set of images acquired in static and normal indoor light condition. Due to the restricted amount of data present in the dataset we do not ensure a perfect generalization in all light conditions. Indeed, problems of detection (for eye-blink and face recognition) or wrong predictions (false positive or false negative) may arise when dealing with extreme light conditions (very bright or very dark).
When testing the code please note that, while phase 1 (eye-blink) is evaluated depending on the sequence of frames acquired from a webcam, phase 2 and 3 can easily be tested on different inputs just changing the input path at line 63
of the file main.py
. In this way, if the user is interested, it will be possible to text the histogram-analysis phase of the algorithm on specific input images. Exactly for this reason, we have attached two input images (one real and one fake) that you can use to test the algorithm on specific input. To do so you will need to change at line 63 of main.py
the path 'face_detected.jpg'
in 'face_detected_true.jpg'
or 'face_detected_fake.jpg'
.
To build the virtual environment follow the next few steps
git clone https://github.com/KevinDepedri/Face-Spoofing-Detection-Using-Colour-Texture-Analysis
cd Face-Spoofing-Detection-Using-Colour-Texture-Analysis
python -m venv venv
venv/Scripts/pip install -r requirements.txt
python3 -m venv venv
venv/bin/pip install -r requirements.txt
To run the code, once the virtual environment has been built, you will need to
./venv/Scripts/activate # if on Windows
source ./venv/bin/activate # if on Unix
python ./main.py <flags>
When running the code different types of flags
can be used to show the data computed by the algorithm. The list of available flags is:
-pe
, plot EAR (mean value) computed during the check of the eye-blink-pc
, plot channels (RGB, Y, Cb, Cr, H, S, V) of the input image that will be used during the first phase of the histogram analysis-pad
, plot all descriptors (channel: Y, Cb, Cr, H, S, V) computed during the histogram analysis-pfd
, plot final descriptor (concatenation of channels: Y, Cb, Cr, H, S, V) computed at the end of the histogram analysis. The final decision of the SVM will be based on that final descriptor