Update app.py
Browse files
app.py
CHANGED
|
@@ -18,15 +18,15 @@ def plot_boxes(frame, model):
|
|
| 18 |
|
| 19 |
# Function to process and display video
|
| 20 |
def process_video(source, model, options=None):
|
| 21 |
-
if source == '
|
| 22 |
-
cap = cv2.VideoCapture(0) #
|
| 23 |
else: # YouTube source
|
| 24 |
cap = CamGear(source=source, stream_mode=True, logging=True, **options).start()
|
| 25 |
|
| 26 |
FRAME_WINDOW = st.empty()
|
| 27 |
|
| 28 |
while True:
|
| 29 |
-
if source == '
|
| 30 |
ret, frame = cap.read()
|
| 31 |
if not ret:
|
| 32 |
break
|
|
@@ -39,7 +39,7 @@ def process_video(source, model, options=None):
|
|
| 39 |
frame = plot_boxes(frame, model)
|
| 40 |
FRAME_WINDOW.image(frame)
|
| 41 |
|
| 42 |
-
if source == '
|
| 43 |
cap.release()
|
| 44 |
|
| 45 |
# Load the YOLOv9 model
|
|
|
|
| 18 |
|
| 19 |
# Function to process and display video
|
| 20 |
def process_video(source, model, options=None):
|
| 21 |
+
if source == 'Webcam':
|
| 22 |
+
cap = cv2.VideoCapture(0) # webcam
|
| 23 |
else: # YouTube source
|
| 24 |
cap = CamGear(source=source, stream_mode=True, logging=True, **options).start()
|
| 25 |
|
| 26 |
FRAME_WINDOW = st.empty()
|
| 27 |
|
| 28 |
while True:
|
| 29 |
+
if source == 'Webcam':
|
| 30 |
ret, frame = cap.read()
|
| 31 |
if not ret:
|
| 32 |
break
|
|
|
|
| 39 |
frame = plot_boxes(frame, model)
|
| 40 |
FRAME_WINDOW.image(frame)
|
| 41 |
|
| 42 |
+
if source == 'Webcam':
|
| 43 |
cap.release()
|
| 44 |
|
| 45 |
# Load the YOLOv9 model
|