from machine import UART,Timer
from fpioa_manager import fm
import sensor, image, lcd, time
(资料图片)
import KPU as kpu
import gc, sys
input_size = (224, 224)
labels = ['5', '6', '7', '8', '1', '2', '3', '4']
anchors = [, , , , , , , , , ]
#映射串口引脚
(6, _RX, force=True)
(7, _TX, force=True)
#初始化串口
uart = UART(, 9600, read_buf_len=4096)
def lcd_show_except(e):
import uio
err_str = ()
_exception(e, err_str)
err_str = err_()
img = (size=input_size)
_string(0, 10, err_str, scale=1, color=(0xff,0x00,0x00))
(img)
def main(anchors, labels = None, model_addr=0x300000, sensor_window=input_size, lcd_rotation=0, sensor_hmirror=False, sensor_vflip=False):
()
_pixformat()
_framesize()
_windowing(sensor_window)
_hmirror(sensor_hmirror)
_vflip(sensor_vflip)
(1)
_vflip(1) #设置摄像头翻转
(type=1)
(lcd_rotation)
()
if not labels:
with open('','r') as f:
exec(())
if not labels:
print("no ")
img = (size=(320, 240))
_string(90, 110, "no ", color=(255, 0, 0), scale=2)
(img)
return 1
try:
img = ("")
(img)
except Exception:
img = (size=(320, 240))
_string(90, 110, "loading model...", color=(255, 255, 255), scale=2)
(img)
try:
task = None
task = (model_addr)
_yolo2(task, , , 5, anchors) # threshold:[0,1], nms_value: [0, 1]
while(True):
img = ()
t = _ms()
objects = _yolo2(task, img)
t = _ms() - t
if objects:
for obj in objects:
pos = ()
_rectangle(pos)
OutNum=labels[()]
_string(pos[0], pos[1], "%s : %.2f" %(labels[()], ()), scale=2, color=(255, 0, 0))
print(OutNum)
(OutNum)
_string(0, 200, "t:%dms" %(t), scale=2, color=(255, 0, 0))
(img)
except Exception as e:
raise e
finally:
if not task is None:
(task)
if __name__ == "__main__":
try:
main(anchors = anchors, labels=labels, model_addr=0x300000, lcd_rotation=0)
# main(anchors = anchors, labels=labels, model_addr="\sd\")
except Exception as e:
_exception(e)
lcd_show_except(e)
finally:
()
下一篇:最后一页
frommachineimportUART,Timerfromfpioa_managerimportfmimportsensor,i
由机暴网络发行、以石器时代为背景的手游《恐龙神奇宝贝》第13届酋长之
广告
X 关闭
广告
X 关闭