codic commited on
Commit
8254004
·
verified ·
1 Parent(s): b00c2bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -66,12 +66,12 @@ def process_image(image_path, depth_map_path=None):
66
 
67
  # Step 2: Edge-preserving filter (Enhance small structures)
68
  depth_image = cv2.edgePreservingFilter(
69
- (depth_image_cleaned * 255).astype(np.uint8), flags=1, sigma_s=10, sigma_r=0.2
70
  )
71
  depth_image = depth_image.astype(np.float32) / 255 # Normalize back to [0, 1]
72
 
73
  # Step 3: Smooth depth map with Gaussian filter
74
- depth_image = cv2.GaussianBlur(depth_image, (3, 3), sigmaX=1.5, sigmaY=1.5)
75
 
76
  # Step 4: Bilateral filter for detail preservation
77
  depth_image = cv2.bilateralFilter((depth_image * 255).astype(np.uint8), 5, 50, 50).astype(np.float32) / 255
@@ -152,7 +152,7 @@ def create_3d_obj(foreground, depth_image, image_path, depth=12, edge_strength=0
152
  raise RuntimeError("Insufficient points in the point cloud for normals estimation.")
153
 
154
  # Estimate normals with refined parameters
155
- pcd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.05, max_nn=150))
156
  pcd.orient_normals_consistent_tangent_plane(k=10)
157
 
158
 
@@ -170,7 +170,7 @@ def create_3d_obj(foreground, depth_image, image_path, depth=12, edge_strength=0
170
 
171
 
172
  # Simplify with smaller voxel size for more detail
173
- voxel_size = max(mesh_raw.get_max_bound() - mesh_raw.get_min_bound()) / 7200
174
  mesh = mesh_raw.simplify_vertex_clustering(
175
  voxel_size=voxel_size,
176
  contraction=o3d.geometry.SimplificationContraction.Average,
 
66
 
67
  # Step 2: Edge-preserving filter (Enhance small structures)
68
  depth_image = cv2.edgePreservingFilter(
69
+ (depth_image_cleaned * 255).astype(np.uint8), flags=1, sigma_s=13, sigma_r=0.3
70
  )
71
  depth_image = depth_image.astype(np.float32) / 255 # Normalize back to [0, 1]
72
 
73
  # Step 3: Smooth depth map with Gaussian filter
74
+ depth_image = cv2.GaussianBlur(depth_image, (5, 5), sigmaX=3, sigmaY=3)
75
 
76
  # Step 4: Bilateral filter for detail preservation
77
  depth_image = cv2.bilateralFilter((depth_image * 255).astype(np.uint8), 5, 50, 50).astype(np.float32) / 255
 
152
  raise RuntimeError("Insufficient points in the point cloud for normals estimation.")
153
 
154
  # Estimate normals with refined parameters
155
+ pcd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.01, max_nn=100))
156
  pcd.orient_normals_consistent_tangent_plane(k=10)
157
 
158
 
 
170
 
171
 
172
  # Simplify with smaller voxel size for more detail
173
+ voxel_size = max(mesh_raw.get_max_bound() - mesh_raw.get_min_bound()) / 6200
174
  mesh = mesh_raw.simplify_vertex_clustering(
175
  voxel_size=voxel_size,
176
  contraction=o3d.geometry.SimplificationContraction.Average,