Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thermal support for DJI M3T [WIP] #1670

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion opendm/exiftool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import tempfile
import base64
import numpy as np
from rasterio.io import MemoryFile
from opendm.system import run
from opendm import log
Expand Down Expand Up @@ -36,7 +37,12 @@ def extract_raw_thermal_image_data(image_path):
img = img[0][:,:,None]

del j["RawThermalImage"]

elif "ThermalData" in j:
thermal_data = base64.b64decode(j["ThermalData"][len("base64:"):])
thermal_buf = np.frombuffer(thermal_data, dtype=np.int16)
# TODO: how to interpret these?
# https://exiftool.org/forum/index.php?topic=11401.45

return extract_temperature_params_from(j), img
else:
raise Exception("Invalid JSON (not a list)")
Expand Down Expand Up @@ -68,6 +74,7 @@ def _convert(v):

def extract_temperature_params_from(tags):
# Defaults

meta = {
"Emissivity": float,
"ObjectDistance": unit("m"),
Expand Down
6 changes: 6 additions & 0 deletions opendm/photo.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,12 @@ def parse_exif_values(self, _path_file):
self.capture_uuid = matches.group(1)
self.band_name = band_aliases.get(matches.group(2), matches.group(2))

# Some DJI models do not have a band name but have an image source field
if self.camera_make.lower() == 'dji':
image_source = self.get_xmp_tag(xtags, '@drone-dji:ImageSource')
if self.band_name == 'RGB' and isinstance(image_source, str) and image_source.lower() == "infraredcamera":
self.band_name = 'LWIR'

# Sanitize band name since we use it in folder paths
self.band_name = re.sub('[^A-Za-z0-9]+', '', self.band_name)

Expand Down