Update app.py
Browse files
app.py
CHANGED
|
@@ -54,6 +54,29 @@ if uploaded_file is not None:
|
|
| 54 |
depth_image.save('depth_image.png')
|
| 55 |
st.success("Depth image saved successfully!")
|
| 56 |
|
| 57 |
-
#
|
| 58 |
-
st.subheader("Interactive Depth-based Painting
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
depth_image.save('depth_image.png')
|
| 55 |
st.success("Depth image saved successfully!")
|
| 56 |
|
| 57 |
+
# Interactive Painting Feature
|
| 58 |
+
st.subheader("Interactive Depth-based Painting")
|
| 59 |
+
|
| 60 |
+
# Prepare for canvas
|
| 61 |
+
canvas = st.canvas(
|
| 62 |
+
width=colormap.width,
|
| 63 |
+
height=colormap.height,
|
| 64 |
+
drawing_mode="freedraw",
|
| 65 |
+
initial_drawing=colormap,
|
| 66 |
+
key="painting_canvas"
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
if canvas.image_data is not None:
|
| 70 |
+
# Convert canvas drawing to an image
|
| 71 |
+
painted_image = Image.fromarray(canvas.image_data.astype(np.uint8))
|
| 72 |
+
|
| 73 |
+
# You can combine the depth and painting here
|
| 74 |
+
st.subheader("Canvas with Painting")
|
| 75 |
+
st.image(painted_image, caption="Painting on Depth Map", use_column_width=True)
|
| 76 |
+
|
| 77 |
+
# Option to save painted image
|
| 78 |
+
if st.button('Save Painted Image'):
|
| 79 |
+
painted_image.save('painted_image.png')
|
| 80 |
+
st.success("Painted image saved successfully!")
|
| 81 |
+
else:
|
| 82 |
+
st.write("Draw on the canvas to interact with depth!")
|