mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-05 07:18:57 +08:00
Merge 8af1b63d0c into 50e0e3c70c
This commit is contained in:
2 files changed
+19
-3
No files matched your search
@@ -75,7 +75,6 @@ def record3d_to_json(
|
|||||||
|
|
||||||
# Camera intrinsics
|
# Camera intrinsics
|
||||||
K = np.array(metadata_dict["K"]).reshape((3, 3)).T
|
K = np.array(metadata_dict["K"]).reshape((3, 3)).T
|
||||||
focal_length = K[0, 0]
|
|
||||||
|
|
||||||
H = metadata_dict["h"]
|
H = metadata_dict["h"]
|
||||||
W = metadata_dict["w"]
|
W = metadata_dict["w"]
|
||||||
@@ -85,8 +84,8 @@ def record3d_to_json(
|
|||||||
cx, cy = W / 2, H / 2
|
cx, cy = W / 2, H / 2
|
||||||
|
|
||||||
out = {
|
out = {
|
||||||
"fl_x": focal_length,
|
"fl_x": K[0, 0],
|
||||||
"fl_y": focal_length,
|
"fl_y": K[1, 1],
|
||||||
"cx": cx,
|
"cx": cx,
|
||||||
"cy": cy,
|
"cy": cy,
|
||||||
"w": W,
|
"w": W,
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from nerfstudio.process_data.record3d_utils import record3d_to_json
|
||||||
|
|
||||||
|
|
||||||
|
def test_record3d_preserves_distinct_focal_lengths(tmp_path: Path):
|
||||||
|
intrinsics = np.array([[500, 0, 320], [0, 525, 240], [0, 0, 1]], dtype=float)
|
||||||
|
metadata = {"K": intrinsics.T.flatten().tolist(), "h": 480, "w": 640, "poses": [[0, 0, 0, 1, 0, 0, 0]]}
|
||||||
|
path = tmp_path / "metadata.json"
|
||||||
|
path.write_text(json.dumps(metadata))
|
||||||
|
record3d_to_json([Path("frame.png")], path, tmp_path, np.array([0]), None, None)
|
||||||
|
|
||||||
|
output = json.loads((tmp_path / "transforms.json").read_text())
|
||||||
|
assert (output["fl_x"], output["fl_y"]) == (500, 525)
|
||||||
Reference in new issue
Block a user