Lepton获取物体高温示例
import csi
import time
threshold_list = [(100, 255)]
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)))
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))
)