openmv刚开始运行然后卡住,一直亮红灯,求助
-
import sensor, image, time ,pyb from pyb import UART led_qr = pyb.LED(1) usb = pyb.USB_VCP() qrcode = "000+000" qr1="000" qr2="000" qr="000" scan_flag=1 qrcode_flag=1 num = [0,0,0] zhua=[0,0,0] red_threshold = (28,51,45,74,31,52) green_threshold = (39, 87, -58, -28, 5, 44) blue_threshold = (17, 65, -8, 18, -49, -14) sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(30) sensor.set_auto_whitebal(False) clock = time.clock() uart = UART(3, 9600) def find_max(blobs): max_size=0 for blob in blobs: if blob.pixels() > max_size: max_blob=blob max_size = blob.pixels() return max_blob while(scan_flag): img = sensor.snapshot() clock.tick() img.lens_corr(1.8) for code in img.find_qrcodes(): qrcode="%s" % code.payload() scan_flag=0 print(qrcode) uart.write(qrcode+'#') led_qr.on() time.sleep(150) led_qr.off() time.sleep(100) while (True): img = sensor.snapshot() clock.tick() c = uart.readchar()-48 while((qrcode_flag==1 and c==1) or (qrcode_flag==2 and c==2)): i=0 qr1=qrcode[0:3] qr2=qrcode[4:7] num=[0,0,0] zhua=[0,0,0] blobs_r = img.find_blobs([red_threshold]) blobs_g = img.find_blobs([green_threshold]) blobs_b = img.find_blobs([blue_threshold]) if blobs_r: max_r = find_max(blobs_r) img.draw_rectangle(max_r[0:4]) img.draw_cross(max_r[5], max_r[6]) num[0]=max_r[5] if blobs_g: max_g = find_max(blobs_g) img.draw_rectangle(max_g[0:4]) img.draw_cross(max_g[5], max_g[6]) num[1]=max_g[5] if blobs_b: max_b = find_max(blobs_b) img.draw_rectangle(max_b[0:4]) img.draw_cross(max_b[5], max_b[6]) num[2]=max_b[5] imin=min(num) imax=max(num) if qrcode_flag==1: qr=qr1 else: qr=qr2 for q in qr: if q=='1': if num[0]==imin: zhua[i]=1 elif num[0]==imax: zhua[i]=3 else: zhua[i]=2 if q=='2': if num[1]==imin: zhua[i]=1 elif num[1]==imax: zhua[i]=3 else: zhua[i]=2 if q=='3': if num[2]==imin: zhua[i]=1 elif num[2]==imax: zhua[i]=3 else: zhua[i]=2 i+=1 if (zhua[0]==1 and zhua[1]==2 and zhua[2]==3): print('1') uart.write('1') qrcode_flag=2 if (zhua[0]==1 and zhua[1]==3 and zhua[2]==2): print('2') uart.write('2') qrcode_flag=2 if (zhua[0]==2 and zhua[1]==1 and zhua[2]==3): print('3') uart.write('3') qrcode_flag=2 if (zhua[0]==2 and zhua[1]==3 and zhua[2]==1): print('4') uart.write('4') qrcode_flag=2 if (zhua[0]==3 and zhua[1]==1 and zhua[2]==2): print('5') uart.write('5') qrcode_flag=2 if (zhua[0]==3 and zhua[1]==2 and zhua[2]==1): print('6') uart.write('6') qrcode_flag=2
-
求大佬们帮帮忙,之前还可以的,这两天一直遇到这种情况,刚开始运行就卡住了。
-
如果你用VCP,就不要用OpenMV IDE调试代码。
因为OpenMV IDE就是用VCP调试的。