shuishen
19 hours ago 385be2eca72eb3833efa4be0a0088b34e764788a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from __future__ import annotations
 
import sys
import unittest
from pathlib import Path
 
import numpy as np
 
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from prepare_multimodal_pointcloud_dataset import Calibration, Shot, canonical_camera_name, normalise_las_rgb, project_points  # noqa: E402
 
 
class MultimodalPreparationTests(unittest.TestCase):
    def test_camera_name_normalises_odm_version_prefix(self) -> None:
        self.assertEqual(canonical_camera_name("v2 DJI M4TD 4032 3024 Brown 0.6666"), "dji m4td 4032 3024 brown 0.6666")
 
    def test_project_points_uses_camera_centre_and_positive_depth(self) -> None:
        calibration = Calibration("test", 100, 100, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
        shot = Shot("test.jpg", calibration, np.zeros(3), np.zeros(3), 0.0, 0.0, 0.0)
        pixels, inside = project_points(np.array([[0.0, 0.0, 2.0], [3.0, 0.0, 2.0], [0.0, 0.0, -2.0]]), shot)
        self.assertTrue(inside[0])
        self.assertFalse(inside[1])
        self.assertFalse(inside[2])
        np.testing.assert_allclose(pixels[0], [50.0, 50.0])
 
    def test_las_rgb_normalisation_detects_8_bit_values_in_16_bit_dimensions(self) -> None:
        values = np.array([[0, 127, 255], [255, 64, 32]], dtype=np.uint16)
        np.testing.assert_allclose(normalise_las_rgb(values), [[0.0, 127 / 255, 1.0], [1.0, 64 / 255, 32 / 255]])
 
 
if __name__ == "__main__":
    unittest.main()