import sensor, image, time, pyb
from pyb import UART
red_threshold = (14, 68, 11, 70, 9, 56) #红色阈值设定
sensor.reset() # 初始化摄像头传感器.
sensor.set_pixformat(sensor.RGB565) # 使用RGB565.
sensor.set_framesize(sensor.QVGA) # 使用QVGA.
sensor.skip_frames(10) # 让新设置生效.
sensor.set_auto_whitebal(False) # 关闭自动白平衡.
clock = time.clock() # Tracks FPS.
while(True):
img = sensor.snapshot() # 拍照并返回图像.
blobs = img.find_blobs([red_threshold])
for blob in blobs:
img.draw_rectangle(blob.rect())
img.draw_cross(blob.cx(), blob.cy())