How to do it

You need to complete the following steps:

  1. Import the necessary modules:
import cv2import numpy as np
  1. Load the images we're going to combine into a panorama:
images = []images.append(cv2.imread('../data/panorama/0.jpg', cv2.IMREAD_COLOR))images.append(cv2.imread('../data/panorama/1.jpg', cv2.IMREAD_COLOR))
  1. Create a panorama stitcher, pass your images to it, and parse the result:
stitcher = cv2.createStitcher()ret, pano = stitcher.stitch(images)if ret == cv2.STITCHER_OK:    cv2.imshow('panorama', pano)    cv2.waitKey()    cv2.destroyAllWindows()else:    print('Error during stiching')

Get OpenCV 3 Computer Vision with Python Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.