Spaces:
Build error
Build error
Commit
·
8d2a799
1
Parent(s):
d96d68b
app.py updates
Browse files
app.py
CHANGED
|
@@ -38,40 +38,40 @@ def button_click():
|
|
| 38 |
#st.write(str(r))
|
| 39 |
st.session_state["points"] = []
|
| 40 |
|
| 41 |
-
while True:
|
| 42 |
|
| 43 |
-
with current_image as img:
|
| 44 |
-
draw = ImageDraw.Draw(img)
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
|
| 76 |
#else:
|
| 77 |
# st.write('Gohuhuhubye')
|
|
|
|
| 38 |
#st.write(str(r))
|
| 39 |
st.session_state["points"] = []
|
| 40 |
|
|
|
|
| 41 |
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
while True:
|
| 44 |
+
draw = ImageDraw.Draw(current_image)
|
| 45 |
+
|
| 46 |
+
def get_ellipse_coords(point):# tuple[int, int]) -> tuple[int, int, int, int]):
|
| 47 |
+
center = point
|
| 48 |
+
radius = 16
|
| 49 |
+
return (
|
| 50 |
+
center[0] - radius,
|
| 51 |
+
center[1] - radius,
|
| 52 |
+
center[0] + radius,
|
| 53 |
+
center[1] + radius,
|
| 54 |
+
)
|
| 55 |
|
| 56 |
|
| 57 |
+
# Draw an ellipse at each coordinate in points
|
| 58 |
+
for point in st.session_state["points"]:
|
| 59 |
+
coords = get_ellipse_coords(point)
|
| 60 |
+
draw.rectangle(coords, outline="green",width=2)
|
| 61 |
|
| 62 |
+
value = streamlit_image_coordinates(img, key="pil")
|
| 63 |
|
| 64 |
+
if value is not None:
|
| 65 |
+
point = value["x"], value["y"]
|
| 66 |
|
| 67 |
+
if point not in st.session_state["points"]:
|
| 68 |
+
st.session_state["points"]=[point]
|
| 69 |
+
st.experimental_rerun()
|
| 70 |
|
| 71 |
|
| 72 |
+
st.button('Random frame', on_click=button_click)
|
| 73 |
+
|
| 74 |
+
st.write(str(r))
|
| 75 |
|
| 76 |
#else:
|
| 77 |
# st.write('Gohuhuhubye')
|