| import json | |
| from pathlib import Path | |
| import numpy as np | |
| from ylff.services.sensor_adapters import align_depth_nearest, load_arkit_poses_json | |
| def test_align_depth_nearest_resizes(): | |
| d = np.arange(4, dtype=np.float32).reshape(2, 2) | |
| out = align_depth_nearest(d, out_shape_hw=(4, 4)) | |
| assert out.shape == (4, 4) | |
| assert float(out[0, 0]) == float(d[0, 0]) | |
| def test_load_arkit_poses_json(tmp_path: Path): | |
| poses = [np.eye(4).tolist(), (np.eye(4) * 2).tolist()] | |
| p = tmp_path / "poses.json" | |
| p.write_text(json.dumps({"poses": poses})) | |
| arr = load_arkit_poses_json(p) | |
| assert arr.shape == (2, 4, 4) | |
| assert float(arr[1, 0, 0]) == 2.0 | |