demo1 / app.py
aliciiavs's picture
Update app.py
9d66c0a verified
raw
history blame contribute delete
727 Bytes
import cv2
import streamlit as st
for i in range(-1, 10): # Try indices from 0 to 9
cap = cv2.VideoCapture(i)
if cap.isOpened():
print(f"Camera index {i} is open.")
cap.release()
else:
print(f"Camera index {i} is not open.")
st.title("Sign Language App")
frame_placeholder = st.empty()
stop_button_pressed = st.button("Stop")
while cap.isOpened() and not stop_button_pressed:
ret, frame = cap.read()
if not ret:
st.write('video ended')
break
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame_placeholder.image(frame, channels='RGB')
if cv2.waitKey(1) & 0xFF == ord('q') or stop_button_pressed:
break
cap.release()
cv2.destroyAllWindows()