想实现的结果:摄像头识别到二维码后(二维码扫描得到的内容为1),openmv控制舵机运动抓取物体。
from pyb import Servo
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()
s1 = Servo(1) # servo on position 1 (P7) 控制舵机1
s2 = Servo(2)
s3 = Servo(3)
while(True):
clock.tick()
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():
img.draw_rectangle(code.rect(), color = (255, 0, 0))
print(code)
while(data_type()==1):
#舵机转动角度
如上,控制舵机的程序,不知道while()里条件怎么填。希望识别到二维码的内容1后舵机能做相应运动。