TakashiKAWAMOTO-TTS commited on
Commit
087bb16
·
1 Parent(s): ac2392f

add UI for parameter settings

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -59,7 +59,7 @@ def check_delimiter(file_path):
59
  else:
60
  return " "
61
 
62
- def meshing(file_obj):
63
  try:
64
  if DEBUG:
65
  temp_path = os.path.join(file_obj.dir, file_obj.name)
@@ -81,12 +81,13 @@ def meshing(file_obj):
81
 
82
  dists = pcd.compute_nearest_neighbor_distance()
83
  avg_spacing = np.mean(dists)
84
- normal_radius = avg_spacing*5.0 #2.0 # start with 2–3x spacing
85
- pcd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=normal_radius, max_nn=100)) #30))
86
- pcd.orient_normals_consistent_tangent_plane(k=100) #30)
87
 
88
  # Mesh using Ball Pivoting
89
- mesh_radii = [avg_spacing * x for x in [3, 4, 5, 6]] #[1.5, 2.5, 3.5]]
 
90
  mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(pcd, o3d.utility.DoubleVector(mesh_radii))
91
 
92
  # Mesh using Poisson
@@ -117,7 +118,14 @@ def meshing(file_obj):
117
 
118
  iface_mesh = gr.Interface(
119
  fn=meshing,
120
- inputs=gr.File(file_types=[".txt", ".ply", ".pcd"], label="Upload Point Cloud"),
 
 
 
 
 
 
 
121
  outputs=[
122
  gr.Image(type="numpy", label="Mesh Preview"),
123
  gr.File(label="Download Mesh (STL)")
 
59
  else:
60
  return " "
61
 
62
+ def meshing(file_obj, normal_rad_coef, normal_max_nn, orient_k, bpa_min_coef, bpa_max_coef):
63
  try:
64
  if DEBUG:
65
  temp_path = os.path.join(file_obj.dir, file_obj.name)
 
81
 
82
  dists = pcd.compute_nearest_neighbor_distance()
83
  avg_spacing = np.mean(dists)
84
+ normal_radius = avg_spacing*normal_rad_coef # start with 2–3x spacing
85
+ pcd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=normal_radius, max_nn=normal_max_nn))
86
+ pcd.orient_normals_consistent_tangent_plane(k=orient_k)
87
 
88
  # Mesh using Ball Pivoting
89
+ coeffs = np.linspace(bpa_min_coef, bpa_max_coef, int(4))
90
+ mesh_radii = [avg_spacing * x for x in coeffs]
91
  mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(pcd, o3d.utility.DoubleVector(mesh_radii))
92
 
93
  # Mesh using Poisson
 
118
 
119
  iface_mesh = gr.Interface(
120
  fn=meshing,
121
+ inputs=[
122
+ gr.File(file_types=[".txt", ".ply", ".pcd"], label="Upload Point Cloud"),
123
+ gr.Slider(1.0, 10.0, value=2.0, step=0.1, label="Normal Radius (Hybrid Search)"),
124
+ gr.Slider(1, 100, value=30, step=1, label="Max NN for Normals"),
125
+ gr.Slider(1, 100, value=30, step=1, label="K for Consistent Normal Orientation"),
126
+ gr.Slider(0.1, 10.0, value=1.5, step=0.1, label="Ball Pivoting Radius Min"),
127
+ gr.Slider(0.1, 10.0, value=3.5, step=0.1, label="Ball Pivoting Radius Max"),
128
+ ],
129
  outputs=[
130
  gr.Image(type="numpy", label="Mesh Preview"),
131
  gr.File(label="Download Mesh (STL)")