3
\$\begingroup\$

I'm working the the FLIR thermal camera and using the code provided by Pure Engineering. I've recently run into a problem with the images provided by the camera because I realized that the pixels are relative to each other. Meaning that the hottest object in the image will have the lightest color regardless of what the actual heat of the object is.

This is a major problem for me because I'm trying to determine if someone is in the object and can't do that if the pixel values are changing relative to the amount of heat in the image. I tried looking at the code and figuring out how to modify it to give me actual heat values.

Has anyone here worked with the FLIR before and know how to do this? Or can you try looking at the code, and telling me what I could change to get actual heat values.

\$\endgroup\$
  • 2
    \$\begingroup\$ This is not the intended use for thermal vision camera. To get temperatures remotely you need a dedicated device providing it. Cameras are giving you a postprocessed image which is enhanced especially for your eye. \$\endgroup\$ – Eugene Sh. Aug 2 '16 at 19:39
  • \$\begingroup\$ You need some way of correlating the pixel values with actual temperatures. I'd start by using an IR sensor (bolometer) pointed in the same direction to give you an average temperature, which you can assign to the average pixel value and extrapolate the other values from there. With calibration and care you may get enough accuracy for your purpose. \$\endgroup\$ – Brian Drummond Aug 2 '16 at 19:55
  • 1
    \$\begingroup\$ Which FLIR camera are you referring to? There's more than 1 on the market... \$\endgroup\$ – CHendrix Aug 2 '16 at 20:08
  • \$\begingroup\$ The camera's often have a Lock Range function and a hottest pixel reading... it depends on the model of camera I guess \$\endgroup\$ – Spoon Aug 2 '16 at 20:22
  • 2
    \$\begingroup\$ @BrianDrummond I can just tell as one who worked in a company (not FLIR, though), developing thermal vision cameras, that there were some crazy non-linear homebrew enhancement algorithms. They could be turned off though... \$\endgroup\$ – Eugene Sh. Aug 2 '16 at 21:27
2
\$\begingroup\$

The code you linked to is at least partially to blame. It searches through the received values, and finds the maximum and minimum values. It then writes the range (max-min) in the pgm file for scaling, and subtracts the minimum from all values.

This is needed to make the image viewable within the normal range of values for a grey scale image.

You can get the original values from the lepton_image array. Those have not been scaled in the code, so should be more directly related to the temperature. The data sheet says that the AGC is off by default, so you can expect the values you receive to be proportional to the temperature (so long as your code doesn't activate the AGC somewhere.)

On a quick scan through the datasheet, I don't see how to convert from the raw valued to temperature. You should be getting numbers between -8192 and 8192 (signed 14bit) If Radiometry is off, then 0 (zero) should be the same temperature as the sensor itself. You can ask the chip for its temperature, and calculate from there - if you can figure out the scale.

Assuming that the 14bit range covers the entire 0 to 400 degrees Kelvin that the Lepton is rated for, you could turn Radiometry on, and scale such that -8192 is zero Kelvin and 8192 is 400 Kelvin and see if that matches your expected temperatures - it ought to.


Further info: AGC stands for "Automatic Gain Control." In this case, it is used to reduce the 14Bit digitized values (-8192 to 8192) to an 8Bit value (0 to 255.)

You will need the Lepton Software Interface Description Document to see how to turn the AGC on (or off.) But, according to the datasheet for the Lepton, the AGC is off by default. All you need to do is to evaluate the numbers in the lepton_array in the code you listed, and look for numbers above some threshold. You'll have to experiment to see what threshold is needed. You may also find that the threshold will have to change depending on the environment temperature - you can get that from the Lepton using the "SYS FPA Temperature Kelvin" command (page 40 of the Interface Description Document.)


This link seems to imply to me that getting direct temperatures out of the Lepton isn't going to be easy - it appears you only get to do that if you pay enough and sign an NDA.

http://www.flir.com/cvs/cores/knowledgebase/index.cfm?view=67336

That said, you don't really need the true temperature. All you need is to turn the AGC off, and don't muddle things in your own code. Then you can look for temperatures at some threshold above the sensor temperature.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the feedback. I actually don't the temperature I just need to be able to tell when someone is in the image or not. That's why I wanted to disable the scaling. I've seen the part of code that deals with scaling and I'll try to remove it. However, can you tell me what AGC stands for and how I can control it? I've never worked with hardware before so forgive me for my ignorance. \$\endgroup\$ – Isabel Alphonse Aug 3 '16 at 15:17
  • \$\begingroup\$ @IsabelAlphonse: I've added to my answer. See if that helps. \$\endgroup\$ – JRE Aug 3 '16 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.