| 1 |
import numpy as np |
| 2 |
|
| 3 |
import pycolmap |
| 4 |
|
| 5 |
|
| 6 |
def test_two_view_geometry_configuration_undefined(): |
| 7 |
assert pycolmap.TwoViewGeometryConfiguration.UNDEFINED is not None |
| 8 |
|
| 9 |
|
| 10 |
def test_two_view_geometry_configuration_degenerate(): |
| 11 |
assert pycolmap.TwoViewGeometryConfiguration.DEGENERATE is not None |
| 12 |
|
| 13 |
|
| 14 |
def test_two_view_geometry_configuration_calibrated(): |
| 15 |
assert pycolmap.TwoViewGeometryConfiguration.CALIBRATED is not None |
| 16 |
|
| 17 |
|
| 18 |
def test_two_view_geometry_configuration_uncalibrated(): |
| 19 |
assert pycolmap.TwoViewGeometryConfiguration.UNCALIBRATED is not None |
| 20 |
|
| 21 |
|
| 22 |
def test_two_view_geometry_configuration_planar(): |
| 23 |
assert pycolmap.TwoViewGeometryConfiguration.PLANAR is not None |
| 24 |
|
| 25 |
|
| 26 |
def test_two_view_geometry_configuration_panoramic(): |
| 27 |
assert pycolmap.TwoViewGeometryConfiguration.PANORAMIC is not None |
| 28 |
|
| 29 |
|
| 30 |
def test_two_view_geometry_configuration_planar_or_panoramic(): |
| 31 |
assert pycolmap.TwoViewGeometryConfiguration.PLANAR_OR_PANORAMIC is not None |
| 32 |
|
| 33 |
|
| 34 |
def test_two_view_geometry_configuration_watermark(): |
| 35 |
assert pycolmap.TwoViewGeometryConfiguration.WATERMARK is not None |
| 36 |
|
| 37 |
|
| 38 |
def test_two_view_geometry_configuration_multiple(): |
| 39 |
assert pycolmap.TwoViewGeometryConfiguration.MULTIPLE is not None |
| 40 |
|
| 41 |
|
| 42 |
def test_two_view_geometry_default_init(): |
| 43 |
geometry = pycolmap.TwoViewGeometry() |
| 44 |
assert geometry is not None |
| 45 |
|
| 46 |
|
| 47 |
def test_two_view_geometry_config_readwrite(): |
| 48 |
geometry = pycolmap.TwoViewGeometry() |
| 49 |
geometry.config = pycolmap.TwoViewGeometryConfiguration.CALIBRATED |
| 50 |
assert geometry.config == pycolmap.TwoViewGeometryConfiguration.CALIBRATED |
| 51 |
|
| 52 |
|
| 53 |
def test_two_view_geometry_e_readwrite(): |
| 54 |
geometry = pycolmap.TwoViewGeometry() |
| 55 |
essential = np.eye(3) |
| 56 |
geometry.E = essential |
| 57 |
np.testing.assert_array_almost_equal(geometry.E, essential) |
| 58 |
|
| 59 |
|
| 60 |
def test_two_view_geometry_f_readwrite(): |
| 61 |
geometry = pycolmap.TwoViewGeometry() |
| 62 |
fundamental = np.eye(3) |
| 63 |
geometry.F = fundamental |
| 64 |
np.testing.assert_array_almost_equal(geometry.F, fundamental) |
| 65 |
|
| 66 |
|
| 67 |
def test_two_view_geometry_h_readwrite(): |
| 68 |
geometry = pycolmap.TwoViewGeometry() |
| 69 |
homography = np.eye(3) |
| 70 |
geometry.H = homography |
| 71 |
np.testing.assert_array_almost_equal(geometry.H, homography) |
| 72 |
|
| 73 |
|
| 74 |
def test_two_view_geometry_cam2_from_cam1_readwrite(): |
| 75 |
geometry = pycolmap.TwoViewGeometry() |
| 76 |
rigid = pycolmap.Rigid3d() |
| 77 |
geometry.cam2_from_cam1 = rigid |
| 78 |
assert isinstance(geometry.cam2_from_cam1, pycolmap.Rigid3d) |
| 79 |
|
| 80 |
|
| 81 |
def test_two_view_geometry_inlier_matches_readwrite(): |
| 82 |
geometry = pycolmap.TwoViewGeometry() |
| 83 |
matches = np.array([[0, 1], [2, 3]], dtype=np.uint32) |
| 84 |
geometry.inlier_matches = matches |
| 85 |
result = geometry.inlier_matches |
| 86 |
assert result.shape[0] == 2 |
| 87 |
|
| 88 |
|
| 89 |
def test_two_view_geometry_tri_angle_readwrite(): |
| 90 |
geometry = pycolmap.TwoViewGeometry() |
| 91 |
geometry.tri_angle = 1.5 |
| 92 |
assert geometry.tri_angle == 1.5 |
| 93 |
|
| 94 |
|
| 95 |
def test_two_view_geometry_invert(): |
| 96 |
geometry = pycolmap.TwoViewGeometry() |
| 97 |
geometry.config = pycolmap.TwoViewGeometryConfiguration.CALIBRATED |
| 98 |
geometry.invert() |
| 99 |
assert geometry is not None |