SuganthKrishna2003 commited on
Commit
53e5a1a
·
1 Parent(s): 4a4c7c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -15
app.py CHANGED
@@ -14,28 +14,30 @@ from IPython.display import Audio
14
 
15
  # Using captured images
16
 
17
- def process_webcam_images():
18
- cap = cv2.VideoCapture(0) # 0 corresponds to the default camera (usually your webcam)
19
 
20
- while True:
21
- ret, frame = cap.read()
22
 
23
- # Display the captured image
24
- cv2.imshow('Webcam Image', frame)
 
 
25
 
26
- # Press 'q' to quit the loop
27
- if cv2.waitKey(1) & 0xFF == ord('q'):
28
- break
29
 
30
- return frame
 
31
 
32
- cap.release()
33
- cv2.destroyAllWindows()
34
 
35
- if __name__ == "__main__":
36
- process_webcam_images()
 
37
 
38
- image=process_webcam_images()
39
 
40
 
41
  # Using the pre-trained Dog Breed Identification Model
 
14
 
15
  # Using captured images
16
 
17
+ import cv2
 
18
 
19
+ # Open a connection to the webcam (0 is usually the default webcam)
20
+ cap = cv2.VideoCapture(0)
21
 
22
+ # Check if the webcam is opened successfully
23
+ if not cap.isOpened():
24
+ print("Error: Could not open the webcam.")
25
+ exit()
26
 
27
+ while True:
28
+ # Read a frame from the webcam
29
+ ret, frame = cap.read()
30
 
31
+ # Display the captured frame
32
+ cv2.imshow('Webcam', frame)
33
 
34
+ break
 
35
 
36
+ # Release the webcam and close the OpenCV windows
37
+ cap.release()
38
+ cv2.destroyAllWindows()
39
 
40
+ image=frame
41
 
42
 
43
  # Using the pre-trained Dog Breed Identification Model