Example: 01-Camera/04-Global-Shutter/triggered_mode.py
# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Global Shutter Triggered Mode Example
#
# This example shows off setting the global shutter camera into triggered mode. In triggered mode
# snapshot() controls EXACTLY when integration of the camera pixels start such that you can sync
# taking pictures to some external movement. Since the camera captures all pixels at the same time
# (as it is a global shutter camera versus a rolling shutter camera) movement in the image will
# only be captured for the integration time and not the integration time multiplied by the number
# of rows in the image. Additionally, sensor noise is reduced in triggered mode as the camera will
# not read out rows until after exposing which results in a higher quality image.
#
# That said, your maximum frame rate will be reduced by 2 to 3 as frames are no longer generated
# continuously by the camera and because you have to wait for the integration to finish before
# readout of the frame.
import sensor
import time
sensor.reset() # 重置并初始化传感器。
sensor.set_pixformat(sensor.GRAYSCALE) # 将像素格式设置为灰度
sensor.set_framesize(sensor.VGA) # Set frame size to VGA (640x480)
sensor.skip_frames(time=2000) # 等待设置生效。
clock = time.clock() # 创建一个时钟对象来跟踪FPS。
sensor.ioctl(sensor.IOCTL_SET_TRIGGERED_MODE, True)
while True:
clock.tick() # 更新FPS时钟。
img = sensor.snapshot() # 拍照并返回图像。
print(clock.fps()) # 注意:OpenMV摄像头在连接至IDE时运行速度会降低约一半。
# 断开连接后,帧率应会提升。