March 2019
Intermediate to advanced
532 pages
13h 2m
English
The following example, argparse_load_image.py, shows you how to load an image:
# Import the required packagesimport argparseimport cv2# We first create the ArgumentParser object # The created object 'parser' will have the necessary information# to parse the command-line arguments into data types.parser = argparse.ArgumentParser()# We add 'path_image' argument using add_argument() including a help. The type of this argument is string (by default)parser.add_argument("path_image", help="path to input image to be displayed")# The information about program arguments is stored in 'parser'# Then, it is used when the parser calls parse_args().# ArgumentParser parses arguments through the parse_args() method:args = parser.parse_args() ...