Lepton获取物体高温示例

# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# Lepton获取物体高温示例
#
# 此示例展示了如何使用颜色追踪获取物体的温度。

# 通过关闭AGC并设置最高和最低温度范围,您可以将Lepton变成
# 一个出色的特定温度物体探测传感器。话虽如此,FLIR Lepton是
# 微测辐射热计而非热电堆。因此,它需要经常自我重新校准(称为
# 平场校正——FFC)。此外,微测辐射热计设备需要板载处理支持
# 来应对温度漂移的影响,这称为辐射测量支持。

# FLIR Lepton快门说明:带辐射测量和快门的FLIR Lepton在升温过程中会经常暂停视频
# 以重新校准。随着传感器温度趋于稳定,这种情况会越来越少。
# 如有需要,您可以通过Lepton API强制禁止重新校准。
# 但不建议这样做,因为图像质量会随时间下降。

# 如果您使用的LEPTON不是Lepton 3.5,此脚本可能无法完美运行,因为其他
# 其他lepton没有辐射测量支持,或者它们的校准过程不够频繁
# 以应对温度变化(FLIR 2.5)。

import csi
import time

# 颜色跟踪阈值(灰度最小值,灰度最大值)
threshold_list = [(100, 255)]  # 跟踪非常热的物体

# 在此设置目标温度范围
# 500C 是 Lepton 3.5 传感器可以测量的最大值
# 在室温下,其最大值为 ~380C
min_temp_in_celsius = 0.0
max_temp_in_celsius = 400.0

# 初始化传感器。
csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(csi.GRAYSCALE)
csi0.framesize(csi.QQVGA)

# 启用高温测量模式
csi0.ioctl(csi.IOCTL_LEPTON_SET_MODE, True, True)
csi0.ioctl(csi.IOCTL_LEPTON_SET_RANGE, min_temp_in_celsius, max_temp_in_celsius)

# 跳过若干帧
csi0.snapshot(time=5000)
clock = time.clock()

print("Radiometry: " + "Yes" if csi0.ioctl(csi.IOCTL_LEPTON_GET_RADIOMETRY) else "No")
print("Resolution: %dx%d" % (csi0.ioctl(csi.IOCTL_LEPTON_GET_WIDTH), csi0.ioctl(csi.IOCTL_LEPTON_GET_HEIGHT)))

# 只有像素数超过“pixel_threshold”且面积超过“area_threshold”的blob才会被
# “find_blobs”返回。如果更改了“pixels_threshold”和“area_threshold”,请进行相应调整。
# 相机分辨率。"merge=True" 合并图像中所有重叠的斑点。


def map_g_to_temp(g):
    return ((g * (max_temp_in_celsius - min_temp_in_celsius)) / 255.0) + min_temp_in_celsius


while True:
    clock.tick()
    img = csi0.snapshot()
    for blob in img.find_blobs(
        threshold_list, pixels_threshold=200, area_threshold=200, merge=True
    ):
        stats = img.get_statistics(thresholds=threshold_list, roi=blob.rect)
        img.draw_detection(blob, label="%.2f C" % map_g_to_temp(stats.mean))
    print(
        "FPS %f - Lepton Temp: %f C"
        % (clock.fps(), csi0.ioctl(csi.IOCTL_LEPTON_GET_FPA_TEMP))
    )

results matching ""

    No results matching ""