K2=1.79#26/31
uart = UART(3, 115200)
while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot() # Take a picture and return the image.
blobs = img.find_blobs([red_threshold])
if len(blobs) == 1:
# Draw a rect around the blob.
b = blobs[0]
img.draw_rectangle(b[0:4]) # rect
img.draw_cross(b[5], b[6]) # cx, cy
Lm = (b[5]+b[6])/2
length = K2/Lm
print(length)
#print(Lm)
size=K2*Lm
math.sqrt((cx()-160)**2 + (cy()-120)**2)
#print(size)
#x=K2*b[5]
#y=K2*b[6]
print("高:%s cm,宽:%s cm"%(x,y))
img.draw_string(15,10, ("高:%s cm,宽:%s cm"%(x,y)))
#print(clock.fps()) # Note: Your OpenMV Cam runs about half as fast while
# connected to your computer. The FPS should increase once disconnected.![0_1683338100651_灰色.png](https://fcdn.singtown.com/ec6a2e22-d981-44f4-b796-d596a9cecbe4.png)