This code is meant to present an image of the user however, all I get returned is a black image the error code is
Traceback (most recent call last): File "/Users/ethanbrahmawar/Desktop/CardLayout/src/my/cardlayout/Stay Strong App html/rekognition/TEST.PY", line 22, in captureimage('Access','.jpeg') File "/Users/ethanbrahmawar/Desktop/CardLayout/src/my/cardlayout/Stay Strong App html/rekognition/TEST.PY", line 15, in captureimage rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA) cv2.error: OpenCV(4.6.0) /Users/xperience/actions-runner/_work/opencv-python/opencv-python/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
import pyttsx3
import cv2
from datetime import datetime
def captureimage(foldername,suffix):
engine=pyttsx3.init()
engine.say("face recognition enabled please look at the camera")
engine.runAndWait()
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
CAPTURE=foldername+'/capture'+current_time+suffix
cap = cv2.VideoCapture(1)
ret, frame = cap.read()
rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2BGRA)
cv2.imshow('frame', rgb)
out = cv2.imwrite(CAPTURE, frame)
cap.release()
cv2.destroyAllWindows()
return CAPTURE
captureimage('Access','.jpeg')