openmv/scripts/examples/01-Camera/06-Time-of-Flight/tof_camera.py
2024-10-21 13:03:41 -07:00

38 lines
809 B
Python

# This work is licensed under the MIT license.
# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Time of flight camera Demo.
import image
import time
import tof
IMAGE_SCALE = 10 # Scale image to 10x.
# Initialize the ToF sensor
tof.init() # Auto-detects the connected sensor.
# FPS clock
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())