Spaces:
Runtime error
Runtime error
trying uderstan ding th error
Browse files
app.py
CHANGED
|
@@ -160,14 +160,14 @@ def get_mesh(image: Image.Image, depth, image_path: str, foreground: np.ndarray)
|
|
| 160 |
# Normalize depth map and set background to zero (remove background noise)
|
| 161 |
depth_image_normalized = ((depth - depth.min()) / (depth.max() - depth.min()) * 255.0).astype(np.float32)
|
| 162 |
print("Resizing depth image...")
|
| 163 |
-
# Resize the depth image to match the size of the foreground image
|
| 164 |
depth_image_resized = np.array(
|
| 165 |
Image.fromarray((depth_image_normalized).astype(np.uint8)).resize(foreground.shape[:2][::-1], Image.LANCZOS)
|
| 166 |
)
|
|
|
|
|
|
|
| 167 |
|
| 168 |
print("Converting depth and image to Open3D format...")
|
| 169 |
-
|
| 170 |
-
depth_o3d = o3d.geometry.Image(depth_image_resized.astype(np.float32) / 255.0)
|
| 171 |
image_o3d = o3d.geometry.Image(np.array(image))
|
| 172 |
rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
|
| 173 |
image_o3d, depth_o3d, convert_rgb_to_intensity=False
|
|
@@ -230,6 +230,7 @@ def get_mesh(image: Image.Image, depth, image_path: str, foreground: np.ndarray)
|
|
| 230 |
except Exception as e:
|
| 231 |
print(f"Error generating 3D mesh: {type(e).__name__} - {e}")
|
| 232 |
return None, None
|
|
|
|
| 233 |
def process_image(image_path):
|
| 234 |
try:
|
| 235 |
image_raw = Image.open(image_path).convert("RGB")
|
|
|
|
| 160 |
# Normalize depth map and set background to zero (remove background noise)
|
| 161 |
depth_image_normalized = ((depth - depth.min()) / (depth.max() - depth.min()) * 255.0).astype(np.float32)
|
| 162 |
print("Resizing depth image...")
|
|
|
|
| 163 |
depth_image_resized = np.array(
|
| 164 |
Image.fromarray((depth_image_normalized).astype(np.uint8)).resize(foreground.shape[:2][::-1], Image.LANCZOS)
|
| 165 |
)
|
| 166 |
+
# Convert depth map to float for filtering
|
| 167 |
+
depth_image_resized = depth_image_resized.astype(np.float32) # No re-normalization
|
| 168 |
|
| 169 |
print("Converting depth and image to Open3D format...")
|
| 170 |
+
depth_o3d = o3d.geometry.Image(depth.astype(np.float32) / 65535.0) # Non-inverted scale
|
|
|
|
| 171 |
image_o3d = o3d.geometry.Image(np.array(image))
|
| 172 |
rgbd_image = o3d.geometry.RGBDImage.create_from_color_and_depth(
|
| 173 |
image_o3d, depth_o3d, convert_rgb_to_intensity=False
|
|
|
|
| 230 |
except Exception as e:
|
| 231 |
print(f"Error generating 3D mesh: {type(e).__name__} - {e}")
|
| 232 |
return None, None
|
| 233 |
+
|
| 234 |
def process_image(image_path):
|
| 235 |
try:
|
| 236 |
image_raw = Image.open(image_path).convert("RGB")
|