请在这里粘import sensor, image, time
sensor.set_hmirror(True)
sensor.set_vflip(True)
sensor.reset()# 初始化sensor
sensor.set_pixformat(sensor.RGB565)#设置图像色彩格式
sensor.set_framesize(sensor.QQVGA)#设置图像像素大小、使用QQVGA的速度
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False) #关闭自动增益
sensor.set_auto_whitebal(False) #关闭白平衡
clock = time.clock()# 跟踪FPS帧率
while(True):
clock.tick()
img = sensor.snapshot()
for r in img.find_rects(threshold = 10000):
img.draw_rectangle(r.rect(), color = (255, 0, 0))
for tag in img.find_apriltags(): # 使用AprilTag标记,defaults to TAG36H11 without "families".
if tag.id()==0:
data=0
print('you send:',data_out)#写到串口监视端,让你能够看到数据
elif tag.id()==1:
data=1
print('you send:',data_out)#写到串口监视端,让你能够看到数据
else:
for r in img.find_rects(threshold = 10000):#识别atg码外的矩形的宽高
img.draw_rectangle(r.rect(), color = (255, 0, 0))
w =r.w() #宽度
h =r.h() #高度
print('you send:',w,h)#写到串口监视端,让你能够看到数据贴代码你为什么在19行找矩形之后,还在31行找?
为什么要在19行的找矩形遍历的过程中再找apriltag?
我感觉你逻辑写错了,应该把19行的找矩形删除。
@kidswong999
问题是else后面显示的结果是只能识别ATG码矩形不能对其他物品识别,如何改
把所有的draw_rectangle函数删掉。draw_rectangle会影响图像。
具体是不是这个原因不确定。