bdck commited on
Commit
e73a251
·
verified ·
1 Parent(s): 30857ce

Upload examples/chunked_reconstruction.py

Browse files
Files changed (1) hide show
  1. examples/chunked_reconstruction.py +33 -0
examples/chunked_reconstruction.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Large-scale / out-of-core reconstruction example.
3
+
4
+ When your point cloud has millions of points (e.g. a full building or
5
+ outdoor LiDAR scan), NKSR supports chunking: the scene is split into
6
+ overlapping blocks, each reconstructed independently, and then fused
7
+ into a single implicit field.
8
+ """
9
+
10
+ from pathlib import Path
11
+ from nksr_wrapper import NKSRMeshReconstructor, load_point_cloud, save_mesh
12
+
13
+ ply_path = Path("assets/large_scene.ply")
14
+ points, normals = load_point_cloud(ply_path)
15
+
16
+ recon = NKSRMeshReconstructor(
17
+ device="cuda:0",
18
+ config="ks",
19
+ chunk_tmp_device="cpu", # offload finished chunks to CPU RAM
20
+ )
21
+
22
+ mesh = recon.reconstruct(
23
+ points=points,
24
+ normals=normals,
25
+ chunk_size=50.0, # each chunk is a 50-unit cube
26
+ overlap_ratio=0.05, # 5 % overlap for smooth transitions
27
+ approx_kernel_grad=True, # faster gradient approximation
28
+ solver_tol=1e-4, # slightly looser tolerance — huge scenes
29
+ mise_iter=1,
30
+ )
31
+
32
+ save_mesh("large_scene_mesh.ply", mesh.vertices, mesh.faces)
33
+ print(f"Reconstructed {len(mesh.vertices):,} vertices, {len(mesh.faces):,} faces")