DJI H20T thermal radiometric jpeg file

Started by Jonathan McGillivray, July 09, 2020, 06:56:25 AM

Previous topic - Next topic

Chanc3

Hello all

Following this with great interest, as quite frankly, the DJI software is bad for what I need - batch image editing and a reporting feature! Do you think it would ever be possible to convert a DJI RJEPG to a FLIR format? Would make a great many peoples' lives a lot easier!

Happy to put up a small bounty for this!

sebastianbarria

Hi everyone.
I'm having the same problem about extracting thermal information from ZH20T camera.
I used to extract pixel by pixel information from older cameras using Thomas123 php script file, but now, with the new DJI Matrice 300, the JPEG files have the information "hidden".
I can't find a way to extract the planck constants in order to find the pixel by pixel temperature.
Does anyone have an idea on how to do that?

Just in case, I'm attaching a thermal JPEG file captured with the M300 RTK.
Thanks.

remi_beauvais

Hi everyone!

I've combined all your incredible findings in a script so you don't have to!
So, in the link below you can find a little tool that can look into a folder with the source JPG and create the tiff with temperature x10 in a subfolder.
It works on windows with a portable version of python.

How to use :
You have to edit the param.py file to link to your folder with the images you want to transform :
Here is the param.py file :
Image_folder = 'D:/Drone/temperature_JPG/'
Output_folder = "out_temperature/"

So, if you want to transform the images in C:\your\path\to\the\DJI\images\ you have to change the following line :
Image_folder = 'D:/Drone/temperature_JPG/'
to
Image_folder = 'C:/your/path/to/the/DJI/images/'


