summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2024-12-20 20:22:47 +0100
committerjaseg <git@jaseg.de>2024-12-20 20:22:47 +0100
commitf60da2a6430d82576d017633eb21e51652391d96 (patch)
tree5bc185301cc5a174fb799ebf419c43f3eb80a033 /src
parentec85ebad75b5b49c2bf0d142eb0bf0d09e5082bf (diff)
downloadinfiray_irg_py-f60da2a6430d82576d017633eb21e51652391d96.tar.gz
infiray_irg_py-f60da2a6430d82576d017633eb21e51652391d96.tar.bz2
infiray_irg_py-f60da2a6430d82576d017633eb21e51652391d96.zip
Add support for Autel Robotics Evo II Dual 640T V3 files
Diffstat (limited to 'src')
-rw-r--r--src/infiray_irg.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/infiray_irg.py b/src/infiray_irg.py
index dfe0d0c..291dfe3 100644
--- a/src/infiray_irg.py
+++ b/src/infiray_irg.py
@@ -26,7 +26,7 @@ def load(data):
raise ValueError(f'Header magic not found. Got header: {header[0]:02x} {header[1]:02x}')
_unk0, coarse_section_length, y_res, x_res,\
- _zero0, _unk1, _zero1, fine_offset, _unk2, jpeg_length,\
+ flag0, _unk1, _zero1, fine_offset, _unk2, jpeg_length,\
y_res_2, x_res_2, _unk3, = struct.unpack('<HIHHHHHHHIHHI', header[2:34])
fine_temp_offset1, fine_temp_offset2, *rest, high_gain_mode_flag = struct.unpack('<11I', header[34:78])
@@ -39,25 +39,31 @@ def load(data):
# import textwrap
# print(textwrap.dedent(f'''
# {_unk0=}, {coarse_section_length=}, {y_res=}, {x_res=},
-# {_zero0=}, {_unk1=}, {_zero1=}, {fine_offset=}, {_unk2=}, {jpeg_length=},
+# {flag0=}, {_unk1=}, {_zero1=}, {fine_offset=}, {_unk2=}, {jpeg_length=},
# {y_res_2=}, {x_res_2=}, {_unk3=}
# {fine_temp_offset1=} {fine_temp_offset1=} {rest=}, {high_gain_mode_flag=}'''))
- if (x_res, y_res) != (x_res_2, y_res_2) and model != 'p200':
- raise ValueError(f'Resolution mismatch in header: {x_res}*{y_res} != {x_res_2}*{y_res_2}')
-
if x_res*y_res != coarse_section_length:
raise ValueError('Resolution mismatch in header')
+ vis_jpg = None
if model == 'c201':
if header[-2:] != bytes([0xac,0xca]):
raise ValueError(f'Header end marker not found. Got header: {header[-2]:02x} {header[-1]:02x}')
coarse_img = np.frombuffer(consume(coarse_section_length), dtype=np.uint8).reshape((y_res, x_res))
- # 1/16th Kelvin steps
fine_img = np.frombuffer(consume(x_res*y_res*2), dtype=np.uint16).reshape((y_res, x_res))
- fine_img = (fine_img / 16) - fine_temp_offset
- vis_jpg = Image.open(io.BytesIO(consume(jpeg_length)))
+ if flag0 == 1: # Seen in Autel Robotics Evo II Dual 640T V3 file
+ fine_img = (fine_img / 64) - fine_temp_offset
+
+ else: # C201 files
+ # 1/16th Kelvin steps
+ fine_img = (fine_img / 16) - fine_temp_offset
+
+ if jpeg_length > 0:
+ # I have seen a file from an Autel Robotics Evo II Dual 640T V3 that looks like a C201 file, but lacks the
+ # visible data.
+ vis_jpg = Image.open(io.BytesIO(consume(jpeg_length)))
elif model == 'other':
if header[-2:] != bytes([0xab,0xba]):
@@ -76,7 +82,6 @@ def load(data):
fine_img = fine_img / 10 - fine_temp_offset
# In my example file, data now contains the JSON '{"roi":[]}' and no JPG. We ignore that.
- vis_jpg = None
return coarse_img, fine_img, vis_jpg