c_x = 160 * 0.5 # 默认值(image.w * 0.5)
c_y = 120 * 0.5 # 默认值(image.h * 0.5)图片位置
def degrees(radians):
return (180 * radians) / math.pi#计算弧度
while(True):
img = sensor.snapshot() # Take a picture and return the image.
for tag in img.find_apriltags(fx=f_x, fy=f_y, cx=c_x, cy=c_y): # 默认为TAG36H11
if blobs:
print('sum :', len(apriltag))
output_str = json.dumps(apriltag)
for a in apriltag:
# Draw a rect around the blob.
img.draw_rectangle(a.rect()) # rect
img.draw_cross(a.cx(), a.cy()) # cx, cy
print('you send:',output_str)
uart.write(output_str+'\n')
else:
print('not found!')你要先确定好协议,用二进制发送,还是字符串发送,然后生成数据。