1688| 0
|
[问题求助] 无法用串口通信的方式给电脑发消息,会报错,下是源代码 |
import sensor,image,lcd import KPU as kpu from fpioa_manager import fm from machine import UART import time # need your connect hardware IO 10/11 to loopback fm.register(10, fm.fpioa.UART1_TX, force=True) fm.register(11, fm.fpioa.UART1_RX, force=True) uart = UART(UART.UART1, 115200, 8, 1, 0, timeout=1000, read_buf_len=4096) uart.write(b'hello world') lcd.init() sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.set_windowing((224, 224)) sensor.set_vflip(1) sensor.run(1) classes = ["battery","pills","bananas","cans","apples","bottles","ceram","green vegatable","broccoli","boxes","glass","cigarette","orange","eggshell","spitball"] task = kpu.load("/sd/yolov2.kmodel") anchor = (0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828) a = kpu.init_yolo2(task, 0.8, 0.3, 5, anchor) while(True): img = sensor.snapshot() a = img.pix_to_ai() code = kpu.run_yolo2(task, img) if code: for i in code: uart.write(code) # send data back a=img.draw_rectangle(i.rect(),color = (0, 255, 0)) a = img.draw_string(i.x(),i.y(), classes[i.classid()], color=(255,0,0), scale=3) a = lcd.display(img) else: a = lcd.display(img) a = kpu.deinit(task) |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed