File size: 663 Bytes
7a87926
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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