| 1 |
import numpy as np |
| 2 |
|
| 3 |
import pycolmap |
| 4 |
|
| 5 |
|
| 6 |
def test_image_default_init(): |
| 7 |
image = pycolmap.Image() |
| 8 |
assert image is not None |
| 9 |
|
| 10 |
|
| 11 |
def test_image_image_id_readwrite(): |
| 12 |
image = pycolmap.Image() |
| 13 |
image.image_id = 10 |
| 14 |
assert image.image_id == 10 |
| 15 |
|
| 16 |
|
| 17 |
def test_image_camera_id_readwrite(): |
| 18 |
image = pycolmap.Image() |
| 19 |
image.camera_id = 5 |
| 20 |
assert image.camera_id == 5 |
| 21 |
|
| 22 |
|
| 23 |
def test_image_frame_id_readwrite(): |
| 24 |
image = pycolmap.Image() |
| 25 |
image.frame_id = 3 |
| 26 |
assert image.frame_id == 3 |
| 27 |
|
| 28 |
|
| 29 |
def test_image_name_readwrite(): |
| 30 |
image = pycolmap.Image() |
| 31 |
image.name = "test_image.jpg" |
| 32 |
assert image.name == "test_image.jpg" |
| 33 |
|
| 34 |
|
| 35 |
def test_image_points2d_readwrite(): |
| 36 |
image = pycolmap.Image() |
| 37 |
point_list = pycolmap.Point2DList() |
| 38 |
point_list.append(pycolmap.Point2D(xy=np.array([1.0, 2.0]))) |
| 39 |
point_list.append(pycolmap.Point2D(xy=np.array([3.0, 4.0]))) |
| 40 |
image.points2D = point_list |
| 41 |
assert len(image.points2D) == 2 |
| 42 |
|
| 43 |
|
| 44 |
def test_image_data_id_readonly(): |
| 45 |
image = pycolmap.Image() |
| 46 |
data_id = image.data_id |
| 47 |
assert data_id is not None |
| 48 |
|
| 49 |
|
| 50 |
def test_image_has_camera_id(): |
| 51 |
image = pycolmap.Image() |
| 52 |
assert not image.has_camera_id() |
| 53 |
image.camera_id = 1 |
| 54 |
assert image.has_camera_id() |
| 55 |
|
| 56 |
|
| 57 |
def test_image_has_frame_id(): |
| 58 |
image = pycolmap.Image() |
| 59 |
assert not image.has_frame_id() |
| 60 |
image.frame_id = 1 |
| 61 |
assert image.has_frame_id() |
| 62 |
|
| 63 |
|
| 64 |
def test_image_num_points2d(): |
| 65 |
image = pycolmap.Image() |
| 66 |
assert image.num_points2D() == 0 |
| 67 |
point_list = pycolmap.Point2DList() |
| 68 |
point_list.append(pycolmap.Point2D(xy=np.array([1.0, 2.0]))) |
| 69 |
image.points2D = point_list |
| 70 |
assert image.num_points2D() == 1 |
| 71 |
|
| 72 |
|
| 73 |
def test_image_num_points3d_readonly(): |
| 74 |
image = pycolmap.Image() |
| 75 |
assert image.num_points3D == 0 |
| 76 |
|
| 77 |
|
| 78 |
def test_image_has_pose_readonly(): |
| 79 |
image = pycolmap.Image() |
| 80 |
assert isinstance(image.has_pose, bool) |
| 81 |
|
| 82 |
|
| 83 |
def test_image_map_empty(): |
| 84 |
image_map = pycolmap.ImageMap() |
| 85 |
assert len(image_map) == 0 |
| 86 |
|
| 87 |
|
| 88 |
def test_image_map_insert_and_access(): |
| 89 |
image_map = pycolmap.ImageMap() |
| 90 |
image = pycolmap.Image() |
| 91 |
image.image_id = 1 |
| 92 |
image.name = "test.jpg" |
| 93 |
image_map[1] = image |
| 94 |
assert len(image_map) == 1 |
| 95 |
assert image_map[1].name == "test.jpg" |