stm_ K210 facial recognition1. Communication between k210 and stm321.1 Experimental premises1.2 Experimental wiring1.3 Main code explanation1.4 experimental phenomena
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
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.
xint main()
{
//......
while(1)
{
if (k210_msg.class_n != 0)
{
if(k210_msg.class_n == 8)
{
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));
if(k210_msg.id == 'Y' || k210_msg.id == 'y')
{
sprintf(buff_com,"Yes\r\n");
USART2_Send_ArrayU8((uint8_t*)buff_com,strlen(buff_com));
}
else
{
sprintf(buff_com,"NO\r\n");
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
Face recognition only transmits K210_ The five Member variable of msg are x, y, w, h, and id. ID: The information is Y/N, with Y: recorded faces and N: mismatched faces