fcernafukuzaki commited on
Commit
71fd38f
·
verified ·
1 Parent(s): e3784c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -2
app.py CHANGED
@@ -1,3 +1,24 @@
1
- from streamlit_webrtc import webrtc_streamer
 
2
 
3
- webrtc_streamer(key="sample")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import cv2
3
 
4
+ def main():
5
+ st.set_page_config(page_title="Streamlit WebCam App")
6
+ st.title("Webcam Display Steamlit App")
7
+ st.caption("Powered by OpenCV, Streamlit")
8
+ cap = cv2.VideoCapture(0)
9
+ frame_placeholder = st.empty()
10
+ stop_button_pressed = st.button("Stop")
11
+ while cap.isOpened() and not stop_button_pressed:
12
+ ret, frame = cap.read()
13
+ if not ret:
14
+ st.write("Video Capture Ended")
15
+ break
16
+ frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
17
+ frame_placeholder.image(frame,channels="RGB")
18
+ if cv2.waitKey(1) & 0xFF == ord("q") or stop_button_pressed:
19
+ break
20
+ cap.release()
21
+ cv2.destroyAllWindows()
22
+
23
+ if __name__ == "__main__":
24
+ main()