试图将图像传递给代码进行进一步处理,并在python中使用argparse遇到问题?

时间:2019-01-04 15:28:35

标签: python computer-vision argparse

这都是使用python中的argparse将图像传递到数据集

import argparse
import imutils
import cv2

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--input", required=True,
    help="path to input image")
ap.add_argument("-o", "--output", required=True,
    help="path to output image")
args = vars(ap.parse_args())  #here is where the problem occured

应该没有任何错误,作为一个初学者,我无法理解此错误:

usage: [-h] -i INPUT -o OUTPUT
: error: the following arguments are required: -i/--input, -o/--output
An exception has occurred, use %tb to see the full traceback.

%tb
Traceback (most recent call last):

  File "<ipython-input-26-269e7792981c>", line 11, in <module>
    args = vars(ap.parse_args())

  File "E:\SoftwaresInstalled\envs\tensorflow-gpu\lib\argparse.py", line 1734, in parse_args
    args, argv = self.parse_known_args(args, namespace)

  File "E:\SoftwaresInstalled\envs\tensorflow-gpu\lib\argparse.py", line 1766, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)

  File "E:\SoftwaresInstalled\envs\tensorflow-gpu\lib\argparse.py", line 2001, in _parse_known_args
    ', '.join(required_actions))

  File "E:\SoftwaresInstalled\envs\tensorflow-gpu\lib\argparse.py", line 2393, in error
    self.exit(2, _('%(prog)s: error: %(message)s\n') % args)

  File "E:\SoftwaresInstalled\envs\tensorflow-gpu\lib\argparse.py", line 2380, in exit
    _sys.exit(status)

SystemExit: 2

0 个答案:

没有答案