Example: 01-Camera/05-Thermal-Cameras/01-FLIR-Lepton/lepton_target_temp_hotspot_rgb565_color_tracking.py
# 本作品采用MIT许可证授权。
# 版权所有 (c) 2013-2023 OpenMV LLC。保留所有权利。
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# 单色 RGB565 色块跟踪示例
#
# 此示例展示了使用 OpenMV Cam 和 FLIR LEPTON 进行单色 RGB565 跟踪。
# By turning the AGC off and setting a max and min temperature range you can make the lepton into
# a great sensor for seeing objects of a particular temperature. That said, the FLIR lepton is a
# microblobometer and not a thermophile. So, it needs to re-calibrate itself often (which is called
# flat-field-correction - FFC). Additionally, microblobmeter devices require pprocessing support
# onboard to deal with the effects of temperature drift which is called radiometry support.
# FLIR Lepton Shutter Note: FLIR Leptons with radiometry and a shutter will pause the video often
# as they heatup to re-calibrate. This will happen less and less often as the sensor temperature
# stabilizes. You can force the re-calibration to not happen if you need to via the lepton API.
# However, it is not recommended because the image will degrade overtime.
# 如果您使用的LEPTON不是Lepton 3.5,此脚本可能无法完美运行,因为其他
# 其他lepton没有辐射测量支持,或者它们的校准过程不够频繁
# 以应对温度变化(FLIR 2.5)。
import sensor
import time
import image
# 颜色跟踪阈值(L 最小值,L 最大值,A 最小值,A 最大值,B 最小值,B 最大值)
threshold_list = [(70, 100, -30, 40, 20, 100)]
# 在此设置目标温度范围
min_temp_in_celsius = 20
max_temp_in_celsius = 32
print("Resetting Lepton...")
# 这些设置在重置时应用
sensor.reset()
sensor.ioctl(sensor.IOCTL_LEPTON_SET_MODE, True)
sensor.ioctl(
sensor.IOCTL_LEPTON_SET_RANGE, min_temp_in_celsius, max_temp_in_celsius
)
print(
"Lepton Res (%dx%d)"
% (
sensor.ioctl(sensor.IOCTL_LEPTON_GET_WIDTH),
sensor.ioctl(sensor.IOCTL_LEPTON_GET_HEIGHT),
)
)
print(
"Radiometry Available: "
+ ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No")
)
# 使调色板变酷
sensor.set_color_palette(image.PALETTE_IRONBOW)
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time=5000)
clock = time.clock()
# 只有像素数超过“pixel_threshold”且面积超过“area_threshold”的blob才会被
# “find_blobs”返回。如果更改了“pixels_threshold”和“area_threshold”,请进行相应调整。
# 相机分辨率。"merge=True" 合并图像中所有重叠的斑点。
while True:
clock.tick()
img = sensor.snapshot()
for blob in img.find_blobs(
threshold_list, pixels_threshold=200, area_threshold=200, merge=True
):
img.draw_rectangle(blob.rect())
img.draw_cross(blob.cx(), blob.cy())
print(
"FPS %f - Lepton Temp: %f C"
% (clock.fps(), sensor.ioctl(sensor.IOCTL_LEPTON_GET_FPA_TEMP))
)