Python programming example - using the Dragonboard 410c development board to achieve face recognition (2)

In the previous issue of face recognition based on the DragonBoard 410c development board, I have already taught you how to use Python to implement the first part of face recognition - face detection function. Today, based on the front face detection, further teach How do you use createFisherFaceRecognizer to perform face recognition on the dragonbaord 410c development board? Today, we will focus on the principle and calling method of this method. The processing is only to identify the face detected by the front face detection method and the face stored in the database. Matches and finally identifies the face object.

First, we need to prepare face data. Here I used the method of obtaining the face in the previous article, and wrote the getFace.py file. By executing the file, I collected the faces of three people on the Dragonboard 410c. Each person's face collects 5 different angle data and saves them in the 001, 002, and 003 folders under the usrImg folder. The corresponding names are 1.jpg, 2.jpg, 3.jpg, 4.jpg, 5 .jpg, these data are used as training data, and then based on the data, the method provided by FaceRecognizer is used to predict the test face.

Once the data is ready, you can use this data for simple face recognition. Based on the above data, use Python to write the program, import the data into the system, and then construct the corresponding training data set and label, where the same picture corresponds to the same The label data, the specific corresponding method is as follows:

Face image label

./usrImg/001/1.jpg 0

./usrImg/001/2.jpg 0

./usrImg/001/3.jpg 0

./usrImg/001/4.jpg 0

./usrImg/001/5.jpg 0

./usrImg/002/1.jpg 1

./usrImg/002/2.jpg 1

./usrImg/002/3.jpg 1

./usrImg/002/4.jpg 1

./usrImg/002/5.jpg 1

./usrImg/003/1.jpg 2

./usrImg/003/2.jpg 2

./usrImg/003/3.jpg 2

./usrImg/003/4.jpg 2

./usrImg/003/5.jpg 2

In the reading, read the list of limg and lables by the following code:

Dir = ['./usrImg/001/','./usrImg/002/','./usrImg/003/']
Name = ['1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg']
Lables = []
Limg = []
n = 0
For x in dir:
For y in name:
Obj = cv2.imread(x+y,0)
Obj2=cv2.resize(obj,(400,500))
Limg.append(obj2)
Lables.append(n)
n = n+1

Then you can call the methods provided in FaceRecognizer for face training, the specific code is as follows:

Model = cv2.createFisherFaceRecognizer();

Model.train(limg,np.array(lables))

After the training is completed, the test face is read. Here, the code in the previous face recognition article can be used to read the face, and then the face test can be performed. The specific code is as follows:

Img1 = cv2.imread('test.jpg',0)

Test=cv2.resize(img1,(400,500))

Result = model.predict(test)

Print result

After the completion, save the code and run the script to get the face detection result, which will output the label and similarity of the detected face. The result is as follows:

The above is the process of the entire face recognition implementation, and the subsequent blog will further improve how to use the camera to directly detect the face and identify the corresponding person, and display the name.

Video Cable

  • Video and stereo audio in one Cable Assembly
  • 24K gold plated RCA male connectors on each end
  • 25-gauge high quality video cable construction
  • 27-gauge high quality Audio cable construction
  • Bare copper braid shield for rejection of EM and RF interference

Hdmi To Audio Cable,Audio And Video Cable,Aux Audio And Video Cable,Rca To Rca Cable

CHANGZHOU LESEN ELECTRONICS TECHNOLOGY CO.,LTD , https://www.china-lesencable.com