File size: 1,025 Bytes
71fd38f
 
1674e2f
2b2dcb2
1674e2f
71fd38f
1674e2f
 
 
d04305d
 
 
 
 
1674e2f
d04305d
 
 
 
 
 
 
 
 
1674e2f
 
d04305d
1674e2f
 
 
 
 
d04305d
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import streamlit as st
import cv2
#from ultralytics import YOLO

#model = YOLO('best.pt')

#def track(source):
#    result = model.track(source=source)
#    return result

st.set_page_config(page_title="Streamlit WebCam App")
st.title("Webcam Display Steamlit App")
cap = cv2.VideoCapture(0)
frame_placeholder = st.empty()
#st_frame = 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 Capture Ended")
        break
    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    frame_placeholder.image(frame, channels="RGB")

    #resultado = track(frame)
    #res_plotted = resultado[0].plot()
    
    #st_frame.image(res_plotted,
    #                   caption='Detected Video',
    #                   channels="RGB",
    #                   #use_column_width=True
    #                   )

    if cv2.waitKey(1) & 0xFF == ord("q") or stop_button_pressed:
        break
cap.release()
cv2.destroyAllWindows()