The error is raised by OpenCV and based on the error message it seems the imread is failing and might be returning an empty array so you should check the path and make sure cv2 can properly read the image.