Author Topic: DJI H20T thermal radiometric jpeg file  (Read 352 times)

Jonathan McGillivray

  • Newbie
  • *
  • Posts: 5
DJI H20T thermal radiometric jpeg file
« on: July 09, 2020, 06:56:25 AM »
DJI have released a new camera with an integrated 640 x 512 radiometric thermal camera. The thermal camera does not seem to be based on a Flir core.

I have been trying to get the raw temperature information from the radiometric jpeg but they seem to be storing the temperature information in a different format to the Flir R-JPEG images. Their spec sheet just says that the image format is R-JPEG (16 bit).

Any help or guidance with how to extract the temperature information using ExifTool would be greatly appreciated. I have attached a sample image.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16706
    • ExifTool Home Page
Re: DJI H20T thermal radiometric jpeg file
« Reply #1 on: July 09, 2020, 08:18:27 AM »
There are a number of new APP segments in this file.  There is 650 kB of data in APP3 segments that could be the raw thermal data.  There is another 32 kB in APP5 that could potentially be something like this too.  APP4 is smaller, and possibly contains some setting or calibration information.  APP6 contains this text:

Code: [Select]
DTAT
{
"points":[
{"x":292,"y":228,"id":0},
{"x":399,"y":178,"id":1},
{"x":489,"y":276,"id":2},
{"x":290,"y":388,"id":3},
{"x":106,"y":341,"id":4}],
"rects":[
{"x":66,"y":75,"width":169,"height":179,"id":0},
{"x":465,"y":56,"width":104,"height":164,"id":1}],
"code":0
}

Lots of fun stuff to try to decode.  You can see it yourself with the -v3 option or with -htmldump

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

Jonathan McGillivray

  • Newbie
  • *
  • Posts: 5
Re: DJI H20T thermal radiometric jpeg file
« Reply #2 on: July 09, 2020, 12:10:05 PM »
Thanks for the quick response.

You are correct. The APP3 segment seems to be the raw sensor values. I've had a friend look at the image in python and he's managed to convert the APP3 segments from byte arrays into 16-bit unsigned integer pixels. See attached .tiff image generated from the APP3 segment data; However, values range from 18073 - 21222. I'm guessing the calibration data is required to convert the raw sensor values to actual temperature readings.

Can't seem to find out what encoding to use to decode the APP4 segment. Any ideas?

APP6 contains information stored from adding 'features' to the image in their software. For example, users can add points or rectangles to get temperature measurements from the image within their software. This information is subsequently stored in the image file under this segment.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16706
    • ExifTool Home Page
Re: DJI H20T thermal radiometric jpeg file
« Reply #3 on: July 09, 2020, 09:20:13 PM »
Some of the APP4 data may be 2-byte integers.  Other parts look like maybe 4-byte floats, but I don't have time to look into this in any depth right now.

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

mangulo

  • Newbie
  • *
  • Posts: 1
Re: DJI H20T thermal radiometric jpeg file
« Reply #4 on: July 13, 2020, 02:34:32 AM »
Hi all,  ... I would like to seek help from the university to decoding APP4 segment.
« Last Edit: July 13, 2020, 03:27:15 AM by mangulo »

Jonathan McGillivray

  • Newbie
  • *
  • Posts: 5
Re: DJI H20T thermal radiometric jpeg file
« Reply #5 on: July 13, 2020, 03:23:07 AM »
This is the code in python. Not sure how one could do it using ExifTools yet

Code: [Select]
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
import tifffile as tiff

im = Image.open("DJI_20200513193136_0004_THRM.JPG")

# concatenate APP3 chunks of data
a = im.applist[3][1]
for i in range(4, 14):
    a += im.applist[i][1]

# create image from bytes
img = Image.frombytes('I;16L', (640, 512), a)

temps = np.array(img)

# still need to apply formula to image to convert raw sensor values to temps

tiff.imsave('DJI_20200513193136_0004_THRM.tiff', temps)
np.savetxt('temps.csv', temps, delimiter=',')

plt.imshow(temps.astype(np.uint), cmap="inferno")
plt.show()

musteresel

  • Newbie
  • *
  • Posts: 1
Re: DJI H20T thermal radiometric jpeg file
« Reply #6 on: July 21, 2020, 03:59:44 AM »
I'm working on this atm.

When zeroing the APP4 segment and then opening the image with the DJI Thermal Analysis Tool gives the error message

Code: [Select]
>>>> ir_image_temp_info_get
ERROR: magic header adjust failed-7

When zeroing the APP5 segment, then that tool gives this error message:

Code: [Select]
>>>> ir_image_temp_info_get
ERROR: curve lut monotonicity adjust failed-8

So the APP5 segment is apparently also needed for decoding; it's a series of ever increasing values (unsigned 16 bit, with wrap around)

The APP4 segment is (in my images) mostly zeros, but information seemingly spread out at random.  Do you know what kind of format that could be?
« Last Edit: July 21, 2020, 11:23:35 AM by musteresel »

Jonathan McGillivray

  • Newbie
  • *
  • Posts: 5
Re: DJI H20T thermal radiometric jpeg file
« Reply #7 on: August 02, 2020, 04:35:32 PM »
It seems like a compensation is done to the images for Flat Field Corrections to prevent a sudden change in temperature values between FFCs. My guess is that maybe this compensation is stored within the APP5 segment?

I've been trying to compare the APP4 data between two different cameras. See attached spreadsheet showing the APP4 data in hex for 2 different cameras and multiple images from the same camera. It seems like all the images start with the same header. If I zero any of the values within this header no temperature information is displayed within the software. I then started changing other values within the APP4 segment. This caused the temperatures within the software to change which shows that these values are definitely used to convert the raw sensor values to temperature values. I highlighted these values in green within the spreadsheet. I'm not sure how one would go about converting these values from binary/hex to actual decimal or integer values without knowing what you're looking for. Hoping that Phil will be able to add some input once he's got time to look at it.