lepton_with_color_sensor_overlay_with_transform.py

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2026 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 此示例展示了将FLIR Lepton热成像叠加
# 在彩色传感器图像之上(使用图像变换)。
# 这仅适用于OpenMV Cam N6,它可以使用GPU
# 执行图像变换。

import time
import csi
import image
from ulab import numpy as np
import math

# 要获取将热成像视频叠加到彩色视频上的变换矩阵,请使用这里的工具:
# https://github.com/openmv/openmv-projects/tree/master/tools/thermal-overlay-calibration
m = np.array([
    [3.704807, 0.257018, 37.260564],
    [0.052147, 3.609977, -7.831831],
    [0.000294, 0.000552, 1.000000],
])

alpha_pal = image.Image(256, 1, image.GRAYSCALE)
for i in range(256):
    alpha_pal[i] = int(math.pow((i / 255), 2) * 255)

# 设置彩色相机传感器。
csi0 = csi.CSI()
csi0.reset(hard=True)  # 强制硬件复位。
csi0.pixformat(csi.RGB565)
csi0.framesize(csi.VGA)

csi1 = csi.CSI(cid=csi.LEPTON)
csi1.reset(hard=False)  # 不进行硬件复位——仅配置Lepton
csi1.pixformat(csi.GRAYSCALE)
csi1.framesize(csi.QQVGA)

# LEPTON的可选温度范围控制。
# csi1.ioctl(csi.IOCTL_LEPTON_SET_MODE, True, False)
# csi1.ioctl(csi.IOCTL_LEPTON_SET_RANGE, 20.0, 40.0)

clock = time.clock()

img1 = image.Image(csi1.width(), csi1.height(), csi1.pixformat())

while True:
    clock.tick()
    img0 = csi0.snapshot()
    csi1.snapshot(blocking=False, image=img1)
    img0.draw_image(img1, 0, 0, color_palette=image.PALETTE_IRONBOW,
                    alpha_palette=alpha_pal,
                    hint=image.BILINEAR,
                    transform=m)
    print(clock.fps())

results matching ""

    No results matching ""