tof_overlay.py

# Ce travail est publié sous licence MIT.
# Copyright (c) 2013-2023 OpenMV LLC. Tous droits réservés.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Cet exemple montre comment superposer une carte de profondeur aux images
# capturées par la caméra principale.
import csi
import image
import time
import tof

csi0 = csi.CSI()
csi0.reset()  # Réinitialiser et initialiser le capteur.
csi0.pixformat(csi.RGB565)  # Définir le format de pixel sur RGB565 (ou GRAYSCALE)
csi0.framesize(csi.VGA)  # Définir la taille de l'image sur QVGA (320x240)
csi0.framerate(30)
csi0.window((400, 400))  # Définir la taille de fenêtre à 240x240

# Initialiser le capteur ToF
tof.init()

# Horloge FPS
clock = time.clock()

while True:
    clock.tick()

    # Capturer une image
    img = csi0.snapshot()

    # Capturer les données TOF [carte de profondeur, distance min, distance max]
    try:
        depth, dmin, dmax = tof.read_depth(vflip=True, hmirror=True)
    except RuntimeError:
        continue

    # Mettre à l'échelle l'image et la mélanger avec le tampon d'image
    tof.draw_depth(
        img,
        depth,
        x_scale=img.width() / 8,
        y_scale=img.height() / 8,
        hint=image.BILINEAR,
        alpha=100,
        scale=(0, 4000),
        color_palette=image.PALETTE_DEPTH,
    )

    # Afficher les distances min et max.
    img.draw_string(
        (0, 0), f"Distance min: {int(dmin):4d}mm max: {int(dmax):4d}mm", color=(255, 0, 0), mono_space=False
    )

    # Afficher le FPS.
    print(clock.fps())

results matching ""

    No results matching ""