import sensor, image, time, lcd, pyb
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) # must turn this off to prevent image washout...
clock = time.clock()
lcd.init() # Initialize the lcd screen.
while(True):
clock.tick()
img = sensor.snapshot()
for i in range(10):
x = (pyb.rng() % (2*img.width())) - (img.width()//2)
y = (pyb.rng() % (2*img.height())) - (img.height()//2)
r = (pyb.rng() % 127) + 128
g = (pyb.rng() % 127) + 128
b = (pyb.rng() % 127) + 128
img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens.
for code in img.find_qrcodes():
img.draw_rectangle(code.rect(), color = (255, 0, 0))
print(code)
img.draw_string(x, y, code.payload(), color = (255, 0, 0), scale = 5, mono_space = False)
lcd.display(img)
print(clock.fps())定义一个变量啊,img一直画这个变量字符串就行了,当检查到二维码就把变量重新赋值。
要显示的字符串 = ''
while True:
二维码们 = img.find_qrcodes()
for 二维码 in 二维码们:
要显示的字符串 = 二维码.payload()
img.draw(坐标,要显示的字符串)
lcd.display(img)请问下第一行要显示的字符串=“”怎么用代码表示
a = ''那是不是 a="code.payload"
while True:
for code in img.find_qrcodes()
a=code.payload()
img.draw()
lcd.display(img)