From d49e76618b5ddc4373f645b437e70c8831a3c0cb Mon Sep 17 00:00:00 2001 From: Jean NZONZIDI Date: Tue, 22 Oct 2024 18:45:46 +0100 Subject: [PATCH] Update python webcam.py --- python webcam.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python webcam.py b/python webcam.py index b2f2fe7..ea63e0f 100644 --- a/python webcam.py +++ b/python webcam.py @@ -3,6 +3,11 @@ # id of the video capturing device to open. To open default camera using default backend just pass 0. capture = cv2.VideoCapture(0) +# Check if the camera is opened successfully +if not capture.isOpened(): + print("Error: Unable to access the camera.") + exit() + while True: _, frame = capture.read() # We give the Window a name of "Capture from Webcam", and we also give it the frame which is an numpy object.