shukdevdatta123 commited on
Commit
331c43f
·
verified ·
1 Parent(s): d959f41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -3
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
- # Option for interactive painting (Placeholder)
58
- st.subheader("Interactive Depth-based Painting (Demo Placeholder)")
59
- st.write("This feature will allow users to paint on surfaces based on depth. For now, we can show the depth and its effects.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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!")