Spaces:
Runtime error
Runtime error
Commit
·
be8944d
1
Parent(s):
06ee8eb
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# https://www.youtube.com/watch?v=q8GtmrDG6uo
|
3 |
+
import cv2
|
4 |
+
import streamlit as st
|
5 |
+
import numpy as np
|
6 |
+
import tempfile
|
7 |
+
|
8 |
+
cap = cv2.VideoCapture(1)
|
9 |
+
|
10 |
+
st.title("Video Capture")
|
11 |
+
|
12 |
+
frame_placeholder = st.empty()
|
13 |
+
|
14 |
+
stop_button_pressed = st.button("Stop")
|
15 |
+
|
16 |
+
while cap.isOpened() and not stop_button_pressed:
|
17 |
+
ret, frame = cap.read()
|
18 |
+
if not ret:
|
19 |
+
st.write("the video capture has ended")
|
20 |
+
break
|
21 |
+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
22 |
+
frame_placeholder.image(frame, channels = "RGB")
|
23 |
+
if cv2.waitKey(1) & 0XFF == ord("q") or stop_button_pressed:
|
24 |
+
break
|
25 |
+
cap.release()
|
26 |
+
cv2.destroyAllWindows
|