mirror of
https://github.com/openmv/openmv.git
synced 2025-09-26 23:09:13 +08:00
38 lines
809 B
Python
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())
|