Vikas01 commited on
Commit
0222d28
·
1 Parent(s): 24eeec1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -3
app.py CHANGED
@@ -78,9 +78,28 @@ def attend():
78
  csv_writer = csv.writer(csv_file)
79
 
80
  @app.route('/at')
81
- def run_face_recognition():
82
- demo=gr.Interface(gr.Image(source="webcam",streaming=True),"image",live=True)
83
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
 
86
 
 
78
  csv_writer = csv.writer(csv_file)
79
 
80
  @app.route('/at')
81
+ def webcam():
82
+ # Open the webcam
83
+ cap = cv2.VideoCapture(0)
84
+
85
+ while True:
86
+ # Read frames from the webcam
87
+ ret, frame = cap.read()
88
+
89
+ # Display the frames in a window
90
+ cv2.imshow("Webcam", frame)
91
+
92
+ # Break the loop when 'q' is pressed
93
+ if cv2.waitKey(1) & 0xFF == ord('q'):
94
+ break
95
+
96
+ # Release the webcam and close the window
97
+ cap.release()
98
+ cv2.destroyAllWindows()
99
+
100
+ iface = gr.Interface(fn=webcam, inputs=None, outputs=None)
101
+ iface.launch()
102
+
103
 
104
 
105