Python – cv2.createStitcher() doesn’t have enough keypoints?

cv2.createStitcher() doesn’t have enough keypoints?… here is a solution to the problem.

cv2.createStitcher() doesn’t have enough keypoints?

I’m working on a project where it has multiple cameras, each camera takes a photo, and then stitches those images together. Currently I’m trying to use the cv2.createStitcher().stitch(images) function. Here’s the code I used:

import cv2

imageFiles = ['imageCapture1_0.png','imageCapture2_0.png']
images = []
for filename in imageFiles:
    img = cv2.imread(filename)
    images.append(img)

cv2.ocl.setUseOpenCL(False)
stitcher = cv2.createStitcher()
status, result = stitcher.stitch(images)             

cv2.imwrite('result.png',result)

The image input is:

Left:

left image

Right:

right image

However, the resulting output type becomes NoneType, a size of 1, and a value: a NoneType object for the built-in module. According to my search, this is because there are not enough matching keys to stitch the images together. If so, is there a way to stitch the image with fewer key points? Is there a way to set parameters? I read through the doc but didn’t find a solution. Thank you in advance

Solution

Image stitching operation status, result = stitcher.stitch(images) returns two values, a status indicator and the resulting stitched image. You can check the value of status to determine whether the image stitching operation was successful. From the documentation it can be one of four variables:

OK = 0: The image is stitched successfully.

ERR_NEED_MORE_IMGS = 1: Not enough keys are detected in your input image to build the panorama. You will need more input images.

ERR_HOMOGRAPHY_EST_FAIL = 2: This error occurs when the RANSAC uniprocity estimation fails. Again, you may need more input images, or the provided images do not have enough features to accurately match the key points.

ERR_CAMERA_PARAMS_ADJUST_FAIL = 3: Usually related to failure to correctly estimate camera features based on the input image.

For your case, you can

add more input images to detect enough keypoints, or you can look at your implementation.

Related Problems and Solutions