0

I'm trying to do an image stitch using OpenCV by doing SIFT->KNN->warpPerspective. There are whole lot of resource on how to warp the image on the right to be stitched on to the destination on the left. I've tried calculating the homography matrix for warping left image to be stitched to the right and that seems to work. Problem is, I can't stitch the image together with cv2.warpPerspective since it seems to put the image in where it should be if the right side image is warped.

My code is basically:

result = cv2.warpPerspective(left, H, (left.shape[1] + right.shape[1], left.shape[0])
result[0:right.shape[0], result.shape[1]-right[1]:] = right

But this creates image offset shifted to the right. How could I stitch the images correctly?

1
  • Your problem as stated is not clear to me. Can you explain further and/or show a diagram or images.
    – fmw42
    Commented Dec 2, 2019 at 0:41

2 Answers 2

1

First you should resize the images and place them in a bigger image each with outer_x= image_x*5 and outer_y= image_y*3

outer_x= image_x*5
outer_y= image_y*3
result = cv.warpPerspective(left_image, H, (outer_x, outer_y))
result[:, x_img * 2 : x_img*3] = right_image[j][:, x_img * 2 : x_img*3]
1

Yes, it appears there are good number of resources to warp the image on the right to be stitched on to the destination on the left. However if we want to do the opposite of this i.e. transform the left image and stitch it to the image on the right, we can simply flip both the images then warp the image on the right to be stitched on to the destination on the left and then can flip the result back. This will be then equivalent to transform the left image and stitch it to the image on the right.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.