News:

If this site goes down it is because of the crappy DreamHost web hosting: They will disable your "unlimited traffic" web server if a single bot hammers the site with a moderate load.  If necessary, an alternate ExifTool forum page is available at https://sourceforge.net/p/exiftool/discussion/

Main Menu

enhancement: extract binary data from FLIR radiometric jpg

Started by tomas123, March 20, 2013, 12:49:46 PM

Previous topic - Next topic

jmichael

Quote from: tomas123 on April 18, 2013, 05:23:46 PM

for testing I wrote a short shell script raw2tmp.sh

#!/bin/bash
echo "usage $0 flir.jpg PixelArea"
echo "see imagemagick crop for PixelArea, sample 1x1+0+0"

# get Flir values
Flir=$(exiftool -Flir:all "$1")
Type=$(echo "$Flir" | grep "Raw Thermal Image Type" | cut -d: -f2)
if [ "$Type" != " TIFF" ]
    then
        echo "only for RawThermalImage=TIFF"
        exit 1
fi

R1=$(echo "$Flir" | grep "Planck R1" | cut -d: -f2)
R2=$(echo "$Flir" | grep "Planck R2" | cut -d: -f2)
B=$(echo "$Flir" | grep "Planck B" | cut -d: -f2)
O=$(echo "$Flir" | grep "Planck O" | cut -d: -f2)
F=$(echo "$Flir" | grep "Planck F" | cut -d: -f2)

# get RAW Sensor value
RAW=$(exiftool -b -RawThermalImage "$1" 2>/dev/zero | convert - -crop $2 -colorspace gray -format "%[mean]" info: )

# calc spectral range of used Flir camera
echo -n "spectral range [micrometer]: "
echo "scale=2;14387.6515/$B"| bc -l

# calc Temperature of PixelArea with Emissivity = 1.0
degree=$(echo "scale = 8;$B/l($R1/($R2*($RAW+$O))+$F)-273.15" | bc -l )
echo "$RAW RAW => $degree degree Celsius at Emissivity=1.0"

# calc Temperature of PixelArea with saved Emissivity
Emissivity=$(echo "$Flir" | grep "Emissivity" | cut -d: -f2)
Refl_Temp=$(echo "$Flir" | grep "Reflected Apparent Temperature" | sed 's/[^0-9.-]*//g')

RAWrefl=$(echo "scale = 8;$R1/($R2*(e($B/($Refl_Temp+273.15))-$F))-$O" | bc -l )
RAWobj=$(echo "scale = 8;($RAW-(1-$Emissivity)*$RAWrefl)/$Emissivity" | bc -l )
echo $Emissivity $Refl_Temp $RAW $RAWrefl $RAWobj
degree=$(echo "scale = 8;$B/l($R1/($R2*($RAWobj+$O))+$F)-273.15" | bc -l )
echo "$RAWobj RAW => $degree °C at Emissivity=$Emissivity and $Refl_Temp °C reflected temp."


usage ./raw2tmp.sh flir.jpg PixelArea
see imagemagick crop for PixelArea, sample 1x1+0+0

here a sample with a area of 1x1 Pixel and the first pixel on top right (x,y => 0,0)
$ ./raw2tmp.sh IR_1546.jpg  1x1+0+0
spectral range [micrometer]: 10.30
12626 RAW => -9.51770751 degree Celsius at Emissivity=1.0
12373.04334215 RAW => -11.39208744 °C at Emissivity= 0.95 and 20.0 °C reflected temp.


With this values I also calculated the spectral range of camera
it's simple
B = h*c/(k*λ) goes to
λ[μm]=14387.6515/Planck_B
There are two sort of cams on market SW and LW cameras.
see Short Wave and Long Wave
http://en.wikipedia.org/wiki/Infrared

sample of spectral range with Flir E40:
calculated from Exif: 10.30 μm (Peak)
datasheet: 7.5–13 μm (Range)




script works only for Tiff Images
if you use "Raw Thermal Image Type"=PNG you must change upper/lower byte
$ convert cat1.png gray:- | convert -depth 16 -endian msb -size 120x120 gray:- -auto-level cat2.png


PH Edit: Fixed typo in a formula


Hi there,
I'm attempting to extract the temperature data from a jpeg generated by an FLIR E60. I tried using the shell script raw2tmp.sh that Tomas123 wrote (quoted above) and I'm having some trouble.
I have the script saved as a .sh file and I'm calling it in the cygwin64 terminal with the command, "bash raw2tmp.sh FLIR1248.jpg  1x1+0+0". The script seems to run but I got this as an output:

raw2tmp.sh: line 1: $'\r': command not found
usage raw2tmp.sh flir.jpg PixelArea
see imagemagick crop for PixelArea, sample 1x1+0+0
raw2tmp.sh: line 5: $'\r': command not found
raw2tmp.sh: line 41: syntax error: unexpected end of file

Lines 1 and 5 were empty lines so I removed them and resaved the file. It got rid of the 'command not found' issue but I'm now getting this;

$ bash raw2tmp.sh FLIR1248.jpg  1x1+0+0
usage raw2tmp.sh flir.jpg PixelArea
see imagemagick crop for PixelArea, sample 1x1+0+0
raw2tmp.sh: line 33: syntax error: unexpected end of file

Meaning that cygwin doesn't seem to like how the file ends (line 33 is the first blank line at the end of the script). I've not worked much with shell scripts before so I'm a little out of my element. Any suggestions?
Thanks in advance!!!

tomas123


jmichael


jjmmss00

Hi All,

I have been searching for a way to extract the raw data from my new Flir e4, and tried the "Batch Flir Image Converter" (mentioned above) which so far  works really well.

