Example: 01-Camera/06-Time-of-Flight/tof_camera.py
# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 飞行时间相机演示。
import image
import time
import tof
IMAGE_SCALE = 10 # 将图像缩放至10倍。
# 初始化ToF传感器
tof.init() # 自动检测连接的传感器。
# FPS时钟
clock = time.clock()
while True:
clock.tick()
try:
img = tof.snapshot(
vflip=True,
hmirror=True,
x_scale=IMAGE_SCALE,
y_scale=IMAGE_SCALE,
hint=image.BILINEAR,
scale=(0, 4000),
copy_to_fb=True,
color_palette=image.PALETTE_DEPTH,
)
img.flush()
except RuntimeError as e:
tof.reset()
print(clock.fps())