mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-19 14:23:57 +08:00
Preserve OpenSfM intrinsics when importing ODM cameras
This commit is contained in:
1 parent
50e0e3c70c
commit
91a1ddd420
2 files changed
+49
-16
No files matched your search
@@ -0,0 +1,29 @@
|
||||
"""Regression tests for OpenSfM camera intrinsics in ODM conversions."""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from nerfstudio.process_data.odm_utils import cameras2nerfds
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"camera, expected",
|
||||
[
|
||||
({"projection_type": "perspective", "focal": 0.5}, {"fl_x": 400, "cx": 399.5, "cy": 299.5}),
|
||||
({"projection_type": "brown", "focal": 0.5, "c_x": 0.1, "c_y": -0.05}, {"cx": 479.5, "cy": 259.5}),
|
||||
({"projection_type": "fisheye_opencv", "focal": 0.5, "k4": 0.004}, {"k4": 0.004}),
|
||||
({"projection_type": "spherical"}, {"fl_x": 400, "fl_y": 600, "cx": 400, "cy": 300}),
|
||||
],
|
||||
)
|
||||
def test_odm_intrinsics(tmp_path, camera, expected):
|
||||
cameras_path = tmp_path / "cameras.json"
|
||||
cameras_path.write_text(json.dumps({"camera": {"width": 800, "height": 600, **camera}}))
|
||||
reconstruction_path = tmp_path / "reconstruction.json"
|
||||
shot = {"rotation": [0, 0, 0], "translation": [0, 0, 0]}
|
||||
reconstruction_path.write_text(json.dumps([{"shots": {"sample.jpg": shot}}]))
|
||||
cameras2nerfds({"sample": Path("sample.jpg")}, cameras_path, tmp_path / "shots.geojson", reconstruction_path, tmp_path)
|
||||
frame = json.loads((tmp_path / "transforms.json").read_text())["frames"][0]
|
||||
for key, value in expected.items():
|
||||
assert frame[key] == pytest.approx(value)
|
||||
Reference in new issue
Block a user