Example: 50-OpenMV-Boards/60-Shields/62-Thermopile-Shield/thermal_overlay_lcd.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 热成像叠加演示
#
# 此示例展示了如何在OpenMV Cam上叠加热图。
# 来自主摄像头的实时视频输出。

import sensor
import image
import time
import fir
import display

# 或 image.BILINEAR 或 0(最近邻)
drawing_hint = image.BICUBIC | image.CENTER | image.SCALE_ASPECT_KEEP

ALT_OVERLAY = False  # 设置为True以分配第二个红外图像。

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA2)
sensor.skip_frames(time=2000)

# 初始化热传感器
fir.init()

# 初始化LCD。
lcd = display.SPIDisplay()

# 分配另一个帧缓冲区以获得更流畅的视频。
extra_fb = sensor.alloc_extra_fb(sensor.width(), sensor.height(), sensor.RGB565)

# FPS时钟
clock = time.clock()

while True:
    clock.tick()

    # 捕获图像
    img = sensor.snapshot()

    # 捕获FIR数据
    #   ta: Ambient temperature
    #   ir: Object temperatures (IR array)
    #   to_min: Minimum object temperature
    #   to_max: Maximum object temperature
    try:
        ta, ir, to_min, to_max = fir.read_ir()
    except OSError:
        continue

    if not ALT_OVERLAY:
        # 缩放图像并将其与帧缓冲区混合
        fir.draw_ir(img, ir, hint=drawing_hint)
    else:
        # 创建辅助图像并混合到帧缓冲区中。
        extra_fb.clear()
        fir.draw_ir(extra_fb, ir, hint=drawing_hint)
        img.blend(extra_fb, alpha=128)

    # 绘制环境、最低和最高温度。
    img.draw_string(8, 0, "Ta: %0.2f C" % ta, color=(255, 0, 0), mono_space=False)
    img.draw_string(
        8, 8, "To min: %0.2f C" % to_min, color=(255, 0, 0), mono_space=False
    )
    img.draw_string(
        8, 16, "To max: %0.2f C" % to_max, color=(255, 0, 0), mono_space=False
    )

    lcd.write(img)
    # 强制高质量流传输...
    img.to_jpeg(quality=90)

    # 打印FPS。
    print(clock.fps())

results matching ""

    No results matching ""