Update app.py
Browse files
app.py
CHANGED
@@ -332,28 +332,28 @@ def update_gallery():
|
|
332 |
st.markdown(get_download_link(file, "image/png", "Download Image"), unsafe_allow_html=True)
|
333 |
|
334 |
def get_available_video_devices():
|
335 |
-
|
336 |
-
#
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
if
|
352 |
-
video_devices =
|
353 |
-
logger.info(f"Found video nodes: {video_devices}")
|
354 |
else:
|
355 |
-
|
356 |
-
|
|
|
357 |
return video_devices
|
358 |
|
359 |
def mock_search(query: str) -> str:
|
@@ -552,19 +552,15 @@ with tab2:
|
|
552 |
st.header("Camera Snap 📷 (Dual Capture!)")
|
553 |
video_devices = get_available_video_devices()
|
554 |
st.subheader("Camera Settings ⚙️")
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
st.write(f"Detected Video Devices: {', '.join(video_devices)}")
|
559 |
-
|
560 |
# Camera selection with defaults
|
561 |
-
default_cam0_index = 0
|
562 |
-
default_cam1_index = 1 if len(video_devices) > 1 else 0
|
563 |
selected_cam0 = st.selectbox("Select Camera 0", video_devices, index=default_cam0_index, key="cam0_select")
|
564 |
selected_cam1 = st.selectbox("Select Camera 1", video_devices, index=default_cam1_index, key="cam1_select")
|
565 |
|
566 |
-
st.info("Note: Camera selection is informational. Actual device used depends on browser settings. Configure in browser (e.g., Chrome > Settings > Privacy > Camera).")
|
567 |
-
|
568 |
slice_count = st.number_input("Image Slice Count 🎞️", min_value=1, max_value=20, value=10, help="How many snaps to dream of? (Automation’s on vacation! 😜)")
|
569 |
video_length = st.number_input("Video Dream Length (seconds) 🎥", min_value=1, max_value=30, value=10, help="Imagine a vid this long—sadly, we’re stuck with pics for now! 😂")
|
570 |
|
|
|
332 |
st.markdown(get_download_link(file, "image/png", "Download Image"), unsafe_allow_html=True)
|
333 |
|
334 |
def get_available_video_devices():
|
335 |
+
# Placeholder list since we can't directly query browser devices from Python
|
336 |
+
# This is a fallback; ideally, use a custom component for navigator.mediaDevices.enumerateDevices()
|
337 |
+
video_devices = ["Camera 0", "Camera 1"] # Default assumption
|
338 |
+
try:
|
339 |
+
# Attempt OpenCV detection as a secondary check
|
340 |
+
detected = []
|
341 |
+
for i in range(10):
|
342 |
+
cap = cv2.VideoCapture(i, cv2.CAP_V4L2)
|
343 |
+
if not cap.isOpened():
|
344 |
+
cap = cv2.VideoCapture(i) # Try default backend
|
345 |
+
if cap.isOpened():
|
346 |
+
detected.append(f"Camera {i}")
|
347 |
+
logger.info(f"Detected camera at index {i}")
|
348 |
+
cap.release()
|
349 |
+
else:
|
350 |
+
logger.debug(f"No camera detected at index {i}")
|
351 |
+
if detected:
|
352 |
+
video_devices = detected
|
|
|
353 |
else:
|
354 |
+
logger.warning("OpenCV detected no cameras; using browser-inferred defaults")
|
355 |
+
except Exception as e:
|
356 |
+
logger.error(f"Error detecting video devices with OpenCV: {str(e)}")
|
357 |
return video_devices
|
358 |
|
359 |
def mock_search(query: str) -> str:
|
|
|
552 |
st.header("Camera Snap 📷 (Dual Capture!)")
|
553 |
video_devices = get_available_video_devices()
|
554 |
st.subheader("Camera Settings ⚙️")
|
555 |
+
st.write(f"Available Cameras: {', '.join(video_devices)}")
|
556 |
+
st.info("Camera selection is informational. Use your browser settings to switch cameras (e.g., Chrome > Settings > Privacy > Camera).")
|
557 |
+
|
|
|
|
|
558 |
# Camera selection with defaults
|
559 |
+
default_cam0_index = 0
|
560 |
+
default_cam1_index = 1 if len(video_devices) > 1 else 0
|
561 |
selected_cam0 = st.selectbox("Select Camera 0", video_devices, index=default_cam0_index, key="cam0_select")
|
562 |
selected_cam1 = st.selectbox("Select Camera 1", video_devices, index=default_cam1_index, key="cam1_select")
|
563 |
|
|
|
|
|
564 |
slice_count = st.number_input("Image Slice Count 🎞️", min_value=1, max_value=20, value=10, help="How many snaps to dream of? (Automation’s on vacation! 😜)")
|
565 |
video_length = st.number_input("Video Dream Length (seconds) 🎥", min_value=1, max_value=30, value=10, help="Imagine a vid this long—sadly, we’re stuck with pics for now! 😂")
|
566 |
|