summaryrefslogtreecommitdiff
path: root/run_tests.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2025-02-05 20:27:59 +0100
committerjaseg <git@jaseg.de>2025-02-05 20:27:59 +0100
commit176c1ccac2a2c758ac3a5d3922e05a1b936360e5 (patch)
tree703ee826b3b02cb7e676a5964e30f94d5e396131 /run_tests.py
parent9c2ed1c70c2c704e6140c34c2f216865c6f12b0d (diff)
downloadinfiray_irg_py-176c1ccac2a2c758ac3a5d3922e05a1b936360e5.tar.gz
infiray_irg_py-176c1ccac2a2c758ac3a5d3922e05a1b936360e5.tar.bz2
infiray_irg_py-176c1ccac2a2c758ac3a5d3922e05a1b936360e5.zip
Fix offset issues.
This commit is tested against all test files I have available. We tried to parse the temperature array offset from the file to match that one Autel device, but that ended up breaking other stuff. It seems the offset is not explicitly recorded. TODO: Figure out if they are using 273.0 or 273.15 K.
Diffstat (limited to 'run_tests.py')
-rw-r--r--run_tests.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/run_tests.py b/run_tests.py
new file mode 100644
index 0000000..03a358a
--- /dev/null
+++ b/run_tests.py
@@ -0,0 +1,30 @@
+from pathlib import Path
+
+import infiray_irg
+
+test_files = sorted(Path('test_pictures').glob('*.irg'))
+
+for f in test_files:
+ try:
+ coarse, fine, vis = infiray_irg.load(f.read_bytes(), print_debug_information=True)
+ print('\033[93m', f'{f.name:>20}', 'Coldest pixel:', fine.min(), 'C', 'Hottest pixel:', fine.max(), 'C', '\033[0m')
+ except Exception as e:
+ print(f'Error parsing {f}')
+ raise e
+
+print()
+print('Header diffs:')
+
+for offset, legend in {
+ 0: 'magc hlen coars_len yres xres flg0 unk1 zero fine unk2 jpeg_len_ yres xres emissivit fine_off1 fine_off2 distance_',
+ 64: ' unit gain'}.items():
+ print(f'{" ":>20}', legend)
+ test_headers = {f: f.read_bytes()[offset:offset+64] for f in test_files}
+ header_idx_diffs = [len(set(header[i] for header in test_headers.values())) > 1 for i in range(64)]
+ for f, header in test_headers.items():
+ print(f'{str(f.name):>20}', ' '.join(
+ ''.join(
+ (f'\033[91m{header[i]:02x}' if header_idx_diffs[i] else f'\033[0m{header[i]:02x}')
+ for i in range(chunk, chunk+2))
+ for chunk in range(0, 64, 2)
+ )+'\033[0m')