File size: 786 Bytes
59a2d05
1e4b03e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import streamlit as st
from streamlit_drawable_canvas import st_canvas
from PIL import Image

# Create a camera input widget
picture = st.camera_input("Take a picture")

if picture:
    # Convert the picture to an Image object
    img = Image.open(picture)

    # Display the drawable canvas with the image
    canvas_result = st_canvas(
        fill_color="rgba(255, 165, 0, 0.3)",  # Fixed fill color with some opacity
        stroke_width=2,
        stroke_color="black",
        background_image=img,
        update_streamlit=True,
        height=img.height,
        width=img.width,
        drawing_mode="freedraw",
        key="canvas",
    )

    # Display the resulting image with drawings
    if canvas_result.image_data is not None:
        st.image(canvas_result.image_data)