Read time stamp from FLIR .SEQ file

Started by Shwetang, September 19, 2013, 04:53:37 AM

Previous topic - Next topic

Shwetang

Dear Friends,

                    I was following a thread on FLIR file formats being decoded by EXIFTool. People have done a good work in decoding many information from various FLIR file formats. I am working with FLIR SC4000 camera ( 320 X 256 pixel array ) which saves the data in .SEQ file which is a "Proprietary" format of FLIR. I use IDL ( Interactive Data Language ) for post processing my thermography data. I can convert .SEQ files acquired by SC4000 to .FPF files using ThermaCam Researcher but the size of my data is very big hence a conversion of all the .SEQ files to .FPF is not possible since it requires lot of storage space and is very time consuming. I am able to read .FPF files directly in IDL since its file format is "OPEN". But I don't want to waste my time in such an intermediate conversion i.e. from .SEQ to .FPF. I want to directly read .SEQ file in IDL. I am able to read the image data ( Digital Levels ) in IDL but I am not able to catch hold of the time stamps. The time stamp is necessary since there are some lost frames. I tried to look for the time stamp using the information provided in one of the threads on this forum, but could not retrieve this information in IDL from a .SEQ file. I tried to look at pointer location 0X0384 i.e. pointer location 900. But could not read the time stamp information. Can any one of you help me to locate the exact pointer location where the time stamp is stored and the data type of time stamp.

Thank you in advance.

tomas123

#1
exiftool can read the timestamp of the first frame from your sequence file

>exiftool -date* -filecrea* D:\tmp\Flir\01\SEQ1000.seq
Date/Time Original              : 2013:06:24 17:40:59.253+00:00
File Creation Date/Time         : 2013:06:24 17:43:26+02:00


Date/Time Original -> timestamp of first .fff frame

you can split a single frame (.fff) from your sequence and read the time stamp with exiftool

Here is a simple code for splitting the .seq into single .fff frames. It's a dirty hack. A short length of magic bytes can pattern inside the image binary. (6 Bytes works fine)

change the magic bytes (use a hex editor and see the first bytes your camera file)
see my comments

using:
Linux: ./split.pl 320x1.seq
portabe Windows: perl-5.18.0.1-32bit-portable\perl\bin\perl.exe -f split.pl SEQ1000.seq

#!/usr/bin/perl
undef $/;
$_ = <>;
$n = 100;
# FLIR camera E40         
$pat="\x46\x46\x46\x00\x00\x00";
# Flir Tools (comment out)
#$pat = "\x46\x46\x46\x00\x43\x41\x50";
for $content (split(/(?=$pat)/)) {
        open(OUT, ">seq" . ++$n . ".fff");
        binmode OUT;
        print OUT $content;
        close(OUT);
}

for experts:  Windows needs "binmode OUT"  to avoid conversation from 0A -> 0D 0A

change the code for your needs (i.e. count the frames and read timestamp of every thousend frame with a pipe to exiftool)

with sample above I get:
> exiftool -date* D:\tmp\Flir\01\seq167.fff
Date/Time Original              : 2013:06:24 17:41:02.138+00:00

the 67. frames comes 3 seconds later... (my counter begins with $n = 100)

PS: Can you post a link to a short(!!) .seq file from your FLIR SC4000?

tomas123

Quote from: Shwetang on September 19, 2013, 04:53:37 AM
Can any one of you help me to locate the exact pointer location where the time stamp is stored and the data type of time stamp.

