Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -36,24 +36,24 @@ def main():
|
|
36 |
while True:
|
37 |
try:
|
38 |
image = camera_input_live()
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
|
58 |
except:
|
59 |
st.write('.')
|
|
|
36 |
while True:
|
37 |
try:
|
38 |
image = camera_input_live()
|
39 |
+
|
40 |
+
if image is not None:
|
41 |
+
st.image(image)
|
42 |
+
|
43 |
+
if time.time() - st.session_state['last_captured'] > 5:
|
44 |
+
filename = save_image(image)
|
45 |
+
st.session_state['captured_images'].append(filename)
|
46 |
+
st.session_state['last_captured'] = time.time()
|
47 |
+
|
48 |
+
sidebar_html = "<div style='display:flex;flex-direction:column;'>"
|
49 |
+
for img_file in st.session_state['captured_images']:
|
50 |
+
image_base64 = get_image_base64(img_file)
|
51 |
+
sidebar_html += f"<img src='data:image/png;base64,{image_base64}' style='width:100px;'><br>"
|
52 |
+
sidebar_html += "</div>"
|
53 |
+
st.sidebar.markdown("## Captured Images")
|
54 |
+
st.sidebar.markdown(sidebar_html, unsafe_allow_html=True)
|
55 |
+
|
56 |
+
time.sleep(0.1) # Add a short delay to reduce CPU usage
|
57 |
|
58 |
except:
|
59 |
st.write('.')
|