识别二维码,之后进行判断
-
我想先进行识别二维码,扫描出二维码的内容之后根据内容进行判断应该如何写
import sensor, image,pyb,time from pyb import UART from pyb import Pin uart = UART(3, 9600) led1 = pyb.LED(1) led2 = pyb.LED(2) led3 = pyb.LED(3) 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... while(True): img = sensor.snapshot() img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens. for code in img.find_qrcodes(): xingxi = code.payload() print(xingxi) uart.write(xingxi)
这是代码,例如:识别出二维码内容是123+123,让红灯亮,识别出内容321+321让绿灯亮。判断的程序应该怎么写
-
while(True): img = sensor.snapshot() img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens. for code in img.find_qrcodes(): xingxi = code.payload() print(xingxi) if xingxi == '123+123': print('OK') else: print('NOT OK')