0% found this document useful (0 votes)
23 views10 pages

01 Face Recognition

The document outlines the use of the ESP32-S3 vision module for face recognition in a miniAuto project, detailing the program flow, wiring, and program download instructions. It explains the working principle of the ESP32-S3 module, the program's outcomes, and the implementation logic, including various functions for motor control and RGB LED settings. Additionally, it provides troubleshooting FAQs related to color recognition and camera orientation issues.

Uploaded by

Ywhite Eric
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views10 pages

01 Face Recognition

The document outlines the use of the ESP32-S3 vision module for face recognition in a miniAuto project, detailing the program flow, wiring, and program download instructions. It explains the working principle of the ESP32-S3 module, the program's outcomes, and the implementation logic, including various functions for motor control and RGB LED settings. Additionally, it provides troubleshooting FAQs related to color recognition and camera orientation issues.

Uploaded by

Ywhite Eric
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Face Recognition

In this section, miniAuto will use the ESP32-S3 vision module to recognize the
face. After the face is recognized, it will shake slightly and turn the green LED
on. This is a greeting.

1. Program Flowchart

2. ESP32-S3 Vision Module

ESP32-S3 development board integrates an ESP32 chip and a camera


module. After being inserted into the expansion board, it uses the I2C
communication interface to read color and face data through I2C
communication.

2.1 Working Principle


ESP32-S3 is equipped with an OV2640 camera module, which transmits the
captured image data to the ESP32 chip via a serial port. The ESP32 chip can
process the image and transmit it to other devices through I2C communication.

1
2.2 Wiring
Connect the ESP32-S3 module to any I2C interface on the expansion board
with a 4PIN wire.

3. Program Download
Note:

 The Bluetooth module must be removed before downloading the program, otherwise

the program download will fail due to serial interface conflict.

 Please turn the switch of the battery box to “OFF” when connecting the Type-B

download cable in case the download cable touches the power pin of the expansion board

by mistake, which may cause a short circuit.

3.1 Arduino UNO Program Download


1)Locate and open “02 Program File/02 UNO Face Recognition/esp32_face_
recognition” program file in the same dictionary as this section.
2)Connect the Arduino to the computer with the UNO cable (Type-B).

2
3)Click the “Select Board”, and the software will automatically detect current
Arduino serial interface. Then click to connect.

4)Click to download the program to the Arduino, and then wait for the
download to complete.

3.2 ESP32-S3 Program Download


1) According to “5.3 Live Camera Feed/01 Live Camera Feed”, flash the
firmware located in “02 Program File/01 Face Recognition
Firmware/face_IIC_slave_vf0.bin” in the same directory as this section to the
ESP32-S3 vision module.

3
2) After flashing, disconnect the Type-C cable. Turn on the miniAuto to run the
program.

4. Program Outcome
1) After powering miniAuto on, the RGB LED on the expansion board will turn
white.
2) When the face is recognized, the RGB LEDs of the ultrasonic sensor and
the expansion board will turn green. The car will simultaneously shake slightly
to indicate a greeting.

5. Program Analysis
The name of this program is “esp32_face_recognition.ino”. The
implementation logic of the program can be referred to the following flowchart:

4
5.1 Import Library File
Import the necessary Arduino, RGB, ultrasonic sensor, and ESP32-S3 vision
module communication header files for the game.

5.2 Define Pin and Create Objects


1) The Arduino pins used to connect the hardware are defined. They are RGB,
buzzer, and motor control pins.

2) Variables and constants needed for executing the program are defined.
They are the PWM limiting constant, the RGB light static array with each
element of type CRGB, the non-blocking delay function recording variable, the
face detection switch, and the current face detection result.

3) The ESP32-S3 vision module class and ultrasonic class are instantiated.

4) The motor initialization function, face detection task function, non-blocking


delay function, speed control function, and motor control function are declared.

5
5.3 Initial Settings
1) Initialize related hardware equipment in “setup()” function. The first is serial
interface, which sets the baud rate of communication to 9600 and the timeout
for reading data to 500ms.

2) Use the FastLED library to initialize RGB lights on expansion board.

Connect it to ledPin. Then set the color to white by calling “Rgb_Show” and
“ultrasound.Color” functions.

3) Initialize the communication interface of the ESP32-S3 vision module.

4) Call the “Motor_Init” function to initialize motor operation pin.

5) The buzzer pin is set to output mode. This controls the buzzer to make a
short sound and stop.

5.4 Loop Call Sub-function

After initialization is complete, the program enters the “loop” function. The
"Facedetect_Task" function is called in a loop. After recognizing the face,
miniAuto shakes slightly and turns green light on to make a greeting.

5.5 Non-blocking Delay Function

The function is used to achieve the same effect as the “delay(ms)” function.
6
The “millis()” function obtains the current timestamp and assigns it
to “currentTime”. The difference between the current timestamp and the
previous timestamp is calculated. If the difference is greater than the set
time, “currentTime” is assigned to “previousTime”. Return “true”.
Otherwise, return “false”. This achieves the delay without affecting other tasks.

5.6 “Facedetect_Task” Task Function

The “Facedetect_Task” function executes a response once a face is detected.


When a face is detected, the car will shake left and right. The RGB light will
change from white to green. The face detection switch will be turned on. If no
face is detected, the RGB light on the car will change from green to white. The
face detection switch will be turned off.

7
5.7 RGB LED Setting Function

This function sets the color of the RGB light on the expansion board. The
“rValue”, “gValue”, and “bValue” are written to the “rgbs” array. The
“FastLED.show()” function is called to set the color of the RGB light.

5.8 Motor Initialization Function

This function is used to initialize the motor pins. Call the “pinMode” function in
a “for” loop to set the motor IO port to output mode. Then, the
“Velocity_Controller” function is called to set the robot to stop.

5.9 Robot Velocity Control Function

The function sets the speed of each wheel of the robot. By analyzing the
kinematics of the robot's Mecanum wheels, the speed of each wheel can be
calculated. The calculated speed variables can be used as input parameters
for the “Motors_Set” function to adjust the motor speed and control the overall
movement of the robot. Please refer to relevant tutorials to learn about
kinematic analysis.

8
5.10 Motor Setting Function

This function adjusts the speed and direction of each wheel of the robot based
on the input parameter values. In the “for” loop, the robot's steering is adjusted
based on the calculated results. The “map” function maps the calculated
values from “0 to 100” to the range of “pwm_min to 255”. Next, the “digitalWrite”
and “analogWrite” functions sets the motor direction and speed.

9
6. FAQ
Q1:Since the code was upload, the color can not be recognized.
A:Please check that you have connected the 4-pin cable to the I2C interface.
Q2:Why the camera cannot recognize when I face it, but it can recognize
When flipped upside down?
A:Please flash another “bin” file to make the face recognized.

10

You might also like