usage: yolo_opencv.py [-h] -i IMAGE -c CONFIG -w WEIGHTS -cl CLASSES yolo_opencv.py: error: the foll

usage: yolo_opencv.py [-h] -i IMAGE -c CONFIG -w WEIGHTS -cl CLASSES yolo_opencv.py: error: the following arguments are required: -i/--image, -c/--config, -w/--weights, -cl/--classes


yolo_opencv.py: error: the following arguments are required: -i/–image, -c/–config, -w/–weights, -cl/–classes)

笔者在pycharm中使用
https://github.com/arunponnusamy/object-detection-opencv
的例程yolo_opencv.py时出现了上述问题,原因好像是argparse不适合在windows上使用(希望有大神指出真正的原因),我就将:

ap = argparse.ArgumentParser()
ap.add_argument('-i', '--image', required=True,
                help = 'path to input image')
ap.add_argument('-c', '--config', required=True,
                help = 'path to yolo config file')
ap.add_argument('-w', '--weights', required=True,
                help = 'path to yolo pre-trained weights')
ap.add_argument('-cl', '--classes', required=True,
                help = 'path to text file containing class names')
args = ap.parse_args()

改成了:

class args:
    image = 'E:/object-detection-opencv-master/test_1.jpg'#自行替换文件
    config = 'E:/object-detection-opencv-master/yolov3.cfg'
    weights = 'E:/object-detection-opencv-master/yolov3.weights'
    classes = 'E:/object-detection-opencv-master/yolov3.txt'

其中文件路径自己定,yolov3.weights文件要自己另外下载:
https://pjreddie.com/media/files/yolov3.weights

亲测可用。

usage: yolo_opencv.py [-h] -i IMAGE -c CONFIG -w WEIGHTS -cl CLASSES yolo_opencv.py: error: the foll_第1张图片
usage: yolo_opencv.py [-h] -i IMAGE -c CONFIG -w WEIGHTS -cl CLASSES yolo_opencv.py: error: the foll_第2张图片

你可能感兴趣的:(opencv,python,yolo)