Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -932,7 +932,11 @@ with tabs[1]:
|
|
| 932 |
cam0_img = st.camera_input("Take a picture - Cam 0", key="main_cam0")
|
| 933 |
if cam0_img:
|
| 934 |
filename = generate_filename("cam0_snap");
|
| 935 |
-
if st.session_state.get('cam0_file') and os.path.exists(st.session_state['cam0_file']):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 936 |
try:
|
| 937 |
with open(filename, "wb") as f: f.write(cam0_img.getvalue())
|
| 938 |
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}")
|
|
@@ -942,7 +946,11 @@ with tabs[1]:
|
|
| 942 |
cam1_img = st.camera_input("Take a picture - Cam 1", key="main_cam1")
|
| 943 |
if cam1_img:
|
| 944 |
filename = generate_filename("cam1_snap")
|
| 945 |
-
if st.session_state.get('cam1_file') and os.path.exists(st.session_state['cam1_file']):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 946 |
try:
|
| 947 |
with open(filename, "wb") as f: f.write(cam1_img.getvalue())
|
| 948 |
st.session_state['cam1_file'] = filename; st.session_state['history'].append(f"Snapshot from Cam 1: {filename}"); st.image(Image.open(filename), caption="Camera 1 Snap", use_container_width=True); logger.info(f"Saved snapshot from Camera 1: {filename}"); st.success(f"Saved {filename}")
|
|
|
|
| 932 |
cam0_img = st.camera_input("Take a picture - Cam 0", key="main_cam0")
|
| 933 |
if cam0_img:
|
| 934 |
filename = generate_filename("cam0_snap");
|
| 935 |
+
if st.session_state.get('cam0_file') and os.path.exists(st.session_state['cam0_file']):
|
| 936 |
+
try:
|
| 937 |
+
os.remove(st.session_state['cam0_file'])
|
| 938 |
+
except OSError:
|
| 939 |
+
pass
|
| 940 |
try:
|
| 941 |
with open(filename, "wb") as f: f.write(cam0_img.getvalue())
|
| 942 |
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}")
|
|
|
|
| 946 |
cam1_img = st.camera_input("Take a picture - Cam 1", key="main_cam1")
|
| 947 |
if cam1_img:
|
| 948 |
filename = generate_filename("cam1_snap")
|
| 949 |
+
if st.session_state.get('cam1_file') and os.path.exists(st.session_state['cam1_file']):
|
| 950 |
+
try:
|
| 951 |
+
os.remove(st.session_state['cam1_file'])
|
| 952 |
+
except OSError:
|
| 953 |
+
pass
|
| 954 |
try:
|
| 955 |
with open(filename, "wb") as f: f.write(cam1_img.getvalue())
|
| 956 |
st.session_state['cam1_file'] = filename; st.session_state['history'].append(f"Snapshot from Cam 1: {filename}"); st.image(Image.open(filename), caption="Camera 1 Snap", use_container_width=True); logger.info(f"Saved snapshot from Camera 1: {filename}"); st.success(f"Saved {filename}")
|