Ошибка с openCV2

Написал такой код

import cv2
import face_recognition


def face_rec():
    extracting_faces('images/to_recognition/2.jpg')

def extracting_faces(path):
    image = cv2.imread(path) 
    face_coor = face_recognition.face_locations(image)
    for x,y,w,h in face_coor:
        extract_img = image[y:h,x:w]
        print(extract_img)
        cv2.imshow('Result image', extract_img)
        cv2.waitKey(0)

def main():
    face_rec()


if __name__ == '__main__':
    main()

Код тупо берет путь к фотографии с лицом человека и обрезает ее именно в области лица. Путь правильный, но все же возникает ошибка

  File "тут путь к файлу", line 15, in extracting_faces
    cv2.imshow('Result image', extract_img)
cv2.error: OpenCV(4.5.4-dev) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

Ответы (1 шт):

Автор решения: B.lieve144

i had this problem a few days ago . just make sure file is in the correct folder and ahs the correct name and extension

→ Ссылка