# Untitled - By: Dell - 周四 9月 3 2020
import sensor, image, time
from pyb import Pin, Timer,LED
import math
sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(True) # must be turned off for color tracking
sensor.set_auto_whitebal(True) # must be turned off for color tracking
clock = time.clock()
blue_led = LED(3)
red_led = LED(1)
ROI = (200,80,240,280) # 定义感兴趣范围
MY_AREA=ROI
def tick1(timer):
red_led.toggle()
img = sensor.snapshot()
img.draw_rectangle(MY_AREA)
tim = Timer(2, freq=0.2) # 使用定时器2创建定时器对象-以1Hz触发
tim.callback(tick1)
#tim.callback(lambda t:tick()) # 将回调设置为tick函数
while (True):
img = sensor.snapshot()
img.draw_rectangle(MY_AREA)
time.sleep(10)
O
oraq 发布的帖子
-
定时器函数内读取图像出错为什么?