LJMUAstroecology / flirpy

Python library to interact with FLIR camera cores
Other
184 stars 54 forks source link

PureThermal 2 - FLIR Lepton Temperature Measurement #8

Closed Varat7v2 closed 4 years ago

Varat7v2 commented 4 years ago

Hi @jveitchmichaelis, I am using PureThermal 2 - FLIR Lepton camera for thermal imaging. But when I capture the image, lot of meta-data are missing. How can I capture image or use my camera to make it compatible with exiftool? When I run exiftool its just showing the following details:

ExifTool Version Number : 10.80 File Name : my_photo-1.jpg Directory : . File Size : 5.7 kB File Modification Date/Time : 2020:05:04 20:28:10+05:30 File Access Date/Time : 2020:05:04 20:28:47+05:30 File Inode Change Date/Time : 2020:05:04 20:28:10+05:30 File Permissions : rw-rw-r-- File Type : JPEG File Type Extension : jpg MIME Type : image/jpeg JFIF Version : 1.02 Resolution Unit : inches X Resolution : 120 Y Resolution : 120 Image Width : 160 Image Height : 120 Encoding Process : Baseline DCT, Huffman coding Bits Per Sample : 8 Color Components : 3 Y Cb Cr Sub Sampling : YCbCr4:2:2 (2 1) Image Size : 160x120 Megapixels : 0.019

Also, how can I use flirpy with my camera to measure the temperature in degree Celsius?

Thank you.

jveitchmichaelis commented 4 years ago

Hi, have you tried the examples here?

https://github.com/LJMUAstroecology/flirpy/blob/master/README.md#grab-images

The output from flirpy will be a 16 bit Numpy array that corresponds to temperature in Kelvin x 100 (ie 0.01K per count).

The image metadata you've posted is 8 bit and it's a jpeg (or is it a radiometric jpeg?). So you're not capturing a raw image. If you're having trouble with exiftool/PT2, you should try their support forums directly. You may need to enable telemetry.

By the way, I saw your other issue. You don't need all the metadata from exiftool if you just want to extract an ROI from your Lepton. The radiometric Leptons return images that are already temperature converted. I recommend reading the datasheet, particularly the bit about "tlinear" mode, but that should be the default setting.

https://www.flir.com/globalassets/imported-assets/document/flir-lepton-engineering-datasheet.pdf

Varat7v2 commented 4 years ago

@jveitchmichaelis yeah I tried the example. Its giving a numpy array of the image but when I divided it by 100 I am getting values in the range 70-90 in every pixels. (I will try it again with whatever you have mentioned above, I will correct my miscalculations, Thank you!).

And regarding telemetry, how can I enable them? I even tried https://github.com/groupgets/purethermal1-uvc-capture/tree/master/python/uvc-radiometry.py, I was confused with the output array as it does not seems to be in pixel-wise temperature.

Thank you for sharing the references, I will go through them.

jveitchmichaelis commented 4 years ago

Is it a 16 bit array? Also, what platform are you using?

For example 30000 counts is (300 - 373.15) = 26.85 C.

Not sure how you enable telemetry, the pure thermal cameras I've used have always had it enabled. You don't need telemetry for radiometric output though, it's mostly just for monitoring.

Varat7v2 commented 4 years ago

I am running on Python3 in terminal shell. In my case at room temperature, the flirpy is giving me counts in the range 8000-9000 only. When I divided by 100 and subtracted by 273.15, all the values are coming in negative. Am I doing anything wrong?

jveitchmichaelis commented 4 years ago

Sorry, I meant what OS. Are you using a Mac?

Not sure, do you get sensible results if you use the GroupGets gui?

Varat7v2 commented 4 years ago

No I am using Ubuntu 18.04. I haven't tried with groupgets gui. However, I had run it on uvc-radiometry.py, results doesn't seems to be sensible either. If needed I will try with that one also, its GetThermal right?.

jveitchmichaelis commented 4 years ago

Yeah worth giving that a go, if that still doesn't work, there's probably a way to flash the firmware on the PT2 to the default.

It's possible you have radiometry enabled, but not tlinear.

Varat7v2 commented 4 years ago

Hi @jveitchmichaelis I tried GetThermal, but the temperature bar is not visible, so I am confused if its showing correct temperature profile.

Flirpy seems to be giving correct values but I am not getting values in the range you have mentioned above (i.e. 30000 counts). I am getting values in the range (7000 - 9000) and when I tested on different temperature object, those values are changing like:

According to its datasheet (Lepton 3.0 - the one I am using), its output is 14 bit. So, that might be the reason of above (7000-9000) value ranges. How can I use this reading for temperature conversion?

Thank you.

jveitchmichaelis commented 4 years ago

You know I may have seen this before. Try re-seating the camera on the PT2 board, it's possible you've just got a loose connection. Alternatively speak to GroupGets and ask how you can check if TLinear mode is enabled.

I suggest following this guide from FLIR which has the necessary precautions about handling the detector, it's quite sensitive: https://lepton.flir.com/wp-content/uploads/2015/06/PureThermal-2-Basic-Lepton-Features.pdf

Slides 9-10

As you suggest, the numbers are actually in a reasonable range, but it seems like you may be getting the raw counts rather than the radiometric image.

Are you using a Lepton 3.5?

Varat7v2 commented 4 years ago

I am using Lepton 3.0. In the datasheet, it is mentioned that it does not have thermal radiometry configuration.

jveitchmichaelis commented 4 years ago

Oh ok, then you can't get temperature measurements with your camera. That's what radiometry is for. Sorry about that.

You can calibrate the camera yourself in principle, but you would need a blackbody calibration target at least, and ideally also a climate chamber.

https://www.researchgate.net/publication/316870565_Radiometric_calibration_of_an_ultra-compact_microbolometer_thermal_imaging_module

Varat7v2 commented 4 years ago

Okay I will do the same. Thank you for sharing the paper, I could not find any before.

Thank you @jveitchmichaelis for your help.

jveitchmichaelis commented 4 years ago

Having done this with other cameras, I'll be honest - the price of a Lepton 3.5 is less than the cost of the calibration equipment and the time you'll spend doing it. A good blackbody target is at least $500.

You can probably do a cheap calibration though - take a mug, fill it with hot water, and paint it black with e.g. stove/furnace paint. Monitor the temperature with a thermocouple and simultaneously image the mug as well as the temperature of the Lepton (from telemetry). Then you can plot object temperature (e.g. the water) as a function of camera temperature and counts in the image.

Basically as long as you can find 2-3 objects with known temperature that are good blackbody approximations (e.g. very high emissivity) you can do a rough conversion from your counts. You will also need to take into account the camera temperature (usually) unless this is already corrected for by the Lepton 3.

Best of luck!