想只识别二维码一次,为什么加上i+=1,就不识别二维码了,不加就可以识别
-
import sensor, image sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) # can be QVGA on M7... sensor.skip_frames(30) sensor.set_auto_gain(False) # must turn this off to prevent image washout... red_threshold=(30, 100, 15, 127, 15, 127) green_threshold=(30, 100, -64, -8, -32, 32) blue_threshold= (0, 15, 0, 40, -80, -20) i=0 K=1040 while(True): img = sensor.snapshot() img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens. if i<2: for code in img.find_qrcodes(): img.draw_rectangle(code.rect(), color = (255, 0, 0)) message=code.payload() print(message) img.draw_string(int(code.x()+code.w()/2),int(code.y()+code.h()/2),str(message)) if message[0]=="2": blobs = img.find_blobs([red_threshold]) if len(blobs) == 1: # Draw a rect around the blob. b = blobs[0] img.draw_rectangle(b[0:4]) # rect img.draw_cross(b[5], b[6]) # cx, cy Lm = (b[2] + b[3]) / 2 length = K / Lm print(length) i+=1
-
你这个i+1写哪在
-
你应该在if message[0]=="2"下面添加i+=1。