Download tests/test_regionmap.py from kimjunhan/vkgs-sim: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/kimjunhan/vkgs-sim/resolve/main/tests/test_regionmap.py
- Command line
-
hf download hf://kimjunhan/vkgs-sim/tests/test_regionmap.py
-
curl -L -o test_regionmap.py https://huggingface.co/kimjunhan/vkgs-sim/resolve/main/tests/test_regionmap.py
2.27 kB
| """μ§μ λ§΅ μΌμ 볡μ μλ μ ν (nusim.render.regionmap.sensor_world) β λ°μ΄ν°μ μμ΄.""" | |
| import json | |
| import numpy as np | |
| from nusim.io.ply import _ORIGIN_TAG | |
| from nusim.render.regionmap import sensor_world | |
| from nusim.render.segmap import SEGMAP_VERSION | |
| from nusim.sim.voxels import VOXELS_VERSION | |
| def _seg(d, name, origin): | |
| m = d / name | |
| m.mkdir(parents=True) | |
| (m / "point_cloud.ply").write_text(f"ply\ncomment {_ORIGIN_TAG} {origin[0]} {origin[1]} {origin[2]}\nend_header\n") | |
| return m | |
| def test_stale_world_still_used_with_its_own_origin(tmp_path): | |
| d = tmp_path / "scene-x" | |
| s1 = _seg(d, "seg1", (10, 20, 1)) | |
| (d / "world.vox").write_bytes(b"VOX2") | |
| # seg1 λ§ νμ΅λμ λ λ§λ μλ (origin κΈ°λ‘ μ νμ) | |
| (d / "export.json").write_text(json.dumps({"version": SEGMAP_VERSION, "voxels": VOXELS_VERSION, | |
| "models": ["seg1:1"]})) | |
| s0 = _seg(d, "seg0", (0, 0, 0)) # κ·Έ λ€ seg0 μ΄ νμ΅λ¨ β 첫 ꡬκ°κ³Ό μμ μ΄ λ°λμλ€ | |
| segs = [({"k": 0}, s0), ({"k": 1}, s1)] | |
| assert sensor_world(tmp_path, "scene-x", segs) is None # μ격: λ‘μ | |
| p, o = sensor_world(tmp_path, "scene-x", segs, strict=False) | |
| assert p == d / "world.vox" and np.allclose(o, [10, 20, 1]) # μλλ₯Ό λ§λ seg1 μμ | |
| j = json.loads((d / "export.json").read_text()) | |
| (d / "export.json").write_text(json.dumps({**j, "origin": [5, 6, 7]})) | |
| assert np.allclose(sensor_world(tmp_path, "scene-x", segs, strict=False)[1], [5, 6, 7]) | |
| (d / "export.json").write_text(json.dumps({**j, "voxels": VOXELS_VERSION - 1})) | |
| assert sensor_world(tmp_path, "scene-x", segs, strict=False) is None # 볡μ μκ³ λ¦¬μ¦μ΄ λ°λλ©΄ μ μ΄λ€ | |
| def test_unsplit_scene_model_is_scene_dir(tmp_path): | |
| d = tmp_path / "scene-y" | |
| d.mkdir() | |
| (d / "point_cloud.ply").write_text(f"ply\ncomment {_ORIGIN_TAG} 1 2 3\nend_header\n") | |
| (d / "world.vox").write_bytes(b"VOX2") | |
| (d / "export.json").write_text(json.dumps({"version": SEGMAP_VERSION, "voxels": VOXELS_VERSION, | |
| "models": ["scene-y:1"]})) | |
| p, o = sensor_world(tmp_path, "scene-y", [({"k": 0}, d)], strict=False) | |
| assert np.allclose(o, [1, 2, 3]) | |