pn23 commited on
Commit
1c1abdb
·
verified ·
1 Parent(s): d6c9b88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -20
app.py CHANGED
@@ -19,23 +19,15 @@ st.success("Success")
19
 
20
 
21
 
22
- cap = cv.VideoCapture(0)
23
- if not cap.isOpened():
24
- print("Cannot open camera")
25
- exit()
26
- while True:
27
- # Capture frame-by-frame
28
- ret, frame = cap.read()
29
- # if frame is read correctly ret is True
30
- if not ret:
31
- print("Can't receive frame (stream end?). Exiting ...")
32
- break
33
- # Our operations on the frame come here
34
- gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
35
- # Display the resulting frame
36
- cv.imshow('frame', gray)
37
- if cv.waitKey(1) == ord('q'):
38
- break
39
- # When everything done, release the capture
40
- cap.release()
41
- cv.destroyAllWindows()
 
19
 
20
 
21
 
22
+
23
+ st.title("Webcam Live Feed")
24
+ run = st.checkbox('Run')
25
+ FRAME_WINDOW = st.image([])
26
+ camera = cv2.VideoCapture(0)
27
+
28
+ while run:
29
+ _, frame = camera.read()
30
+ frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
31
+ FRAME_WINDOW.image(frame)
32
+ else:
33
+ st.write('Stopped')