Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,11 +43,15 @@ def stitch_rgbd_videos(
|
|
| 43 |
for i in range(min(len(full_frames), len(depths))):
|
| 44 |
rgb_full = full_frames[i] # Full-resolution RGB frame.
|
| 45 |
depth_frame = depths[i]
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
# Normalize the depth frame to the range [0, 255].
|
| 48 |
depth_norm = ((depth_frame - d_min) / (d_max - d_min) * 255).astype(np.uint8)
|
| 49 |
-
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
# Generate depth visualization:
|
| 53 |
if grayscale:
|
|
@@ -57,10 +61,7 @@ def stitch_rgbd_videos(
|
|
| 57 |
cmap = matplotlib.colormaps.get_cmap("inferno")
|
| 58 |
depth_color = (cmap(depth_norm / 255.0)[..., :3] * 255).astype(np.uint8)
|
| 59 |
|
| 60 |
-
|
| 61 |
-
depth_gray = cv2.cvtColor(depth_color, cv2.COLOR_RGB2GRAY)
|
| 62 |
-
else:
|
| 63 |
-
depth_gray = depth_color
|
| 64 |
depth_vis = np.stack([depth_gray] * 3, axis=-1)
|
| 65 |
|
| 66 |
#depth_gray = cv2.cvtColor(depth_color, cv2.COLOR_RGB2GRAY)
|
|
@@ -87,9 +88,9 @@ def stitch_rgbd_videos(
|
|
| 87 |
# Resize the depth visualization to match the full-resolution RGB frame.
|
| 88 |
H_full, W_full = rgb_full.shape[:2]
|
| 89 |
depth_vis_resized = cv2.resize(depth_vis, (W_full, H_full))
|
|
|
|
| 90 |
|
| 91 |
-
|
| 92 |
-
if len(rgb_full.shape) == 3 and len(depth_vis_resized.shape) == 2:
|
| 93 |
depth_vis_resized = cv2.cvtColor(depth_vis_resized, cv2.COLOR_GRAY2BGR)
|
| 94 |
|
| 95 |
# Ensure both are the same type (commonly uint8):
|
|
|
|
| 43 |
for i in range(min(len(full_frames), len(depths))):
|
| 44 |
rgb_full = full_frames[i] # Full-resolution RGB frame.
|
| 45 |
depth_frame = depths[i]
|
| 46 |
+
|
| 47 |
+
if d_max == d_min:
|
| 48 |
+
d_max = d_min + 1
|
| 49 |
|
| 50 |
# Normalize the depth frame to the range [0, 255].
|
| 51 |
depth_norm = ((depth_frame - d_min) / (d_max - d_min) * 255).astype(np.uint8)
|
| 52 |
+
|
| 53 |
+
if depth_norm > 255:
|
| 54 |
+
depth_norm = 255
|
| 55 |
|
| 56 |
# Generate depth visualization:
|
| 57 |
if grayscale:
|
|
|
|
| 61 |
cmap = matplotlib.colormaps.get_cmap("inferno")
|
| 62 |
depth_color = (cmap(depth_norm / 255.0)[..., :3] * 255).astype(np.uint8)
|
| 63 |
|
| 64 |
+
depth_gray = cv2.cvtColor(depth_color, cv2.COLOR_RGB2GRAY)
|
|
|
|
|
|
|
|
|
|
| 65 |
depth_vis = np.stack([depth_gray] * 3, axis=-1)
|
| 66 |
|
| 67 |
#depth_gray = cv2.cvtColor(depth_color, cv2.COLOR_RGB2GRAY)
|
|
|
|
| 88 |
# Resize the depth visualization to match the full-resolution RGB frame.
|
| 89 |
H_full, W_full = rgb_full.shape[:2]
|
| 90 |
depth_vis_resized = cv2.resize(depth_vis, (W_full, H_full))
|
| 91 |
+
depth_vis_resized = depth_vis_resized.astype(np.uint8) # Ensure uint8
|
| 92 |
|
| 93 |
+
if len(depth_vis_resized.shape) == 2:
|
|
|
|
| 94 |
depth_vis_resized = cv2.cvtColor(depth_vis_resized, cv2.COLOR_GRAY2BGR)
|
| 95 |
|
| 96 |
# Ensure both are the same type (commonly uint8):
|