@yuan 那么请问这个输出数据的单位是mm吗
Q
qtw_dr 发布的帖子
-
请问能否解释以下这段测距的代码
import sensor, image, time
yellow_threshold = ( 56, 83, 5, 57, 63, 80)
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # use RGB565.
sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
sensor.skip_frames(10) # Let new settings take affect.
sensor.set_auto_whitebal(False) # turn this off.
clock = time.clock() # Tracks FPS.K=5000#the value should be measured
while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot() # Take a picture and return the image.blobs = img.find_blobs([yellow_threshold]) if len(blobs) == 1:#为什么列表的长度是1? b = blobs[0] img.draw_rectangle(b[0:4]) # rect img.draw_cross(b[5], b[6]) # cx, cy Lm = (b[2]+b[3])/2 length = K/Lm print(length)