Start adding thermal support for DJI M3T

pull/1670/head
Piero Toffanin 2023-06-29 14:10:53 +02:00
rodzic eb95137a4c
commit c7ada3668c
2 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -2,6 +2,7 @@ import json
import os
import tempfile
import base64
import numpy as np
from rasterio.io import MemoryFile
from opendm.system import run
from opendm import log
@ -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)")
@ -68,6 +74,7 @@ def unit(unit):
def extract_temperature_params_from(tags):
# Defaults
meta = {
"Emissivity": float,
"ObjectDistance": unit("m"),

Wyświetl plik

@ -481,6 +481,12 @@ class ODM_Photo:
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)