File size: 1,651 Bytes
7a87926 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
import json
from pathlib import Path
from ylff.utils.capture_bundle import CaptureBundle
def test_load_detailed_annotation_returns_model(tmp_path: Path):
(tmp_path / "devices" / "iphone_a").mkdir(parents=True)
(tmp_path / "annotations").mkdir(parents=True)
(tmp_path / "devices" / "iphone_a" / "video.mov").write_bytes(b"x")
(tmp_path / "devices" / "iphone_a" / "intrinsics.json").write_text(
json.dumps({"fx": 100.0, "fy": 100.0, "cx": 4.0, "cy": 4.0})
)
(tmp_path / "devices" / "iphone_a" / "timestamps.json").write_text(json.dumps({"t": []}))
ann = {
"schema_version": "1.0",
"capture_id": "cap_001",
"segments": [],
"scene_metadata": {"primary_type": "RESIDENTIAL_KITCHEN"},
"quality_assessment": {"rating": "good"},
}
(tmp_path / "annotations" / "detailed_annotation.json").write_text(json.dumps(ann))
manifest = {
"schema_version": "1.0",
"capture_id": "cap_001",
"devices": [
{
"device_id": "iphone_a",
"device_type": "iphone",
"video_path": "devices/iphone_a/video.mov",
"intrinsics_path": "devices/iphone_a/intrinsics.json",
"timestamps_path": "devices/iphone_a/timestamps.json",
}
],
"annotations": {"detailed_annotation_path": "annotations/detailed_annotation.json"},
}
(tmp_path / "manifest.json").write_text(json.dumps(manifest))
bundle = CaptureBundle.load(tmp_path)
loaded = bundle.load_detailed_annotation()
assert loaded is not None
assert loaded.capture_id == "cap_001"
|