gtatters / Thermimage

R Package for working with radiometric thermal image files and data
GNU General Public License v3.0
162 stars 40 forks source link

Can't open FLIR ONE jpg #19

Closed IvanDesuo closed 2 years ago

IvanDesuo commented 2 years ago

Describe the bug I can't open the jpg taken with a FLIRONE coupled in a Caterpillar Mobile (CAT6), R retrieves an empty list. It works great with a FLIR T530.

library(Thermimage)

imagefile<-paste0(system.file("extdata/flirone.jpg", package="Thermimage")) imagefile

library(Thermimage) imagefile<-paste0(system.file("extdata/flirone.jpg", package="Thermimage")) imagefile [1] ""

Expected behavior the image path should appear in console indicating the image was properly stored and it is ready to be processed.

Screenshots issueTherimage

Desktop (please complete the following information):

Additional context Adding the image, in case you want to test. flirone

Thanks in advance, Ivan

gtatters commented 2 years ago

I'm not sure what the problem is? It opens fine in ThermimageJ (my other github repository that is more GUI based).

test

I'll copy some of the command line code used to get it to work from the command line.

------ Running ConvertImportFLIRJPG function ------ Loading: /Desktop/test.jpg Extracting calibration and image settings

------ Running flirvalues function ------ Command line code being executed (copy/paste into terminal window to test): /usr/local/bin/exiftool '-Planck*' '-*AtmosphericTrans*' '-*Emissivity' '-*Distance' '-*Temperature' '-*Transmission' '-*Humidity' '-*Height' '-*Width' '-*Original' '-*Date' /Desktop/test.jpg Temporary file saved to: /Desktop/temp/test.png

------ Running ConvertImportFLIRJPG function ------ Loading: /Desktop/test.jpg Extracting calibration and image settings

------ Running flirvalues function ------ Command line code being executed (copy/paste into terminal window to test): /usr/local/bin/exiftool '-Planck*' '-*AtmosphericTrans*' '-*Emissivity' '-*Distance' '-*Temperature' '-*Transmission' '-*Humidity' '-*Height' '-*Width' '-*Original' '-*Date' /Desktop/test.jpg Temporary file saved to: /Desktop/temp/test.png FLIR JPG loaded

gtatters commented 2 years ago

what is this supposed to do?

imagefile<-paste0(system.file("extdata/flirone.jpg", package="Thermimage"))
imagefile

why not just setwd and use the readFLIRjpg() function?

setwd("~/Desktop")
 img<-readflirJPG("test.jpg", exiftoolpath="installed")
IvanDesuo commented 2 years ago

Thank you for the response! Yeah, it was probably related to setting up the directory correctly. Appreciate the heads up, I'm just getting used with R and thermal images.

I managed to load and extract the raw data (all the steps provided in the documentation), however, for some reason the temperature values are out of the place in this particular case, maybe related to some parameter specification of this model?

I'm using the code that is provided in the documentation, and I'm getting this:

test_converted

gtatters commented 2 years ago

your reflected temperature is incorrect (298C!!!) and you have a window transmission set to 0.82 (did you have a thermal window in front, not likely). you need to set proper values using the raw2temp function. most of the values look nonsense. don't trust the values in the file since they are up to the user to set when they capture the image.

 exiftool test.jpg
