哪错了
-
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
-
除了格式之外的错误
-
首先你的代码,缩进是错的,先把缩进改完再说。
-
不是,是复制粘贴到论坛上时,自己乱的
-
但是你需要修改。
-
直接复制粘贴,文本是不会乱的,除非你的代码本来格式就不对。