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

Upload examples/quickstart.py

Browse files
Files changed (1) hide show
  1. examples/quickstart.py +44 -0
examples/quickstart.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Quick-start example — reconstruct a mesh from a PLY point cloud.
3
+
4
+ Prerequisites
5
+ -------------
6
+ pip install nksr-wrapper
7
+
8
+ Or, from the repo root:
9
+ pip install -e .
10
+ """
11
+
12
+ from pathlib import Path
13
+ from nksr_wrapper import NKSRMeshReconstructor, load_point_cloud, save_mesh
14
+
15
+ # ------------------------------------------------------------------ #
16
+ # 1. Load your point cloud #
17
+ # ------------------------------------------------------------------ #
18
+ # Replace with your own .ply or .pcd file.
19
+ ply_path = Path("assets/my_scan.ply")
20
+ points, normals = load_point_cloud(ply_path)
21
+
22
+ # ------------------------------------------------------------------ #
23
+ # 2. Reconstruct #
24
+ # ------------------------------------------------------------------ #
25
+ # Use the "ks" (kitchen-sink) pretrained model — it generalises to
26
+ # objects, indoor scenes, and outdoor LiDAR scans.
27
+ recon = NKSRMeshReconstructor(device="cuda:0", config="ks")
28
+
29
+ mesh = recon.reconstruct(
30
+ points=points,
31
+ normals=normals, # optional — will estimate if None
32
+ detail_level=1.0, # 0.0 = smooth, 1.0 = max detail
33
+ mise_iter=1, # 1 or 2 for higher-res mesh
34
+ )
35
+
36
+ # ------------------------------------------------------------------ #
37
+ # 3. Save / inspect #
38
+ # ------------------------------------------------------------------ #
39
+ save_mesh("output_mesh.ply", mesh.vertices, mesh.faces)
40
+
41
+ # Or use Trimesh / Open3D for visualisation
42
+ import trimesh
43
+ vis = trimesh.Trimesh(vertices=mesh.vertices, faces=mesh.faces)
44
+ vis.show()