Image Stitching using OpenCV and Python (Creating Panorama Project)

11 / 23

Getting Key-Points and Feature Descriptors

In order to stitch two images, we should first find out the matching image features between both of them, so that we could stitch them based on these features.

Image features are small patches that are useful to compute similarities between images. An image feature is usually composed of a feature keypoint and a feature descriptor.

The key point usually contains the patch 2D position and other stuff if available such as scale and orientation of the image feature.

The descriptor contains the visual description of the patch and is used to compare the similarity between image features.

Let us use ORB algorithm from OpenCV to extract key-points and descriptors for each image. Though there are other alternatives to ORB - like SIFT and SURF - ORB wins over them as it is as efficient as them in computation-wise, performance-wise and ost importantly patent-wise. ORB is free while SIFT and SURF are patented.


  • cv2.ORB_create() which creates an object for ORB. We could use this object to get the key-points and descriptors for the images using detectAndCompute method of orb object.
  • Create an object of cv2.ORB_create() and let it be named as orb.

    orb = cv2.ORB_create()
  • Now use detectAndCompute method of this orb object and pass img1 as an argument to get the key-points and feature descriptors from the grayscale image of the right-side image.

    kp1, des1 = orb.<< your code comes here >>(img1,None)
  • Similarly, get the key-points and descriptors for img2.

    kp2, des2 = orb.<< your code comes here >>(img2,None)
Get Hint See Answer

Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...