Loading

Python Opencv Overload resolution failed: > - Layout of the output array img is incompatible with cv::Mat

https://stackoverflow.com/questions/23830618/python-opencv-typeerror-layout-of-the-output-array-incompatible-with-cvmat

某些情况下读取的img经过了转置,比如

gt_img = img.detach().cpu().numpy()[0]
gt_img = np.transpose(gt_img, (1, 2, 0))

这时候需要保证数组是ascontiguousarray

image = np.ascontiguousarray(image, dtype=np.uint8)

posted @ 2022-12-07 11:42  ZXYFrank  阅读(923)  评论(0编辑  收藏  举报