Overview of the implementation process of face recognition

First of all, I am a novice like everyone else.

They are all looking for blogs on the Internet to follow others to learn and do, and they know very little about face recognition.

After studying online for a period of time, the realization of face recognition is probably as follows:


The following environments need to be installed:  opencv-3.2.0 + opencv_+contrib-3.2.0


1. Data preparation - collect face images and preprocess them to build your own face database

        What is the basis for the so-called face recognition? It is to use the now obtained face image to match and judge with multiple original face images. The now obtained face image is generally an image captured by a camera in real time, or it can be a picture; where does the original one come from? Of course, it must be collected before identification. Therefore, data preparation is the foundation, and building a face database is the first step.

        How to collect faces? In what way?

        It was time to write a small program. Features of this applet:

1. It can automatically detect the face and frame the face part;

2. Realize one-click photo, take a face photo, the condition is that the photo can only be taken when a face is detected, and it will be ignored if there is no face;

3. For the face photos taken, cut out the face part and write it into a picture file, and automatically name it according to the number, and place it in the specified folder.


After collecting the above face photos, you need to manually assist:

Create a face library folder, and put the face photos of multiple people in this folder. Each face photo must be installed in a folder and named according to the rules.


2. Model training---training the collected face data

After preparing the face database, it is necessary to perform model training on the face database.

First of all, to prepare a csv file, what is the use of this file?

        During training, it is necessary to read the photo of each person in the face database and the corresponding label (the label is equivalent to the ID number of each face, which is different). The csv file is used to guide the training to read the photos and labels, and tell it where the face of A is, what the label is, and how much of B. . . Of course, csv will have its specific format and cannot be written indiscriminately.

        How to write csv file? Of course, writing a small program is automated. Provided later.

        With the csv file in hand, the model training program can read the data it needs. The purpose of model training is to obtain an xml file, which should be loaded for face recognition and recognized according to this file.


3. Face Recognition---Open the camera (or face picture) for recognition

The xml file obtained by the model training comes in handy here.

First call the camera to use the image, load the face detector and face model xml file, detect the face, match the face with the model, and output the recognition result.


This is the general face recognition implementation process. If you have time, you should read more official documents, which is very helpful.

Face recognition official tutorial document: https://docs.opencv.org/3.2.0/da/d60/tutorial_face_main.html

Another Chinese version of a netizen translation is provided: http://www.cnblogs.com/guoming0000/archive/2012/09/27/2706019.html

Later, each step will be implemented separately, so stay tuned.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325520692&siteId=291194637