March 2020
Intermediate to advanced
366 pages
9h 8m
English
We want to write a script that will take a list of images and will produce a single panorama picture. So, let's set up the ArgumentParser for our script:
def parse_args(): parser = argparse.ArgumentParser() img_group = parser.add_mutually_exclusive_group(required=True) img_group.add_argument('--image-dir', type=Path) img_group.add_argument('--images', type=Path, nargs='+') args = parser.parse_args() if args.image_dir: args.images = sorted(args.image_dir.iterdir()) return args
Here, we created an instance of ArgumentParser and added arguments to pass either an image directory of a list of images. Then, we make sure we get all the images from the image directory if it is passed, instead of passing ...