Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -51,7 +51,7 @@ def plot_depth_map(depth_map, original_image):
|
|
51 |
|
52 |
# Resize original image to match depth map dimensions
|
53 |
original_image_resized = cv2.resize(original_image, (depth_map.shape[1], depth_map.shape[0]))
|
54 |
-
colors = original_image_resized.reshape(
|
55 |
|
56 |
ax.plot_surface(x, y, depth_map, facecolors=colors, shade=False)
|
57 |
ax.view_init(elev=70, azim=0) # Tilt by 20 degrees (90 - 20 = 70)
|
@@ -75,7 +75,11 @@ def process_frame(image):
|
|
75 |
|
76 |
depth_map = (depth_map - depth_map.min()) / (depth_map.max() - depth_map.min())
|
77 |
|
78 |
-
|
|
|
|
|
|
|
|
|
79 |
|
80 |
interface = gr.Interface(
|
81 |
fn=process_frame,
|
|
|
51 |
|
52 |
# Resize original image to match depth map dimensions
|
53 |
original_image_resized = cv2.resize(original_image, (depth_map.shape[1], depth_map.shape[0]))
|
54 |
+
colors = original_image_resized.reshape(depth_map.shape[0], depth_map.shape[1], 3) / 255.0
|
55 |
|
56 |
ax.plot_surface(x, y, depth_map, facecolors=colors, shade=False)
|
57 |
ax.view_init(elev=70, azim=0) # Tilt by 20 degrees (90 - 20 = 70)
|
|
|
75 |
|
76 |
depth_map = (depth_map - depth_map.min()) / (depth_map.max() - depth_map.min())
|
77 |
|
78 |
+
# Convert BGR to RGB if necessary
|
79 |
+
if image.shape[2] == 3: # Check if it's a color image
|
80 |
+
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
81 |
+
|
82 |
+
return plot_depth_map(depth_map, image)
|
83 |
|
84 |
interface = gr.Interface(
|
85 |
fn=process_frame,
|