这个错误是怎么回事,求解(江湖救急)
5
5mo2
@5mo2
0
声望
4
楼层
323
资料浏览
0
粉丝
0
关注
5mo2 发布的帖子
-
哪错了
import sensor, image,time,pyb,utime import sensor, image, time,utime from pyb import UART p0 = pyb.Pin('P0', pyb.Pin.OUT_PP) p0.value(1) uart = UART(3, 57600) output_str=0 yanse=0 flag=1 while 1: if uart.any(): flag=uart.readline().decode() flag=int(flag) print(flag) if flag==1: thresholds = [(60, 18, 37, 75, -35, 76),(58, 24, -11, 17, -61, -16),(60, 30, -17, -58, -43, 31)] sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) sensor.set_auto_gain(False) sensor.set_auto_whitebal(False) while flag : if uart.any(): flag=uart.readline().decode() flag=int(flag) img = sensor.snapshot() blobs=img.find_blobs(thresholds, pixels_threshold=5000, area_threshold=400) for blob in blobs: img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) yanse="%s" % (blob.code()) print( yanse) pyb.delay(500) if yanse: pyb.delay(10) uart.write(yanse) p0.value(0) pyb.delay(10) p0.value(1) yanse=0 if flag==2: sensor.reset() sensor.set_pixformat(sensor.GRAYSCALE) sensor.set_framesize(sensor.VGA) sensor.set_windowing((240, 240)) sensor.skip_frames(30) sensor.set_auto_gain(False) while flag : img = sensor.snapshot() img.lens_corr(0.1) for code in img.find_qrcodes(): img.draw_rectangle(code.rect(), color = (255, 0, 0)) output_str="%s" % (code.payload()) print(output_str) pyb.delay(500) if output_str: uart.write(output_str) pyb.delay(10) p0.value(0) pyb.delay(10) p0.value(1) output_str=0 flag=0