Welcome to K210 Module repository
6. ard_ K210-facial feature detection
ard_K210 facial feature detection
ard_K210 facial feature detection1.K210 and Arduino communication1.1 Experimental premises1.2 Experimental wiring1.3 Main code explanation1.4 experimental phenomena
1.K210 and Arduino communication
1.1 Experimental premises
This tutorial uses arduino, and K210 requires running the program in K210-AI (stm32_pico_arduino) to start the experiment arduino *1 K210 perspective module * 1 (requires SD card (with AI model inside) and camera) USB to TTL module * 1
1.2 Experimental wiring
| arduino | usb to ttl |
|---|---|
| TXD | RXD |
| GND | GND |
| arduino | K210 perspective module |
|---|---|
| RXD | TXD |
| GND | GND |
| VCC | 5V |
| Wiring as shown in the diagram: |


1.3 Main code explanation
void loop(){ while (K210Serial.available()) { recv_k210msg(K210Serial.read()); if (k210_msg.class_n != 0) { if(k210_msg.class_n == 6) { 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); K210Serial.print(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 facial feature detection, and the serial assistant will print out the important information transmitted from k210 to stm32, as shown in the following figure

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