import sensor, image, time,pyb
from pyb import Pin
from pyb import LED
red_threshold = (54, 65, 54, 79, 16, 48)
blue_threshold = (42, 65, 5, 48, -87, -33)
green_threshold = (44, 82, -54, 1, -6, 24)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(10)
sensor.set_auto_whitebal(False)
led1 = pyb.LED(1)
led2 = pyb.LED(2)
led3 = pyb.LED(3)
p3 = Pin('P0', Pin.OUT_PP)
p4 = Pin('P1', Pin.OUT_PP)
p5 = Pin('P2', Pin.OUT_PP)
p6 = Pin('P3', Pin.OUT_PP)
while(True):
img = sensor.snapshot()
blobs1 = img.find_blobs([red_threshold],roi=(270,5,150,250), pixels_threshold=150, area_threshold=200,merge=True)
blobs2 = img.find_blobs([blue_threshold],roi=(270,5,150,250), pixels_threshold=150, area_threshold=200,merge=True)
blobs3 = img.find_blobs([green_threshold],roi=(270,5,150,250),pixels_threshold=150, area_threshold=200,merge=True)
img.lens_corr(1.8)
for code in img.find_qrcodes():
print(code)
Data = code.payload()
if Data == '357':
i=0
while(i<1000):
p3.low()
p4.low()
p5.low()
p6.high()
i=i+1
print(i)
elif Data == '358':
i=0
while(i<1000):
p3.low()
p4.low()
p5.high()
p6.low()
i=i+1
print(i)
elif Data == '367':
i=0
while(i<1000):
p3.low()
p4.low()
p5.high()
p6.high()
i=i+1
print(i)
elif Data == '368':
i=0
while(i<1000):
p3.low()
p4.high()
p5.low()
p6.low()
i=i+1
print(i)
elif Data == '457':
i=0
while(i<1000):
p3.low()
p4.high()
p5.low()
p6.high()
i=i+1
print(i)
elif Data == '458':
i=0
while(i<1000):
p3.low()
p4.high()
p5.high()
p6.low()
i=i+1
print(i)
elif Data == '467':
i=0
while(i<1000):
p3.low()
p4.high()
p5.high()
p6.high()
i=i+1
print(i)
elif Data == '468':
i=0
while(i<1000):
p3.high()
p4.low()
p5.low()
p6.low()
i=i+1
print(i)
if blobs1:
for b in blobs1:
img.draw_rectangle(b[0:4])
print('red')
led1.on()
led2.off()
led3.off()
p3.high()
p4.low()
p5.low()
p6.high()
elif blobs2:
for b in blobs2:
img.draw_rectangle(b[0:4])
print('blue')
led1.off()
led2.off()
led3.on()
p3.high()
p4.low()
p5.high()
p6.low()

固件与IDE也升级到最新版本,依然报错
建议把OpenMV和延长线都寄回检查维修。