take a single fff Frame -> Tag 0x384   => {    Name => 'DateTimeOriginal',

see exiftool source code
\lib\Image\ExifTool\FLIR.pm

and doc
http://www.exiftool.org/TagNames/FLIR.html

Phil Harvey

Yes, a sample SEQ would be useful.  Also, if you could post a sample JPG image -- I am trying to accumulate a set of FLIR JPG samples, but I don't have one from this model.

Thanks.

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

Shwetang

Dear Phil and Tomas,


     Thank you for your help. I am uploading 2 images from seq files acquired by SC4000 and SC655. I am not able to convert it to .JPG since there is no such option to do so. Thermacam researcher can save .seq as BMP, AVI, FPF, Matlab and SAF formats only. May be you must be having a better way of doing such a conversion at your end. Actually I noticed that .SEQ files generated by both the FLIR models have different file structure. I am not able to open the .seq generated by SC655 by a code written for reading .seq generated by SC4000. May be headers are different. But you people can judge better. I am still a beginner. Please find the .seq files attached. The file names signifies the model numbers.

  Thank you once again.

-Shwetang

Phil Harvey

Thanks for the SEQ samples.  I'll download them on Monday.  I was only interested in the JPG if it was generated in-camera.

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

tomas123

#6
Your FLIR software generates two different file formats.

here are the magic bytes
$ hexdump -n16 -C SC655.seq
00000000  46 46 46 00 43 41 4d 43  54 52 4c 00 00 00 00 00  |FFF.CAMCTRL.....|

$ hexdump -n16 -C SC4000.seq
00000000  41 46 46 00 43 41 4d 43  54 52 4c 00 00 00 00 00  |AFF.CAMCTRL.....|


exiftool can read the Flir FFF File Format from your SC655
see this FLIR document
http://www.workswell.cz/manuals/flir/hardware/A3xx_and_A6xx_models/Streaming_format_ThermoVision.pdf

$ exiftool SC655.seq
...snip
Relative Humidity               : 50.0 %
Planck R1                       : 16002.714
Planck B                        : 1417.8
Planck F                        : 1
Camera Temperature Range Max    : 150.0 C
Camera Temperature Range Min    : -40.0 C
Camera Model                    : FLIR SC655
Camera Part Number              : 55001-0301
Camera Serial Number            : 55001246
Camera Software                 : 16.0.0
Lens Model                      : FOL41
Lens Part Number                : T197524
Lens Serial Number              : 56701725
Field Of View                   : 15.0 deg
Filter Model                    :
Filter Part Number              :
Filter Serial Number            :
Planck O                        : -3844
Planck R2                       : 0.012546406
Raw Value Median                : 14929
Raw Value Range                 : 1766
Date/Time Original              : 2013:09:20 17:29:36.798+09:00
Focus Step Count                : 45233
Focus Distance                  : 0.6 m
Raw Thermal Image Width         : 640
Raw Thermal Image Height        : 483
Raw Thermal Image Type          : TIFF
Raw Thermal Image               : (Binary data 618444 bytes, use -b option to extract)
Peak Spectral Sensitivity       : 10.1 um


Date/Time Original  shows the time stamp of first frame
you can split all frames with perl code from my first post and pattern "FFF.CAMCTRL"
#!/usr/bin/perl
undef $/;
$_ = <>;
$n = 100;
# FLIR Thermacam researcher FFF.CAMCTRL       
$pat="\x46\x46\x46\x00\x43\x41\x4d\x43\x54\x52\x4c";
for $content (split(/(?=$pat)/)) {
        open(OUT, ">seq" . ++$n . ".fff");
        binmode OUT;
        print OUT $content;
        close(OUT);
}


there are two frames in SC655.seq
get the timestamps:
$ ./split.pl SC655.seq
$ exiftool -date* seq*
======== seq101.fff
Date/Time Original              : 2013:09:20 17:29:36.798+09:00
======== seq102.fff
Date/Time Original              : 2013:09:20 17:29:36.818+09:00
    2 image files read

change the sample code for your requirements, you must don't write all frames to disc, count the frames and pipe to exiftool




we haven't yet decoded the FLIR Format AFF (SC6000 docs: Cumulus Flir iPort Ethernet ?)
your sequence SC4000.seq is unreadable for exiftool and FLIR Tools (!)
try change the output format from your FLIR  Software to FFF sequence or try another FLIR Software



@Phil
this cams can't write a single image (video cams for streaming to a software)

tomas123

only for documentation

the FLIR SC655 has a 640x480 Sensor

die FFF Tags show 3 lines more (483 lines)
$ exiftool -v4 SC655.seq | egrep -A2 "RawThermalImageW|RawThermalImageH"
  | RawThermalImageWidth = 640
  | - Tag 0x0001 (2 bytes, int16u[1]):
  |     053e: 80 02                                           [..]
--
  | RawThermalImageHeight = 483
  | - Tag 0x0002 (2 bytes, int16u[1]):
  |     0540: e3 01     


we can decode the correct image with this command
$ exiftool -b -RawThermalImage SC655.seq > SC655.tif
and get 3 extra lines with binary junk

I think it's a FLIR software error and not worth to debug

Shwetang

Dear Tomas & Phil,

    Thank you very much for your help. I am now able to read the data as well as time stamps from the .SEQ files from SC655  ;D. But still the .SEQ from SC4000 is a mystery  :(, specially the time stamps. I am able to read the raw data from SC4000 .SEQ files.

I think I have not made things very clear in my previous mail.

SC4000 Acquires data using ThermaCam Researcher pro 2.9 which generates .SEQ files as output sequence, from which raw data can be read but not the time stamp

SC655 acquires data using FLIR ResearchIR which generates .FCF files as output sequence

SC655, when controlled by LABVIEW can give the output as .SEQ sequence file which can then be read for raw data and time stamp, as successfully attempted by you.

I am uploading a test .FCF file from SC655. Can you please try to read it. From my experience, it has a header that is of different size for different files and hence it is not possible to decode it. Also it stores some session information at the end of each file. But it seems that it still follows FFF file format. Can you please confirm. I would be interested in decoding this format from FLIR also.

I will be thankful if you help me to decode the time stamp part from SC4000 .SEQ file.

Thank you in advance.....

tomas123

#9
your filename extension is unimportent

use a hexeditor and lock at your magic bytes ( http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files )

exiftool can only read the format "FFF" because the is a support document for this format
see page 3 in link above: http://www.workswell.cz/manuals/flir/hardware/A3xx_and_A6xx_models/Streaming_format_ThermoVision.pdf

if you have another file format, you need a flir support document for file format description or some motivations for reverse engineering ...



only for information:
exiftool can also decode the old Flir FPF Header, because there is a public header file avaible
http://code.google.com/p/dvelib/source/browse/trunk/flirPublicFormat/fpfConverter/Fpfimg.h?r=3

Phil Harvey

I took a look at the SC4000 SEQ file you posted and couldn't find an obvious date/time stamp.  It may require significant effort to decode this format.

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