How to get the temperature of ROI

I am using openmv h7 plus r3 thermal camera, i try to get the thermal data or temperature of the ROI using example code lepton_get_object_temp. I am getting gray scale image but i dint got any temperature data.Please let me know how to get the temperture of ROI.

What’s the output you are getting? The example should do something. I’m not sure what error you are getting is.

i am getting the gray scale image, and i also defined the ROI, but i unable to get temperature data of the is showing nothing.I just want to get the temperature in ROI.

"import numpy as np
roi_i = cv2.imread("D:\\thermal\\temp5.png")
roi = roi_i[300:360, 400:540]
Min_temp = 30
max_temp = 120
min_pix = 100
max_pix = 255
average_pixel_value = np.mean(roi, axis=(0, 1))
print("Red value:", average_pixel_value[2])
clipped_pixel_value = np.clip(average_pixel_value, min_pix, max_pix)
t = (((255-clipped_pixel_value[2])*(120-30)/(max_pix - min_pix))+30)
print("temperature:", t)
print("average pixel value:", average_pixel_value)
roi_rec = cv2.rectangle(roi_i, (400, 300), (540,360),(255, 255, 255), 2)
cv2.imshow("roi", roi_rec)

Here is code which i am using, i use to take the thermal image from camera and store it in the local disc,after the same image would be called by program to get the temperature value, the expected value was aroud 62degree, i got 71.4 degree, after 20 min, real time temperature around 50, i got 71.2.please let me any possible solution.

Here’s the default script. I just changed:

# Color Tracking Thresholds (Grayscale Min, Grayscale Max)
threshold_list = [(140, 255)]

# Set the target temp range here
min_temp_in_celsius = 20.0
max_temp_in_celsius = 50.0

So that it would track an object. You have to adjust the grayscale color threshold if you change the temperature range.

With my head in the picture the system reads about 36.94C which s around 100F. This is close to what temperature you expect a persons head to be. Note that like any sensor you have to calibrate the FLIR Lepton’s output if you want it to be super exact.

# This work is licensed under the MIT license.
# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
# Lepton Get Object Temp Example
# This example shows off how to get an object's temperature using color tracking.

# 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.

# If you are using a LEPTON other than the Lepton 3.5 this script may not work perfectly as other
# leptons don't have radiometry support or they don't activate their calibration process often
# enough to deal with temperature changes (FLIR 2.5).

import sensor
import time

# Color Tracking Thresholds (Grayscale Min, Grayscale Max)
threshold_list = [(140, 255)]

# Set the target temp range here
min_temp_in_celsius = 20.0
max_temp_in_celsius = 50.0

print("Resetting Lepton...")
# These settings are applied on reset
sensor.ioctl(sensor.IOCTL_LEPTON_SET_MEASUREMENT_MODE, True)
    sensor.IOCTL_LEPTON_SET_MEASUREMENT_RANGE, min_temp_in_celsius, max_temp_in_celsius
    "Lepton Res (%dx%d)"
    % (
    "Radiometry Available: "
    + ("Yes" if sensor.ioctl(sensor.IOCTL_LEPTON_GET_RADIOMETRY) else "No")

clock = time.clock()

# Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are
# returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the
# camera resolution. "merge=True" merges all overlapping blobs in the image.

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

while True:
    img = sensor.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())
            blob.y() - 10,
            "%.2f C" % map_g_to_temp(stats.mean()),
        "FPS %f - Lepton Temp: %f C"
        % (clock.fps(), sensor.ioctl(sensor.IOCTL_LEPTON_GET_FPA_TEMPERATURE))

1 Like