ExifTool Version Number         : 12.26
File Name                       : test.jpg
Directory                       : .
File Size                       : 961 KiB
File Modification Date/Time     : 2021:09:08 17:52:29-04:00
File Access Date/Time           : 2021:09:08 17:52:56-04:00
File Inode Change Date/Time     : 2021:09:08 17:54:50-04:00
File Permissions                : -rw-r--r--
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Little-endian (Intel, II)
Make                            : FLIR Systems AB
Camera Model Name               : CAT® S61
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : Common_dll v1.0.0b0
Modify Date                     : 2021:07:07 20:32:16
Y Cb Cr Positioning             : Centered
Exif Version                    : 0220
Create Date                     : 2021:07:07 20:32:16
Components Configuration        : -, Cr, Cb, Y
Subject Distance                : 1 m
Image Temperature Max           : 213
Image Temperature Min           : 213
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 1080
Exif Image Height               : 1440
Digital Zoom Ratio              : 1
Image Unique ID                 : 00000000000000000000000000000000
GPS Version ID                  : 2.2.0.0
GPS Altitude Ref                : Above Sea Level
GPS Img Direction Ref           : Magnetic North
GPS Img Direction               : 0
Compression                     : JPEG (old-style)
Thumbnail Offset                : 2040
Thumbnail Length                : 1592
Creator Software                : 
Embedded Image Width            : 1080
Embedded Image Height           : 1440
Embedded Image Type             : JPG
Embedded Image                  : (Binary data 72950 bytes, use -b option to extract)
Emissivity                      : 1.00
Object Distance                 : 1.00 m
Reflected Apparent Temperature  : 298.1 C
Atmospheric Temperature         : 20.0 C
IR Window Temperature           : 16.5 C
IR Window Transmission          : 0.82
Relative Humidity               : 50.0 %
Planck R1                       : 18216.199
Planck B                        : 1435
Planck F                        : 1
Atmospheric Trans Alpha 1       : 0.006569
Atmospheric Trans Alpha 2       : 0.012620
Atmospheric Trans Beta 1        : -0.002276
Atmospheric Trans Beta 2        : -0.006677
Atmospheric Trans X             : 1.900000
Camera Temperature Range Max    : 150.0 C
Camera Temperature Range Min    : -20.0 C
Camera Temperature Max Clip     : 150.0 C
Camera Temperature Min Clip     : -60.0 C
Camera Temperature Max Warn     : 120.0 C
Camera Temperature Min Warn     : -40.0 C
Camera Temperature Max Saturated: 150.0 C
Camera Temperature Min Saturated: -60.0 C
Camera Model                    : CAT® S61
Camera Part Number              : 
Camera Serial Number            : 
Camera Software                 : 
Lens Model                      : 
Lens Part Number                : 
Lens Serial Number              : No Lens
Field Of View                   : 0.0 deg
Filter Model                    : 
Filter Part Number              : 
Filter Serial Number            : 
Planck O                        : -1683
Planck R2                       : 0.0125
Raw Value Range Min             : 4
Raw Value Range Max             : 65535
Raw Value Median                : 11760
Raw Value Range                 : 5856
Date/Time Original              : 2021:07:07 23:32:16.000+00:00
Focus Step Count                : 0
Focus Distance                  : 2.0 m
Frame Rate                      : 0
Palette Colors                  : 240
Above Color                     : 126 128 128
Below Color                     : 67 216 98
Overflow Color                  : 235 128 128
Underflow Color                 : 16 128 128
Isotherm 1 Color                : 137 40 58
Isotherm 2 Color                : 210 146 16
Palette Method                  : 0
Palette Stretch                 : 0
Palette Name                    : lava
Palette                         : (Binary data 720 bytes, use -b option to extract)
Meas 1 Type                     : Area
Meas 1 Params                   : 0 0 480 640
Meas 1 Label                    : 
Raw Thermal Image Width         : 480
Raw Thermal Image Height        : 640
Raw Thermal Image Type          : PNG
Raw Thermal Image               : (Binary data 131726 bytes, use -b option to extract)
Real 2 IR                       : 1.49814999103546
Offset X                        : +31
Offset Y                        : -3
PiP X1                          : 0
PiP X2                          : 479
PiP Y1                          : 0
PiP Y2                          : 639
GPS Valid                       : Yes
GPS Latitude Ref                : Unknown (So)
GPS Longitude Ref               : Unknown (We)
GPS Map Datum                   : WGS84
Image Width                     : 1080
Image Height                    : 1440
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Image Size                      : 1080x1440
Megapixels                      : 1.6
Thumbnail Image                 : (Binary data 1592 bytes, use -b option to extract)
Peak Spectral Sensitivity       : 10.0 um
GPS Latitude                    : 22 deg 24' 20.04" S
GPS Longitude                   : 46 deg 58' 6.30" W
GPS Position                    : 22 deg 24' 20.04" S, 46 deg 58' 6.30" W
IvanDesuo commented 2 years ago

Wow! I didn't even noticed that monstrosity! No wonder the values are all over the place. This is a really important information. Again, thank you!

gtatters commented 2 years ago

Yep GIGO. ;-)

So, examine all the settings in the raw2temp function and set them to what you estimate is the real value. Pull the planck calibration constants from your file (those are presumably accurate for your camera, although with a flir one, not likely that accurate). Just set window Transmission to 1, and then it doesn't matter what temperature the window is. A window of 1 is the same as not having any window in front of the cam.

IvanDesuo commented 2 years ago

These are really valuable tips!

I managed to correct that image using the standard values for Reflected Apparent Temperature, although not optimum, once I need to estimate them properly, it gave me a better picture of what is happening there. It is quite staggering the discrepancy tho, once those values pretty much came with the mobile sensor, as factory settings for CAT6.

Anyways, thank you so much Glenn for tips and helping me out with the issues! Here is the image with the updated values. corrected

gtatters commented 2 years ago

the 298C looks like an error in units, since if Kelvin, that would be 25C which sounds appropriate. these algorithms will never work perfectly - lots of reason for additional errors beyond the instrument / sensor calibration itself. But expect your warmest skin temps to be ~35 to 36C near your eyes. it's the wild west with these consumer flir products, I can't attest to what sort of accuracy you can expect. If you just turn it on and don't let it self "calibrate", you can easily get temperature measurements that are 2C too low or 2C too high. After 5 min of run time, the camera stabilises. At least with my old flir one (now no longer works with their software!)