The English name of face recognition is Face Recognition, Some time ago, when I searched for data science, I found that , Many people will face recognition and face detection (Face
Detection) be confused , It greatly increases the difficulty of querying learning materials , On the basis of referring to some predecessors , Write your own code , A complete version has been sorted out .


         This series of articles will be integrated from theory to practice : Narrate in three parts ,
The first part of face recognition from zero , Make sure that most of your friends can understand the concept of face recognition through this article , And can form a basic framework . The second part will carry out preliminary practice , Including face image acquisition , And how to use opencv Existing models are trained according to face images , Get the required classifier . The third is comprehensive , Show the program in modularity , Face recognition and establishment in document form MFC Face recognition by program .


One , Face detection and recognition

First of all, we need to introduce the difference between face recognition and face detection . Face detection refers to the detection of a picture , Detect whether there is a face in the picture ; Face recognition is based on face detection , Not only to detect whether there is a face in the picture , It is necessary to further compare the detected face image with the existing face database , Identify which one of the corresponding databases of the face image .
Face detection knowledge can refer to the official account of WeChat. (Mr_cplus) Related historical articles of .

Two , General process of face recognition

      Face recognition is generally divided into four steps : Face image acquisition and detection , Face image preprocessing , Face image feature extraction , Matching and recognition .

(1) Face image acquisition and detection

Face image acquisition refers to the acquisition of face image according to the research objectives ( For example, face recognition under different postures ), Collecting a certain amount of image data and organizing it into a database . At present, there are many ready-made face databases in academia , Meet basic research needs , Of course, it can also be added on the basis of these databases ( For example, add your own face to a database ). Currently, the most commonly used face image databases are :

1. FERET Face database
from FERET Project creation , contain 14,051 Zhang duo's posture , Gray face image of illumination , It is one of the most widely used face databases in the field of face recognition . Most of them are Westerners , Each person's face image has a single change . 
2. MIT Face database  
      Created by MIT Media Lab , contain 16 Volunteer 2,592 Zhang different posture , Face images in light and size . 
3. Yale Face database  
      Created by Yale computing vision and control center , contain 15 Volunteer 165 Pictures , Include light , Changes in expression and posture . 
4. Yale Face database B
Contains 10 individual 5,850 Amplitude multi attitude , Multi illumination image . The images of attitude and illumination change are collected under strict control , Mainly used for modeling and analysis of illumination and attitude problems . Due to the small number of people collected , The further application of the database is limited . 
5. PIE Face database
Founded by Carnegie Mellon University , contain 68 Volunteer 41,368 Zhang duo's posture , Face images of light and expression . The attitude and illumination change images are also collected under strict control , At present, it has gradually become an important test set in the field of face recognition . 
6. ORL Face database
By Cambridge University AT&T Lab creation , contain 40 People in total 400 Face images , Some of the volunteers' images included posture ,  Changes in expression and facial accessories . This face database is often used in the early days of face recognition research , But there are few modes of change , The recognition rate of most systems can reach 90% above , Therefore, the value of further utilization is not great . 

(2) Face image preprocessing

         Here mainly refers to two aspects : One is how to process the acquired face image , Make it the same size as the image data to be put into the face database , Format, etc ; The other is to process the pictures in the whole library , Make it meet the requirements of feature extraction and recognition .

(3) Face image feature extraction

Face image feature extraction is based on a certain algorithm , Processing face image , Extract feature information , Forming characteristic matrix, etc , Then used for classifier training . The algorithm of feature extraction often determines the recognition effect .

(4) Matching and recognition

The feature matrix of face image is formed by feature extraction , After that, the face image to be recognized ( Or some frames in the video ) As input , According to the same feature extraction algorithm , The matrix of human face , And then classify with classifier , Identify which category it belongs to in the library .

Three , Common methods of face recognition

        There are many face recognition methods , At present, it can be roughly divided into four categories :

Recognition algorithm based on face feature points (Feature-based recognition algorithms).

Recognition algorithm based on whole face image (Appearance-based recognition algorithms).

Template based recognition algorithm (Template-based recognition algorithms).

An algorithm of recognition based on Neural Network (Recognition algorithms using neural network).

Four , Advance presentation of some results

       The face database used in this practice is
ORL Face database , And in order to recognize their own faces, I wrote a photo taking program to take self portraits , Add the collected image information to the database , Form a new database containing face information .

1, Take the document program as an example to show , When the camera detects that the face is itself , Meeting “ Exaggerate " I am “
Shuaibi ”, It will be displayed when the test result is not self “ Ugly force ”. Ha ha ha , It's no secret that I'm handsome !(41 It refers to the result of identification judgment ,41 For myself ,ORL Central Plains 40 personal )

2, with MFC Show the program as an example . same , When the camera detects that the face is itself , Meeting “ Exaggerate " I am “
Shuaibi ”, It will be displayed when the test result is not self “ Ugly force ”. And it can be set when the test result is one of the databases , In another picture control (picture
control) The corresponding image in face database is displayed in .( various BUTTON Represent different functions , This will be covered in the next two articles .)

That's all , If it works , Please pay attention ~