cv2.error: OpenCV(4.1.2) error: (-215:Assertion failed) !_img.empty() in function 'cv::imwrite'

Traceback (most recent call last):
  File "D:/FER/FacePP/decode_json.py", line 174, in
    demonstrate(r'C:\Users\user-pc\Documents\Dataset\FER\JsonFiles\FacePP\BBQNR\S3\angry\13342.json', 'angry')
  File "D:/FER/FacePP/decode_json.py", line 157, in demonstrate
    cv2.imwrite(new_path, new_img)
cv2.error: OpenCV(4.1.2) C:\projects\opencv-python\opencv\modules\imgcodecs\src\loadsave.cpp:715: error: (-215:Assertion failed) !_img.empty() in function 'cv::imwrite'

 

注意查看要imwrite的对象是否为空,在本例中为_img.

你可能感兴趣的:(cv2.error: OpenCV(4.1.2) error: (-215:Assertion failed) !_img.empty() in function 'cv::imwrite')