Book Image

OpenCV with Python By Example

By : Prateek Joshi
Book Image

OpenCV with Python By Example

By: Prateek Joshi

Overview of this book

Table of Contents (19 chapters)
OpenCV with Python By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating the panoramic image


Now that we know how to match keypoints, let's go ahead and see how we can stitch multiple images together. Consider the following image:

Let's say we want to stitch the following image with the preceding image:

If we stitch these images, it will look something like the following one:

Now let's say we captured another part of this house, as seen in the following image:

If we stitch the preceding image with the stitched image we saw earlier, it will look something like this:

We can keep stitching images together to create a nice panoramic image. Let's take a look at the code:

import sys
import argparse

import cv2
import numpy as np

def argument_parser():
    parser = argparse.ArgumentParser(description='Stitch two images together')
    parser.add_argument("--query-image", dest="query_image", required=True,
            help="First image that needs to be stitched")
    parser.add_argument("--train-image", dest="train_image", required=True,
            help="Second image...