Temperature value of each pixel captured by LEPTON

Hi,

I use Lepton 3.5 with OpenMV board. I wanted to get the temperature values of each pixel of the frame captured(160*120). Are there any available codes for this. Could the pixel data be accessed in excel?

~Jubin

Hi, you need to put the camera into a target temperature range mode (see the flir example scripts) and then comment out the code in the example scripts that markup the image with blob locations.

You can then save the image to an SD card or save the image in OpenMV IDE by right clicking on the screen. Please make sure to keep the FLIR Lepton in grayscale mode when doing this do that you have a linear mapping of pixels with value 0-255 as the min/max temperature range you set the FLIR lepton to look for.

Hi,

I wanted to add the spot-meter feature and read the temperature value of a precise spot(roi) under measurement. I accessed the FLIR LEPTON IDD documentation and it has an example SDK interface code for obtaining spot-meter value, I have attached the snapshot of this). Could you kindly guide me on how to use this code in the OpenMV IDE for the OpenMV Lepton module to work with spot-meter feature. The spot-meter ability on an IR camera enables to measure specific temperature values of an object under study!

Thanking you,
~Jubin
Spotmeter C SDK Interface.JPG

Hi,

The saved image does not give temperature for each pixel. Is there any way to get temperature for each pixel in the frame?

Thanking you,
Jubin

Hi, do something like this to get the SPOT-O-Meter value:

import sensor, struct
data = sensor.ioctl(sensor.IOCTL_LEPTON_GET_ATTRIBUTE, 0x4ED0, 4)
radSpotmeterValue, radSpotmeterMaxValue, radSpotmeterMinValue, radSpotmeterPopulation = struct.unpack("<HHHH", data)

For other commands, you just need to pass the ID hex number and then the size in 16-bit shorts that are read from the device. Then you just have to unpack the data which will be in the order of the struct for the FLIR SDK. For the set operation you’d do a similar thing where you’d call the set attribute and then pass the SDK ID hex number along with a byte array of packed bytes which are the struct in the SDK document to send.

If you want to get the temperature per pixel please run the “lepton target temp hot spot color tracking” example under the FLIR lepton examples. You can set the min and max range which all pixels are mapped to in the image. Then pixels will go from 0-255 within your range you set. To get the temp per pixel you can look at the code in the example.

Hi,

I have a question regarding the colour thresholds and the min and max temperature range. If I set the colour threshold to (120, 255), the minimum temperature to 25 degrees and the maximum temperature to 45 degrees does this mean my minimum temperature is mapped to the 120 greyscale colour or is the minimum temperature mapped to a greyscale value of 0?

It would be 0. The thresholds are applied on the mapped image. You set a min and max temperature range which maps all pixels on the image to 0 to 255 which represent the min and max temperature range. This is just simple scaling…

Ok thank you

Hello,

Just a follow up question.

My script saves .jpg images. If I understood correctly, the max and min temps I selected will be mapped to 0 and 255 into an rgb image. Does this mean that the same rgb image could be actually encoding different temperatures if taken on two sessions with different max and min parameters ?

I think that I will add saving of parameters to be able to rescale everything to a common scale later.

Yes, I would open a file in python. Just use standard python code to open a text file and write out the file name and the temperature scale you used to that text file log. You can open the file in append mode so that you just append to it.

I understand you can simply get temperature values with Lepton 2.5, where the 14-bit value you get out is the temperature value in Kelvin * 100. How do I do this with the OpenMV?

You need to modify the C firmware if you want the RAW 14-bit value. We have no paths in our code to handle 14-bit data.

Can you get raw temperature data using the Rad Spotmeter commands (for individual pixels or groups of pixels)?

Yes, you can. You need to use our IOCTLs to issue FLIR API calls.

I’m trying to use this sample code you posted, but I’m not sure how to read/display the values such as radSpotmeterValue or radSpotmeterMaxValue

import sensor, struct data = sensor.ioctl(sensor.IOCTL_LEPTON_GET_ATTRIBUTE, 0x4ED0, 4)
radSpotmeterValue, radSpotmeterMaxValue, radSpotmeterMinValue, radSpotmeterPopulation = struct.unpack("<HHHH", data)

The values are 16 bit unsigned ints. Since that fits inside of a native python int you can treat them as regular ints. So, just print() them.

I think I need to first define the ROI, is there a command for that?

You have to read the lepton API and lookup the command for that and determine what struct to pass.

There are a lot of functions in the FLIR Lepton API. The python ioctls I expose allow you to access them all. It was not possible to code a wrapper in python for each one.

Hi Kwagyeman,

How are you? I am trying to do exactly what byrdman12 is trying to do. I would like to use radSpotmeterRoi and radSpotmeterValue in conjunction to obtain a temperature value for any given pixel. I saw your example code from a previous post:

data = sensor.ioctl(sensor.IOCTL_LEPTON_GET_ATTRIBUTE, 0x4ED0, 4)

. You did this for radSpotmeterValue. I understand how you calculated the command id for this one to yield 0x4ED0. The Command ID is module ID + command ID Base + command type + protection bit value. I am now trying to do the same thing for radSpotmeterRoi. However, the command id base for radSpotmeterRoi is 0xcc instead of 0x00. Does this mean that the command id will for radSpotmeterRoi will be 0x4Ecco or 0x4eco?

Thank you in advance.