怎么把人脸检测的方框数提取出来,并传输给单片
-
import sensor, time, image, pyb,lcd from pyb import UART led = pyb.LED(3) sensor.reset() sensor.set_contrast(1) sensor.set_gainceiling(16) sensor.set_framesize(sensor.HQVGA) sensor.set_pixformat(sensor.GRAYSCALE) face_cascade = image.HaarCascade("frontalface", stages=25) uart = UART(3,19200) print(face_cascade) clock = time.clock() lcd.init() # Initialize the lcd screen. while (True): clock.tick() img = sensor.snapshot() objects = img.find_features(face_cascade, threshold=0.75, scale_factor=1.25) for a in objects: img.draw_rectangle(a) time.sleep(2000) uart.write("%s",a[2]) time.sleep(1000)请在这里粘贴代码
-
draw_rectangle(a),其中的a就是方框的矩形元组,你可以print(a)看一下。
-
@yuan 不能直接print(a)
-
@yuan import sensor, time, image, pyb,lcd
from pyb import UART
led = pyb.LED(3)
sensor.reset()
sensor.set_contrast(1)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.HQVGA)
sensor.set_pixformat(sensor.GRAYSCALE)
face_cascade = image.HaarCascade("frontalface", stages=25)
uart = UART(3,19200)
print(face_cascade)
clock = time.clock()
lcd.init() # Initialize the lcd screen.
while (True):
clock.tick()
img = sensor.snapshot()
objects = img.find_features(face_cascade, threshold=0.75, scale_factor=1.25)
for a in objects:
img.draw_rectangle(a)
time.sleep(2000)
uart.write("%s",a[2])
time.sleep(1000)print(clock.fps())
lcd.display(img) # Take a picture and display the image.
这是代码,我要把检测到的人脸个数传送给单片机
-
输出人脸个数,就是输出检测到人脸后返回的列表个数。
num=len(objects)
-
@yuan openmv的上位机是可以打印出来有几个框,但是单片机接回来的数据是00 30 00
下面是单片机的主函数代码
void macUSART_INT_FUN(void)
{
static uint16_t usRxCount = 0;if(USART_GetITStatus( macUSARTx, USART_IT_RXNE ) != RESET) { ucTemp = USART_ReceiveData( macUSARTx ); /* 遇到换行字符,认为接收到一个命令 */ Usart_SendStr_length( macUSARTx, ucaRxBuf, usRxCount ); a = ucaRxBuf[24]; printf("%d",a); usRxCount = 0; } else { ucaRxBuf[usRxCount++] = ucTemp; }
}
int main(void)
{
// /* USART1 配置模式为 115200 8-N-1,中断接收 */
USARTx_Config();
NVIC_Configuration();Usart_SendString( macUSARTx, "这是一个串口中断接收回显实验\n" ); Usart_SendString( macUSARTx, "输入数据并以回车键结束\n" );
}
-
因为你的openmv里的代码,发送的是ascii字符串,接受代码里显示的数字
-
@维他奶 把分辨不同人脸的结果传给单片机,单片机的接受程序要怎么写呢
-
@1xg5 不同的问题,单独发帖子提问。