Explication de routine-09-selective_search Recherche sélective
Cette routine est 09-sélective_search
# 选择性查找例程
import sensor, image, time
from random import randint
sensor.reset()                      # 复位并初始化传感器。
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
#设置图像色彩格式,有RGB565色彩图和GRAYSCALE灰度图两种
sensor.set_framesize(sensor.QVGA)   # 将图像大小设置为QVGA (320x240)
#设置图像像素大小
sensor.skip_frames(time = 2000)     # 等待设置生效。
sensor.set_auto_gain(False)
sensor.set_auto_exposure(False, exposure_us=10000)
clock = time.clock()                # 创建一个时钟对象来跟踪FPS帧率。
while(True):
    clock.tick()                    # 更新FPS帧率时钟。
    img = sensor.snapshot()         # 拍一张照片并返回图像。
    rois = img.selective_search(threshold = 200, size = 20, a1=0.5, a2=1.0, a3=1.0)
    for r in rois:
        img.draw_rectangle(r, color=(255, 0, 0))
        #img.draw_rectangle(r, color=(randint(100, 255), randint(100, 255), randint(100, 255)))
    print(clock.fps())