Ask Your Question
-2

hello anyone answer me how to pass command line arguments through python and how this error occurs usage: object_size.py [-h] -i IMAGE -w WIDTH object_size.py: error: argument -i/--image is required in this below code [closed]

asked 2017-07-18 00:32:26 -0600

deesha gravatar image

updated 2017-07-18 01:03:34 -0600

berak gravatar image
from scipy.spatial import distance as dist
from imutils import perspective
from imutils import contours
import numpy as np
import argparse
import imutils
import cv2
...

# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True,
                help="path to the input image")
ap.add_argument("-w", "--width", type=float, required=True,
                help="width of the left-most object in the image (in inches)")
args = vars(ap.parse_args())
image = cv2.imread(args["image"])
...
edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2017-07-18 01:16:41.616848

Comments

please do not throw a ton of unformatted code at us.

berak gravatar imageberak ( 2017-07-18 00:39:44 -0600 )edit

really, not an opencv problem.

berak gravatar imageberak ( 2017-07-18 01:17:08 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-18 01:09:45 -0600

berak gravatar image

your program requires cmdline args, so you have to call it like:

python myprog.py -i someimg.png -w 17

again, both -i and -w arguments are required here.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-07-18 00:32:26 -0600

Seen: 1,296 times

Last updated: Jul 18 '17