tof_overlay.py

# هذا العمل مرخص بموجب ترخيص MIT.
# حقوق النشر (c) 2013-2023 OpenMV LLC. جميع الحقوق محفوظة.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# يوضح هذا المثال كيفية تراكب خريطة عمق فوق الإطارات
# الملتقطة من الكاميرا الرئيسية.
import csi
import image
import time
import tof

csi0 = csi.CSI()
csi0.reset()  # إعادة ضبط المستشعر وتهيئته.
csi0.pixformat(csi.RGB565)  # تعيين تنسيق البكسل إلى RGB565 (أو GRAYSCALE)
csi0.framesize(csi.VGA)  # تعيين حجم الإطار إلى QVGA (320x240)
csi0.framerate(30)
csi0.window((400, 400))  # تعيين حجم النافذة إلى 240x240

# تهيئة حساس زمن الطيران (ToF)
tof.init()

# ساعة معدل الإطارات (FPS)
clock = time.clock()

while True:
    clock.tick()

    # التقاط صورة
    img = csi0.snapshot()

    # التقاط بيانات ToF [خريطة العمق، أقل مسافة، أقصى مسافة]
    try:
        depth, dmin, dmax = tof.read_depth(vflip=True, hmirror=True)
    except RuntimeError:
        continue

    # تحجيم الصورة ومزجها مع ذاكرة الإطار المؤقتة
    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,
    )

    # رسم أقل وأقصى مسافة.
    img.draw_string(
        (0, 0), f"Distance min: {int(dmin):4d}mm max: {int(dmax):4d}mm", color=(255, 0, 0), mono_space=False
    )

    # طباعة معدل الإطارات.
    print(clock.fps())

results matching ""

    No results matching ""