| 1 |
import numpy as np |
| 2 |
import pytest |
| 3 |
|
| 4 |
import pycolmap |
| 5 |
|
| 6 |
|
| 7 |
def test_estimate_rigid3d_with_coplanar_points(): |
| 8 |
source = [ |
| 9 |
np.array([0.0, 0.0, 0.0]), |
| 10 |
np.array([1.0, 0.0, 0.0]), |
| 11 |
np.array([0.0, 1.0, 0.0]), |
| 12 |
np.array([1.0, 1.0, 0.0]), |
| 13 |
] |
| 14 |
target = [ |
| 15 |
np.array([0.0, 0.0, 0.0]), |
| 16 |
np.array([1.0, 0.0, 0.0]), |
| 17 |
np.array([0.0, 1.0, 0.0]), |
| 18 |
np.array([1.0, 1.0, 0.0]), |
| 19 |
] |
| 20 |
result = pycolmap.estimate_rigid3d(source, target) |
| 21 |
# May return None for degenerate configurations, but call should succeed |
| 22 |
assert result is None or isinstance(result, pycolmap.Rigid3d) |
| 23 |
|
| 24 |
|
| 25 |
def test_estimate_sim3d_with_points(): |
| 26 |
source = [ |
| 27 |
np.array([0.0, 0.0, 0.0]), |
| 28 |
np.array([1.0, 0.0, 0.0]), |
| 29 |
np.array([0.0, 1.0, 0.0]), |
| 30 |
np.array([0.0, 0.0, 1.0]), |
| 31 |
] |
| 32 |
target = [ |
| 33 |
np.array([0.0, 0.0, 0.0]), |
| 34 |
np.array([2.0, 0.0, 0.0]), |
| 35 |
np.array([0.0, 2.0, 0.0]), |
| 36 |
np.array([0.0, 0.0, 2.0]), |
| 37 |
] |
| 38 |
result = pycolmap.estimate_sim3d(source, target) |
| 39 |
assert result is None or isinstance(result, pycolmap.Sim3d) |
| 40 |
|
| 41 |
|
| 42 |
@pytest.mark.parametrize( |
| 43 |
"name", |
| 44 |
[ |
| 45 |
"estimate_rigid3d_robust", |
| 46 |
"estimate_sim3d_robust", |
| 47 |
], |
| 48 |
) |
| 49 |
def test_public_api_callable(name): |
| 50 |
assert callable(getattr(pycolmap, name)) |