exiftool.js icon indicating copy to clipboard operation
exiftool.js copied to clipboard

Read temperature data per pixel on Flir image?

Open MarkDaviesSensei opened this issue 5 years ago • 10 comments

Is it currently possible to read the temperature data per pixel using this codebase?

If not what would be required to make this work?

MarkDaviesSensei avatar May 16 '19 05:05 MarkDaviesSensei

I just tested a FLIR image, this library couldn’t get any exif, just an empty object. It would need to extract the binary thermal data (ExifTool’s is at ThermalImageRaw) and a few other metadatas but from there it’s trivial to get a temperature matrix

daz avatar May 16 '19 11:05 daz

Thanks @daz Any ideas high level on how to get the ThermalImageRaw data?

MarkDaviesSensei avatar May 16 '19 12:05 MarkDaviesSensei

I guess by reading through the exiftool code, and adding the bit markers to this library:

https://github.com/exiftool/exiftool/blob/master/lib/Image/ExifTool/FLIR.pm

This is a python tool I’ve been using, it uses exiftool to extract the TIFF/PNG raw data plus the planck values, min/max, emissivity and whatnot to spit out a temp matrix

https://github.com/Nervengift/read_thermal.py

I’d really love to see the FLIR metadata in this library though, I’ll play with it over the next week but I think it’s a bit beyond me.

daz avatar May 16 '19 12:05 daz

Thanks, I dont see ThermalImageRaw data but do see RawData

https://github.com/exiftool/exiftool/blob/9178cc5e64d8c1ca0215438a748d2221c27d0562/lib/Image/ExifTool/FLIR.pm#L110

Would this be the equivalent ?

MarkDaviesSensei avatar May 16 '19 12:05 MarkDaviesSensei

Correction, ExifTool calls it RawThermalImage

On decoding a FLIR JPG to get the metadata, more info here http://u88.n24.queensu.ca/exiftool/forum/index.php/topic,4898.0.html

daz avatar May 16 '19 13:05 daz

But if you’re just interested in, right now, getting a temperature matrix from a FLIR JPG, use the Python tool. It even exports CSV

daz avatar May 16 '19 13:05 daz

Thanks I've already got a solution to do it in C#, but it still requires sending data to the client, I need a pure JS solution so it can interact with the native image.

Thanks for the link about decoding the metadata, it looks pretty involved!

MarkDaviesSensei avatar May 16 '19 13:05 MarkDaviesSensei

From what I can tell, it's a matter of handling the header of "FLIR", something like this:

                    var headerAsString = oFile.getStringAt(iOffset + 4, 28);
                    if (headerAsString.indexOf("FLIR") != -1) {
                      // readEXIFData(oFile, ..., ...)
                    } else if (headerAsString.indexOf("http://ns.adobe.com/xap/1.0/") != -1) {

Implementing the ProcessFLIR function from here:

https://github.com/exiftool/exiftool/blob/ef6107edcf2c47e5190754540e15ea27c020233e/lib/Image/ExifTool/FLIR.pm#L1455

It's certainly doable, I don't have the programming chops unfortunately. I need a pure JS implementation as well

daz avatar May 17 '19 07:05 daz

Just adding that I also need this, I lack the perl understanding to read original code.

ericoporto avatar Oct 19 '20 15:10 ericoporto

I see ExifReader extracts binary thumbnails, maybe it can get the FLIR binary too?

https://github.com/mattiasw/ExifReader

daz avatar Oct 19 '20 16:10 daz