MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / point_cloud_stats

Function point_cloud_stats

scripts/worldmirror/compare_to_reference.py:176–204  ·  view source on GitHub ↗

Return (ref_n, cand_n, count_diff_pct, bbox_vol_diff_pct, centroid_diff_norm).

(ref_ply: Path, cand_ply: Path)

Source from the content-addressed store, hash-verified

174
175
176def point_cloud_stats(ref_ply: Path, cand_ply: Path):
177 """Return (ref_n, cand_n, count_diff_pct, bbox_vol_diff_pct, centroid_diff_norm)."""
178 a = read_ply_xyz(ref_ply)
179 b = read_ply_xyz(cand_ply)
180 if a is None or b is None:
181 return None
182 ref_n, cand_n = len(a), len(b)
183 count_diff = abs(ref_n - cand_n) / max(ref_n, 1)
184
185 def bbox_vol(xyz):
186 lo, hi = xyz.min(axis=0), xyz.max(axis=0)
187 side = hi - lo
188 return float(np.prod(side))
189
190 vol_a, vol_b = bbox_vol(a), bbox_vol(b)
191 vol_diff = abs(vol_a - vol_b) / max(abs(vol_a), 1e-9)
192 centroid_a, centroid_b = a.mean(axis=0), b.mean(axis=0)
193 # Use bbox diagonal of ref to normalize centroid shift.
194 diag = np.linalg.norm(a.max(axis=0) - a.min(axis=0))
195 centroid_shift = float(np.linalg.norm(centroid_a - centroid_b) / max(diag, 1e-9))
196 return {
197 "ref_points": ref_n,
198 "cand_points": cand_n,
199 "count_diff_pct": count_diff,
200 "ref_bbox_vol": vol_a,
201 "cand_bbox_vol": vol_b,
202 "bbox_vol_diff_pct": vol_diff,
203 "centroid_diff_normalized": centroid_shift,
204 }
205
206
207def main() -> int:

Callers 1

mainFunction · 0.85

Calls 2

read_ply_xyzFunction · 0.85
bbox_volFunction · 0.85

Tested by

no test coverage detected