codic commited on
Commit
2b2708a
·
verified ·
1 Parent(s): 989ef51

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -181,7 +181,7 @@ def get_mesh(image: Image.Image, depth, image_path: str, foreground: np.ndarray)
181
  )
182
 
183
  # Camera intrinsics
184
- w, h = foreground_resized.shape[1], foreground_resized.shape[0]
185
  camera_intrinsic = o3d.camera.PinholeCameraIntrinsic(w, h, 2000, 2000, w / 2, h / 2) # Adjust focal length
186
 
187
  # Generate point cloud
@@ -192,13 +192,13 @@ def get_mesh(image: Image.Image, depth, image_path: str, foreground: np.ndarray)
192
  raise RuntimeError("Insufficient points in the point cloud for normals estimation.")
193
 
194
  # Estimate normals and orient them
195
- pcd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.01, max_nn=50))
196
  pcd.orient_normals_consistent_tangent_plane(k=10)
197
  pcd.orient_normals_towards_camera_location(camera_location=np.array([0.0, 0.0, 2000.0]))
198
 
199
  # Generate Poisson mesh
200
  mesh_raw, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(
201
- pcd, depth=12, width=0, scale=4, linear_fit=True
202
  )
203
 
204
  # Filter mesh by density
@@ -226,7 +226,7 @@ def get_mesh(image: Image.Image, depth, image_path: str, foreground: np.ndarray)
226
  # Save high-resolution texture image
227
  texture_path = f"./{os.path.splitext(os.path.basename(image_path))[0]}_texture_highres.png"
228
  foreground_pil = Image.fromarray(foreground)
229
- high_res_texture = foreground_pil.resize((3096, 3096), Image.LANCZOS)
230
  high_res_texture.save(texture_path)
231
 
232
  # Apply texture and export mesh
 
181
  )
182
 
183
  # Camera intrinsics
184
+ w, h = foreground.shape[1], foreground.shape[0]
185
  camera_intrinsic = o3d.camera.PinholeCameraIntrinsic(w, h, 2000, 2000, w / 2, h / 2) # Adjust focal length
186
 
187
  # Generate point cloud
 
192
  raise RuntimeError("Insufficient points in the point cloud for normals estimation.")
193
 
194
  # Estimate normals and orient them
195
+ pcd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.05, max_nn=100))
196
  pcd.orient_normals_consistent_tangent_plane(k=10)
197
  pcd.orient_normals_towards_camera_location(camera_location=np.array([0.0, 0.0, 2000.0]))
198
 
199
  # Generate Poisson mesh
200
  mesh_raw, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(
201
+ pcd, depth=12, width=0, scale=2, linear_fit=True
202
  )
203
 
204
  # Filter mesh by density
 
226
  # Save high-resolution texture image
227
  texture_path = f"./{os.path.splitext(os.path.basename(image_path))[0]}_texture_highres.png"
228
  foreground_pil = Image.fromarray(foreground)
229
+ high_res_texture = foreground_pil.resize((2000, 2000), Image.LANCZOS)
230
  high_res_texture.save(texture_path)
231
 
232
  # Apply texture and export mesh