Welcome to K210 Module repository
5. stm_ K210 Face Detection
stm_ K210 Face Detection
stm_ K210 Face Detection1. Communication between k210 and stm321.1 Experimental premises1.2 Experimental wiring1.3 Main code explanation1.4 experimental phenomena
1. Communication between k210 and stm32
1.1 Experimental premises
This tutorial uses stm32C8T6, and k210 requires running the program in * * K210-AI (stm32_pico_arduino) * * to start the experiment Stm32 * 1 K210 perspective module * 1 (requires SD card (with AI model inside) and camera) USB to TTL module * 1
1.2 Experimental wiring
| stm32 | usb to ttl |
|---|---|
| PA2 | RXD |
| GND | GND |
| STM32 | k210 |
|---|---|
| PA3 | TXD |
| GND | GND |
| VCC | 5V |
Wiring as shown in the diagram:


This type of wiring is not necessary for the RXD of k210 and the TXD of USB to TTL, as it was not used in the experiment.
1.3 Main code explanation
xint main(){ //...... while(1) { if (k210_msg.class_n != 0) { if(k210_msg.class_n == 5) { sprintf(buff_com,"x=%d,y=%d,w=%d,h=%d\r\n",k210_msg.x,k210_msg.y,k210_msg.w,k210_msg.h); USART2_Send_ArrayU8((uint8_t*)buff_com,strlen(buff_com)); k210_msg.class_n = 0; } } }}
After the above program, if you are running this routine, k210_ The members of the msg structure have corresponding values and are processed through serial port printing K210_ Msg: is a structure that receives information, and its main members are
- X: is the horizontal coordinate of the top left corner of the recognized box (range: 0-240)
- Y: is the vertical coordinate of the upper left corner of the identified box (range: 0-320)
- W: is the width of the recognized box (range: 0-240)
- H: The length of the recognized box (range: 0-320)
- ID: is the recognized label
- Class_ n: Routine number
- Msg_ Msg [20]: Valid data After receiving and processing data, k210_ Each member of the msg will store valid information. If you want to develop it again, call K210 directly_ Members of msg are sufficient
1.4 experimental phenomena
- After connecting the cable, the K210 perspective module runs offline. Please check 【6.2 K210 as coprocessor】--【ReadMe】
- Set the serial port assistant to the interface shown in the figure

- Then run the routine of face detection, and the serial assistant will print out the important information transmitted from k210 to stm32, as shown in the following figure

Face detection only transmits the four Member variable of k210msg: x, y, w, h.