请提供全部代码。
请缩减成可以出现报错的最小完整代码。
@kidswong999
import sensor, image, pyb, os,time,utime
from pyb import Pin, Timer, LED
x = 640
y = 180
ROI = (0,300,x,y);
sensor.reset() # Initialize the camera sensor.
sensor.set_contrast(1)
sensor.set_gainceiling(16)
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.set_windowing(ROI)
sensor.skip_frames(time = 1000) # Let new settings take affect.
sensor.set_auto_whitebal(False) # Turn off white balance.
extra_fb = sensor.alloc_extra_fb(x, y, sensor.GRAYSCALE)
extra_fbb = sensor.alloc_extra_fb(x, y, sensor.GRAYSCALE)
extra_fb.replace(sensor.snapshot())
extra_fbb.replace(sensor.snapshot())
def CheckingArea(picture):
img = sensor.snapshot()
img.difference(picture)
stats = img.statistics()
if (stats[5] > 50):
return 1
else:
return 0
def systick(timer): # we will receive the timer object when being called
print("yes")
tim = pyb.Timer(2, freq=10)
tim.callback(systick)
#循环体
while(True):
CheckingArea(extra_fb)@kidswong999 发现如果有img = sensor.snapshot() 这句代码,就会出现定时器报错
import sensor, image, time
from pyb import Pin, Timer
sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.QVGA) # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.
def systick(timer): # we will receive the timer object when being called
print("yes")
tim = Timer(2, freq=10)
tim.callback(systick)
while(True):
clock.tick() # Update the FPS clock.
img = sensor.snapshot() # Take a picture and return the image.
print(clock.fps()) # Note: OpenMV Cam runs about half as fast when connected
# to the IDE. The FPS should increase once disconnected.已经提交issue
https://github.com/openmv/openmv/issues/460
@kidswong999 这个问题无法解决吗?