| 1 |
import pycolmap |
| 2 |
|
| 3 |
|
| 4 |
def test_sensor_type_enum(): |
| 5 |
assert {k: int(v) for k, v in pycolmap.SensorType.__members__.items()} == { |
| 6 |
"INVALID": -1, |
| 7 |
"CAMERA": 0, |
| 8 |
"IMU": 1, |
| 9 |
} |
| 10 |
|
| 11 |
|
| 12 |
def test_sensor_type_string_construction(): |
| 13 |
assert pycolmap.SensorType("CAMERA") == pycolmap.SensorType.CAMERA |
| 14 |
assert pycolmap.SensorType("IMU") == pycolmap.SensorType.IMU |
| 15 |
assert pycolmap.SensorType("INVALID") == pycolmap.SensorType.INVALID |
| 16 |
|
| 17 |
|
| 18 |
def test_sensor_t_default_init(): |
| 19 |
sensor = pycolmap.sensor_t() |
| 20 |
assert sensor is not None |
| 21 |
|
| 22 |
|
| 23 |
def test_sensor_t_init_with_args(): |
| 24 |
sensor = pycolmap.sensor_t(type=pycolmap.SensorType.CAMERA, id=42) |
| 25 |
assert sensor.type == pycolmap.SensorType.CAMERA |
| 26 |
assert sensor.id == 42 |
| 27 |
|
| 28 |
|
| 29 |
def test_sensor_t_readwrite_type(): |
| 30 |
sensor = pycolmap.sensor_t() |
| 31 |
sensor.type = pycolmap.SensorType.IMU |
| 32 |
assert sensor.type == pycolmap.SensorType.IMU |
| 33 |
|
| 34 |
|
| 35 |
def test_sensor_t_readwrite_id(): |
| 36 |
sensor = pycolmap.sensor_t() |
| 37 |
sensor.id = 7 |
| 38 |
assert sensor.id == 7 |
| 39 |
|
| 40 |
|
| 41 |
def test_data_t_default_init(): |
| 42 |
data = pycolmap.data_t() |
| 43 |
assert data is not None |
| 44 |
|
| 45 |
|
| 46 |
def test_data_t_init_with_args(): |
| 47 |
sensor = pycolmap.sensor_t(type=pycolmap.SensorType.CAMERA, id=1) |
| 48 |
data = pycolmap.data_t(sensor_id=sensor, id=99) |
| 49 |
assert data.id == 99 |
| 50 |
|
| 51 |
|
| 52 |
def test_data_t_readwrite_sensor_id(): |
| 53 |
data = pycolmap.data_t() |
| 54 |
sensor = pycolmap.sensor_t(type=pycolmap.SensorType.CAMERA, id=5) |
| 55 |
data.sensor_id = sensor |
| 56 |
assert data.sensor_id.id == 5 |
| 57 |
|
| 58 |
|
| 59 |
def test_data_t_readwrite_id(): |
| 60 |
data = pycolmap.data_t() |
| 61 |
data.id = 123 |
| 62 |
assert data.id == 123 |
| 63 |
|
| 64 |
|
| 65 |
def test_image_pair_to_pair_id_and_roundtrip(): |
| 66 |
pair_id = pycolmap.image_pair_to_pair_id(1, 2) |
| 67 |
assert isinstance(pair_id, int) |
| 68 |
image_id1, image_id2 = pycolmap.pair_id_to_image_pair(pair_id) |
| 69 |
assert image_id1 == 1 |
| 70 |
assert image_id2 == 2 |
| 71 |
|
| 72 |
|
| 73 |
def test_should_swap_image_pair(): |
| 74 |
result = pycolmap.should_swap_image_pair(2, 1) |
| 75 |
assert isinstance(result, bool) |