logo

为什么矩形对象只能用for语句创建,不可以直接用=创建?

2021-02-17 22:20
C
syxh
THRESHOLD =(23, 103)
import sensor, image
from pyb import LED,Timer,Pin

sensor.reset()
sensor.set_vflip(True)
sensor.set_hmirror(True)
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QQQVGA)
sensor.set_auto_whitebal(True)
sensor.skip_frames(time = 2000)
clock = time.clock()

while(True):
    clock.tick()
    img = sensor.snapshot().mean(3).binary([THRESHOLD])
    img.draw_rectangle((0,10,80,60))
    rec = img.find_rects(roi=(0,20,80,60),threshold=55000)
    img.draw_rectangle(rec.rect(), color = (0, 255, 0))
    '''for rec in img.find_rects(roi=(0,20,80,60),threshold=55000):
        img.draw_rectangle(rec.rect(), color = (0, 255, 0))'''
ec952fe1-6e53-45ba-9f33-27108ce4ff71.png
2021-02-19 15:00
I
网红小智智 星瞳科技

img.find_rects返回的是列表,多个矩形,而不是一个矩形。