My one concern is that that my Norton virus software reports a security risk based on reputation (i.e. there was no actual issue found, but they didn't trust the source). Has anyone found any sort of problem with this download?

Also, the output raw image is 150k (320*240*2 width*height*2 bytes per pixel). However, my input file is not large enough to contain this much raw data (only about 140k total (but varies) which also includes significant other stuff). Is the E4 a lower bits/pixel camera, or is the raw image somehow compressed, or is there another explanation? Flir claims 14 bits per pixel on their web page. I went through a file with a binary editor and found it pretty much consistent with the file discussed in the first post of this blog, except my file is just not big enough.

thanks jjmmss00

tomas123

see my links two posts above

there is a long thread for all things around the Flir E4
please ask there (I think, you have a hacked E4 and you know the thread)
www.eevblog.com/forum/testgear/flir-e4-thermal-imaging-camera-teardown

hint: see exiftool RawThermalImageType -> PNG (compression)

read my tutorial "exiftool and Imagemagick step-by-step"
http://www.eevblog.com/forum/testgear/flir-e4-thermal-imaging-camera-teardown/msg348398/#msg348398


jjmmss00

Thanks Thomas123,

Yes the camera is hacked, and I do know the blog you referenced.

Will also study the other links.

jjmmss00

Armen

Hello to all.
I am doing research on the energy balance of the earth. I started using FLIR A305sc to determine the temperature of the surface of plant at long range. Information that I found unto your conversation really helped me perform analysis and corrections. Thanck you much...
I have a question about Planck R canstant.
With ExiftoolGUI I get:

Planck R1                       : 16314.8828125
Planck B                        : 1423.59997558594
Planck F                        : 1
Planck O                        : -6199
Planck R2                       : 0.0109910489991307
Peack of spactral range 10.11 mkm

For have a proof, I calculated:
B = h*c/(k*λ)=(6.626068*10^-34*2.9979*10^8)/(1.38066*10^-23*10.11*10^-6) = 1423 (Planck B)
R=R1/R2=1.484*10^6, so...
R = 2*h*c^2/λ^5=(2* 6.626068*10^-34*(2.9979*10^8)^2)/(10.11*10^-6) = 1.423*10^3 ???? why not 1.484*10^6

And another question.
If spectral range is a constant (10.11 mkm) then Wien law of displacement (lambda=2898/T) is not provided in FLIR???

Thank you in advance for your reply and sorry for my english.

tomas123

this is not the right forum for this question  :)
- better ask here (there are the flir experts):
http://www.eevblog.com/forum/testgear/flir-e4-thermal-imaging-camera-teardown/

the flir part of exiftool is only the reverse engeneering of paramaters you find in flir documents
read this long thread (and see the attachments)

use this excel sheet for proofing the values
https://exiftool.org/forum/index.php/topic,4898.msg27546.html#msg27546

Armen

Thank you Tomas.
I have studied these documents. All calculated and corrected for several matrices and DEM model. Demanded an explanation from me about these constants. You talked about these constants a lot, so I thought that I am in the right forum.
Thanks for the tip.

klarakos

These numbers just give the location and the number of entries in what I call the record directory (the FLIR equivalent of the EXIF IFD).  You aren't guaranteed that the camera data comes immediately after this, but in practice it is likely that it does.  Instead, the offsets in the record directory should be used to determine the location of the camera data records.

Phil Harvey

...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

universeblue

Hello,

I am looking at the reply from tomas123 to convert Flir image to texts:

$ exiftool -b -RawThermalImage test1.jpg | convert - gray:- | convert -depth 16 -endian msb -size 60x60 gray:- raw.png

It is very useful. However, I only have the raw output from FLIR, saying a.seq file, inside which there are more than 1 images. It works for me to get the information from the first image in a.seq. Would there be a way to extract the information from any of the images in a.seq file? Thank you for your help.

Jay

tomas123

#147
Which Flir camera do you use with 60x60?

Quote from: universeblue on January 05, 2016, 06:21:23 PM
Would there be a way to extract the information from any of the images in a.seq file?

see here:
https://exiftool.org/forum/index.php/topic,5279.msg25567.html#msg25567
different magic bytes:
https://exiftool.org/forum/index.php/topic,5279.msg25593.html#msg25593

more informations about Flir formats you find in my link list:
http://www.eevblog.com/forum/testgear/flir-e4-thermal-imaging-camera-teardown/msg342072/#msg342072

http://www.eevblog.com/forum/testgear/flir-e4-thermal-imaging-camera-teardown/msg348398/#msg348398
Quoteor since IM 6.8.8 with switch png:swap-bytes:
convert -define png:swap-bytes=on t1.png t2.png

universeblue

Hi Thomas,

Thank you for your reply.
> Which Flir camera do you use with 60x60?

It is A655SC camera, which happens to be the same as you had in the link. It's not 60x60, but 640x480, which is fixed though.

I have:
----------------------------------
hexdump -n16 -C A655SC.seq
00000000  46 46 46 00 45 78 61 6d  69 6e 49 52 00 00 00 00  |FFF.ExaminIR....|
00000010
----------------------------------
Looks reasonable?

And the time stamp:
Date/Time Original              : 2015:11:04 00:26:31.196+01:00

However, using your code: FFF.CAMCTRL
in https://exiftool.org/forum/index.php/topic,5279.msg25593.html#msg25593
I get only 1 split file: seq101.fff, while A655SC.seq contains a lot.

Do you have any idea why?

Best, Jay

universeblue

Hi,

Ah, I realized a typo when modifying the magic bytes in the split.pl code. When it is fixed, I can split images with time stamp in the .seq file.

Thank you very much for the kind help here.

Best, Jay