Please notice the type of separator used ("/" instead of "\") for the absolute path.

When the param.py file is configured, you just have to launch the "extract.bat" file and it will create the subfolder in the source image path and you will be granted with a little log in the cmd prompt.


Here to download the thingy : https://drive.google.com/file/d/1ckUXwcGND4UjqpLqqYQV8COt_LzdFzOA

If you find a better solution, I would be really happy to hear from you!

Rémi

JoseASanchez

Hi everyone,

I'm working in the same issue. Do you have any advance?.

@musteresel, could you provide the source code of the function ReadJpgFile?.

Thanks

Phil Harvey

I'm finally getting around to looking at this, and am adding the ability to read DJI FLIR APP3/APP4/APP5 data.  It does look to me as if the parameters are at constant offsets in APP4.  I am currently decoding the raw thermal and calibration data, as well as all parameters from APP4 listed in the debugging output.  Below is the output for all files posted so far in this thread.  (Note I am decoding "D1" as "AmbientTemperature", taking a cue from the correct_params_t structure which has c_int16 "ambient_temp" immediately following c_int16 "reflection".)

> exiftool tmp2 -dji:all -G
======== tmp2/DJI_20200715204138_0144_THRM.JPG
[APP3]          Thermal Data                    : (Binary data 655360 bytes, use -b option to extract)
[APP4]          K1                              : -101.738883972168
[APP4]          K2                              : 11.5029211044312
[APP4]          K3                              : 1047.04809570312
[APP4]          K4                              : 0
[APP4]          KF                              : 81.1580429077148
[APP4]          B1                              : 0
[APP4]          B2                              : -435.885711669922
[APP4]          Object Distance                 : 5
[APP4]          Relative Humidity               : 70
[APP4]          Emissivity                      : 100
[APP4]          Reflection                      : 230
[APP4]          Ambient Temperature             : 21
[APP4]          D2                              : -945
[APP4]          KJ                              : 100
[APP4]          DB                              : 0
[APP4]          KK                              : 191
[APP5]          Thermal Calibration             : (Binary data 32768 bytes, use -b option to extract)
======== tmp2/DJI_20200715204037_0108_THRM.JPG
[APP3]          Thermal Data                    : (Binary data 655360 bytes, use -b option to extract)
[APP4]          K1                              : -101.738883972168
[APP4]          K2                              : 11.5029211044312
[APP4]          K3                              : 1047.04809570312
[APP4]          K4                              : 0
[APP4]          KF                              : 81.1580429077148
[APP4]          B1                              : 0
[APP4]          B2                              : -435.885711669922
[APP4]          Object Distance                 : 5
[APP4]          Relative Humidity               : 70
[APP4]          Emissivity                      : 100
[APP4]          Reflection                      : 230
[APP4]          Ambient Temperature             : 21
[APP4]          D2                              : -945
[APP4]          KJ                              : 100
[APP4]          DB                              : 0
[APP4]          KK                              : 191
[APP5]          Thermal Calibration             : (Binary data 32768 bytes, use -b option to extract)
======== tmp2/DJI_20200513193136_0004_THRM.JPG
[APP3]          Thermal Data                    : (Binary data 655360 bytes, use -b option to extract)
[APP4]          K1                              : -98.3822555541992
[APP4]          K2                              : 25.5608234405518
[APP4]          K3                              : 655.765869140625
[APP4]          K4                              : 0
[APP4]          KF                              : 80.4379577636719
[APP4]          B1                              : 0
[APP4]          B2                              : -463.600006103516
[APP4]          Object Distance                 : 5
[APP4]          Relative Humidity               : 70
[APP4]          Emissivity                      : 100
[APP4]          Reflection                      : 230
[APP4]          Ambient Temperature             : 21
[APP4]          D2                              : -945
[APP4]          KJ                              : 100
[APP4]          DB                              : 0
[APP4]          KK                              : 204
[APP5]          Thermal Calibration             : (Binary data 32768 bytes, use -b option to extract)
======== tmp2/DJI_20200715203807_0023_THRM.JPG
[APP3]          Thermal Data                    : (Binary data 655360 bytes, use -b option to extract)
[APP4]          K1                              : -101.738883972168
[APP4]          K2                              : 11.5029211044312
[APP4]          K3                              : 1047.04809570312
[APP4]          K4                              : 0
[APP4]          KF                              : 81.1580429077148
[APP4]          B1                              : 0
[APP4]          B2                              : -435.885711669922
[APP4]          Object Distance                 : 5
[APP4]          Relative Humidity               : 70
[APP4]          Emissivity                      : 100
[APP4]          Reflection                      : 230
[APP4]          Ambient Temperature             : 21
[APP4]          D2                              : -945
[APP4]          KJ                              : 100
[APP4]          DB                              : 0
[APP4]          KK                              : 191
[APP5]          Thermal Calibration             : (Binary data 32768 bytes, use -b option to extract)
======== tmp2/DJI_20200916170844_0002_THRM.JPG
[APP3]          Thermal Data                    : (Binary data 655360 bytes, use -b option to extract)
[APP4]          K1                              : -116.967163085938
[APP4]          K2                              : 22.0576038360596
[APP4]          K3                              : 784.67138671875
[APP4]          K4                              : 0
[APP4]          KF                              : 80.1084518432617
[APP4]          B1                              : 0
[APP4]          B2                              : -605.314270019531
[APP4]          Object Distance                 : 5
[APP4]          Relative Humidity               : 70
[APP4]          Emissivity                      : 100
[APP4]          Reflection                      : 230
[APP4]          Ambient Temperature             : 21
[APP4]          D2                              : -945
[APP4]          KJ                              : 100
[APP4]          DB                              : 0
[APP4]          KK                              : 269
[APP5]          Thermal Calibration             : (Binary data 32768 bytes, use -b option to extract)
    1 directories scanned
    5 image files read


ExifTool 12.15 should contain this update.  Plus I'll add anything else useful that is discovered.  Up until now ExifTool hasn't ventured into doing temperature calculations, but I would consider adding this feature as well if someone can figure out how to do this based on the information extracted.

- 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 ($).

kiah09

Hello,

I am currently deciding on whether to purchase an XT2 or H20T. The main purpose of my purchase is to have accurate temperature data in a programmable file format (.txt, .csc, .tiff). I have little to no experience in determining each image's calibration values in the H20T, and it seems like a major issue in obtaining accurate temperature readings. In addition, it looks like the formula to derive the temperature values is more sound and backed up via testing and verification with the FLIR product (XT2) and NOT with the H20T. Is my understanding of the issues with the H20T data correct? Are these issues resolved? Because from my reading of this forum, it seems as though they are not quite resolved, but I wanted to make sure before making such a large purchase. Thank you!

daz

There is an official DJI Thermal SDK with an API and Linux and Windows lib binaries. This may help reverse engineering the thermal calibration.

https://www.dji.com/au/downloads/softwares/dji-thermal-sdk

Chanc3

I'm a little out of the loop now. Has anyone managed to get anywhere with this?

remi_beauvais

Quote from: remi_beauvais on October 13, 2020, 04:40:18 AM
Hi everyone!

I've combined all your incredible findings in a script so you don't have to!
So, in the link below you can find a little tool that can look into a folder with the source JPG and create the tiff with temperature x10 in a subfolder.
It works on windows with a portable version of python.

How to use :
You have to edit the param.py file to link to your folder with the images you want to transform :
Here is the param.py file :
Image_folder = 'D:/Drone/temperature_JPG/'
Output_folder = "out_temperature/"

So, if you want to transform the images in C:\your\path\to\the\DJI\images\ you have to change the following line :
Image_folder = 'D:/Drone/temperature_JPG/'
to
Image_folder = 'C:/your/path/to/the/DJI/images/'


Please notice the type of separator used ("/" instead of "\") for the absolute path.

When the param.py file is configured, you just have to launch the "extract.bat" file and it will create the subfolder in the source image path and you will be granted with a little log in the cmd prompt.


If you find a better solution, I would be really happy to hear from you!

Rémi


The new link since the old one is broken : https://drive.google.com/file/d/1S1-KOr9CjIeYOB3Nn6j6JHNYXwDTziyB

geo-nerd

Hi everyone!

I'm looking for some help with this error I'm getting with the package Remi put together from all your coded pieces.

I followed Remi's instructions in changing the imagery input and output folders and then ran the bat file..but I got an error as it couldn't located the .dll file even though both dll files are in the same directory within the same file folder structure that Remi had.


this is my line of code that I tweaked from the wrapper.py script to try to get it to look in the right place:
libname_so = 'dji_ir_measure' + so_ext
mylib = CDLL(os.path.join(os.path.dirname("C:/Users/Cami/Downloads/traitement_temperature-1/traitement_temperature"), libname_so))


And this is the error message I got:
RESTART: C:\Users\Cami\Downloads\traitement_temperature-1\traitement_temperature\dji_ir_measure_wrapper.py
Traceback (most recent call last):
  File "C:\Users\Cami\Downloads\traitement_temperature-1\traitement_temperature\dji_ir_measure_wrapper.py", line 175, in <module>
    mylib = CDLL(os.path.join(os.path.dirname("C:/Users/Cami/Downloads/traitement_temperature-1/traitement_temperature/dji_ir_measure.dll"), libname_so))
  File "C:\Users\Cami\Downloads\traitement_temperature-1\traitement_temperature\python_portable\WPy32-3850\python-3.8.5\lib\ctypes\__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\Cami\Downloads\traitement_temperature-1\traitement_temperature\dji_ir_measure.dll' (or one of its dependencies). Try using the full path with constructor syntax.


Any help is sooo greatly appreciated!

OZ

Hi everyone,

Thank you all for your efforts to extract the raw values from DJI radiometric format!

According to this, did someone manage to extract the value of the real temperature from M2EA radiometric Images (I found that this is not the same format as H20T, why DJI??!!?!)??

I manage to extract the raw data from the image using Exiftool v12.30 but what is the formula to calculate the temp in Celsius?

Thanks a lot!!

daz

I use the DJI thermal SDK, it comes with a tool to process a binary of temperature floats from a JPEG. Dockerized here: https://github.com/daz/dji-thermal-sdk-docker

OZ

@daz Thanks for the docker, but this version still does not support Mavic 2 enterprise advanced radiometric images.

I was wondering if someone has successfully done so using Exiftool...

daz

Nah sorry, the thermal SDK only supports XT S and H20T. Nobody has successfully reversed engineered the proprietary DJI temperature from raw algorithms for any cameras yet. I would suggest pulling apart the Thermal Analysis Tool 2.0 the same way users have here with version 1, seeing if you can expose any APIs in the DLL that relate to the Mavic thermal. Can you upload an example image from the Mavic?

OZ