为什么我这一段代码显示的十字总在左上角?
-
import sensor, image sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) sensor.skip_frames(30) sensor.set_auto_gain(False) while(True): img = sensor.snapshot() img.lens_corr(1.8) blobs = img.find_qrcodes() if blobs: for b in blobs: img.draw_rectangle(b[0:4]) img.draw_cross(b[5], b[6],size=5,color=(0,0,0)) sensor.snapshot().save("example.jpg") for code in img.find_qrcodes(): print(code)
-
原因:b[5], b[6]不是中心点。
解决办法:
改为:img.draw_cross(int(b.x()+b.w()/2), int(b.y()+b.h()/2),size=5,color=(0,0,0))