Shahrayar123 / Python-Projects

A comprehensive list of Python projects
399 stars 360 forks source link

Camera Access Check on AI_Attendance_Program #254

Open Eshanshahriar1234 opened 2 months ago

Eshanshahriar1234 commented 2 months ago

The code does not check if the camera is accessed. Possible fix could be a method to check if the webcam was properly accessed or not and return an error message if it is not accessed.

JC230903 commented 2 months ago

import cv2

cap = cv2.VideoCapture(0)

if not cap.isOpened(): print("Error: Could not access the webcam") else: while True: ret, frame = cap.read() if not ret: print("Failed to grab frame") break

    cv2.imshow('Webcam Feed', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release() cv2.destroyAllWindows()

Fuad-san commented 1 month ago

Hi is this issue still open

janetjoseph02 commented 1 month ago

I would be glad to contribute to this, so it would be great if you could assign me this task. Thanks, Regards.