cv2.error: OpenCV(4.2.0) :opencv-pythonerror:right >= ms() <= 2 in function ‘cv::copyMakeBorder‘

参考大佬博客中的评论

https://ask.csdn.net/questions/1057478#answer_1310863

报错信息:

img = cv2.copyMakeBorder(img, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color)  # add border

cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\core\src\copy.cpp:1421: error: (-215:Assertion failed) top >= 0 && bottom >= 0 && left >= 0 && right >= 0 && _src.dims() <= 2 in function 'cv::copyMakeBorder'

解决:

建议你把test.py文件中的第四十七行的
dataset = LoadImagesAndLabels(test_path, img_size, batch_size)

改为

dataset = LoadImagesAndLabels(test_path, img_size, batch_size,rect = False)试试

你可能感兴趣的:(Python)