解决方法:
cv2.imdecode(np.fromfile(img_path, dtype=np.uint8))
如果在使用上面方法的返回值会报错,请使用以下方法:
def cv_imread(img_path):
cv_img = cv2.imdecode(np.fromfile(img_path, dtype=np.uint8), -1)
cv_img = cv2.cvtColor(cv_img, cv.COLOR_RGB2BGR)
return cv_img