Update app.py
Browse files
app.py
CHANGED
@@ -948,7 +948,11 @@ with tabs[1]:
|
|
948 |
cam0_img = st.camera_input("Take a picture - Cam 0", key="main_cam0")
|
949 |
if cam0_img:
|
950 |
filename = generate_filename("cam0_snap");
|
951 |
-
if st.session_state.get('cam0_file') and os.path.exists(st.session_state['cam0_file']):
|
|
|
|
|
|
|
|
|
952 |
try:
|
953 |
with open(filename, "wb") as f: f.write(cam0_img.getvalue())
|
954 |
st.session_state['cam0_file'] = filename; st.session_state['history'].append(f"Snapshot from Cam 0: {filename}"); st.image(Image.open(filename), caption="Camera 0 Snap", use_container_width=True); logger.info(f"Saved snapshot from Camera 0: {filename}"); st.success(f"Saved {filename}")
|
|
|
948 |
cam0_img = st.camera_input("Take a picture - Cam 0", key="main_cam0")
|
949 |
if cam0_img:
|
950 |
filename = generate_filename("cam0_snap");
|
951 |
+
if st.session_state.get('cam0_file') and os.path.exists(st.session_state['cam0_file']):
|
952 |
+
try:
|
953 |
+
os.remove(st.session_state['cam0_file'])
|
954 |
+
except OSError:
|
955 |
+
pass
|
956 |
try:
|
957 |
with open(filename, "wb") as f: f.write(cam0_img.getvalue())
|
958 |
st.session_state['cam0_file'] = filename; st.session_state['history'].append(f"Snapshot from Cam 0: {filename}"); st.image(Image.open(filename), caption="Camera 0 Snap", use_container_width=True); logger.info(f"Saved snapshot from Camera 0: {filename}"); st.success(f"Saved {filename}")
|