junaid-simamdigital commited on
Commit
bc70f8a
·
verified ·
1 Parent(s): e571f74

Add portable binary splat export

Browse files
Files changed (1) hide show
  1. tests/test_gaussian_ply_to_splat.py +26 -0
tests/test_gaussian_ply_to_splat.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import struct
3
+
4
+ import numpy as np
5
+
6
+ from gaussian_ply_to_splat import convert_gaussian_ply
7
+ from simam3d_core import write_gaussian_ply
8
+
9
+
10
+ def test_gaussian_conversion_writes_records_and_sidecar(tmp_path):
11
+ source = tmp_path / "gaussians.ply"
12
+ destination = tmp_path / "scene.splat"
13
+ write_gaussian_ply(
14
+ source,
15
+ np.asarray([[0.0, 0.0, 1.0], [0.2, 0.0, 1.0]], dtype=np.float32),
16
+ np.asarray([[255, 0, 0], [0, 255, 0]], dtype=np.uint8),
17
+ weights=np.asarray([0.5, 1.0], dtype=np.float32),
18
+ source_views=np.asarray([0, 1], dtype=np.int32),
19
+ )
20
+ result = convert_gaussian_ply(source, destination)
21
+ assert result["vertex_count"] == 2
22
+ assert destination.stat().st_size == 64
23
+ assert struct.unpack("<3f", destination.read_bytes()[:12]) == (0.0, 0.0, 1.0)
24
+ sidecar = json.loads(destination.with_suffix(".splat.json").read_text(encoding="utf-8"))
25
+ assert sidecar["record_bytes"] == 32
26
+ assert "source_mask" in sidecar["source_evidence_fields"]