2.8 Facial recognition

 

1. Learning objectives

In this course, we will realize k210 vision module performs face recognition.

When different faces are recognized, the Micro:bit led dot matrix displays different face serial numbers and plays different music.

In this course, we are recognize 3 different faces.

2. preparation before class

  1. Take out the TF card from the k210 vision module and insert it into the card reader.

01

  1. Plug the card reader into the computer, and wait for the computer to recognize the U disk.

02

  1. Then, enter the TF card U disk. You will see following content.

03

  1. Go to the k210 folder, find the 2.8_face_recog.py file from the folder and copy it to the root directory.

04

05

  1. Delete the main.py file.

    Then, rename the 2.8_face_recog.py file as the main.py file.

06

  1. After re-name, pull out the card reader, remove the TF card and insert it back into the k210 vision module.

3. Programming Methods

Online programming: first copy this URL https://makecode.microbit. and enter the online programming interface.

Copy the package URL: https://github.com/YahboomTechnology/K210-Module.git to the input field, click confirm to add the package, after that you can use the blocks of K210 vision module package.

4. Blocks

08

09

10

11

12

5. Code

13

6. Download code

Connect the Micro:bit board to the computer via micro USB cable, the computer will pop up a USB stick.

Then, select the microbit-face_rec.hex file and right click to send it to the Micro:bit U disk.

Wait until sending is complete and unplug the Micro:bit USB cable. Plug the Micro:bit board into the car.

7. Experimental phenomena

After starting the car, wait for the screen to display the camera image.

After the screen is displayed, the camera is pointed at the face, and if it is an unrecognized face, a white box will be displayed.

15

Press the K1 button in the upper right corner to record the face information, at this time the face serial number is 0, the white border changes to green border, and the recognized score is displayed.

Micro:bit led dot matrix displays the face serial number 0, and plays the music of serial number 0.

16

Continue to the unrecognized face, press the K1 button at the top right corner, at this time the face serial number is 1, the white border changes to a green border and the recognized score is displayed.

Micro:bit led dot matrix displays the face serial number 1 and plays the music of serial number 1.

17

Repeat the above operation for the recognized face.

Press the K1 button in the upper right corner, then the face serial number is 2, the white border changes to green border and the recognized score is displayed.

Micro:bit led dot matrix displays the face serial number 2 and plays the music of serial number 2.

18