Circularmachines
commited on
Commit
•
3d79c89
1
Parent(s):
775fea9
app.py updates
Browse files
app.py
CHANGED
@@ -28,6 +28,9 @@ if "points" not in st.session_state:
|
|
28 |
if "img" not in st.session_state:
|
29 |
st.session_state["img"] = 0
|
30 |
|
|
|
|
|
|
|
31 |
#"## Click on image"
|
32 |
|
33 |
|
@@ -40,7 +43,7 @@ def button_click():
|
|
40 |
#st.write(str(r))
|
41 |
st.session_state["points"] = []
|
42 |
#value = streamlit_image_coordinates(current_image, key="pil")
|
43 |
-
|
44 |
|
45 |
|
46 |
|
@@ -57,10 +60,12 @@ def get_ellipse_coords(point):# tuple[int, int]) -> tuple[int, int, int, int]):
|
|
57 |
)
|
58 |
|
59 |
|
|
|
|
|
60 |
# Draw an ellipse at each coordinate in points
|
61 |
-
for point in st.session_state["points"]:
|
62 |
-
|
63 |
-
|
64 |
|
65 |
value = streamlit_image_coordinates(current_image, key="pil")
|
66 |
|
@@ -69,6 +74,7 @@ if value is not None:
|
|
69 |
|
70 |
if point not in st.session_state["points"]:
|
71 |
st.session_state["points"]=[point]
|
|
|
72 |
st.experimental_rerun()
|
73 |
|
74 |
|
|
|
28 |
if "img" not in st.session_state:
|
29 |
st.session_state["img"] = 0
|
30 |
|
31 |
+
if "draw" not in st.session_state:
|
32 |
+
st.session_state["draw"] = False
|
33 |
+
|
34 |
#"## Click on image"
|
35 |
|
36 |
|
|
|
43 |
#st.write(str(r))
|
44 |
st.session_state["points"] = []
|
45 |
#value = streamlit_image_coordinates(current_image, key="pil")
|
46 |
+
st.session_state["draw"]=False
|
47 |
|
48 |
|
49 |
|
|
|
60 |
)
|
61 |
|
62 |
|
63 |
+
if st.session_state["draw"]:
|
64 |
+
|
65 |
# Draw an ellipse at each coordinate in points
|
66 |
+
for point in st.session_state["points"]:
|
67 |
+
coords = get_ellipse_coords(point)
|
68 |
+
draw.rectangle(coords, outline="green",width=2)
|
69 |
|
70 |
value = streamlit_image_coordinates(current_image, key="pil")
|
71 |
|
|
|
74 |
|
75 |
if point not in st.session_state["points"]:
|
76 |
st.session_state["points"]=[point]
|
77 |
+
st.session_state["draw"]=True
|
78 |
st.experimental_rerun()
|
79 |
|
80 |
|