Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -42,19 +42,14 @@ def plot_depth_map(depth_map, original_image):
|
|
42 |
ax = fig.add_subplot(111, projection='3d')
|
43 |
x, y = np.meshgrid(range(depth_map.shape[1]), range(depth_map.shape[0]))
|
44 |
|
45 |
-
# Flip x and y to mirror the plot
|
46 |
-
x = np.flip(x, axis=1)
|
47 |
-
y = np.flip(y, axis=0)
|
48 |
-
|
49 |
-
# Rotate by 90 degrees
|
50 |
-
x, y = y, x
|
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 |
-
|
|
|
|
|
58 |
ax.set_zlim(0, 1)
|
59 |
plt.axis('off')
|
60 |
plt.close(fig)
|
|
|
42 |
ax = fig.add_subplot(111, projection='3d')
|
43 |
x, y = np.meshgrid(range(depth_map.shape[1]), range(depth_map.shape[0]))
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
# Resize original image to match depth map dimensions
|
46 |
original_image_resized = cv2.resize(original_image, (depth_map.shape[1], depth_map.shape[0]))
|
47 |
colors = original_image_resized.reshape(depth_map.shape[0], depth_map.shape[1], 3) / 255.0
|
48 |
|
49 |
ax.plot_surface(x, y, depth_map, facecolors=colors, shade=False)
|
50 |
+
|
51 |
+
# Adjust view to look down at an angle
|
52 |
+
ax.view_init(elev=110, azim=180) # Adjusted elevation and azimuth for better view
|
53 |
ax.set_zlim(0, 1)
|
54 |
plt.axis('off')
|
55 |
plt.close(fig)
|