Aligning and stitching images based on defined feature using OpenCV [closed]

asked 2017-05-16 12:00:20 -0600

bprodz gravatar image

I would like to create a panoramic image by combining 2 images in which the same feature, a plus sign.

I've used cv2.xfeatures2d.SIFT_create() to find keypoints in the image however it doesn't find the plus symbol very well. Is there some way I can improve this by making it search specifically for a plus-shaped feature?

import cv2

image1 = cv2.imread('example_image.png')
sift = cv2.xfeatures2d.SIFT_create()
kp = sift.detect(grey_image1, None)
kp_image = cv2.drawKeypoints(grey_image1, kp, None)

def showimage(image, name="No name given"):
    cv2.imshow(name, image)
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    return

showimage(kp_image)

The source image is here, second image to align is here. Here is the resulting image from the code above. This is an example of the desired output made using GIMP and manually aligning the two images (the second image will need to transformed to fit properly).

NB I'm open to using other approaches outside of OpenCV/Python to solve this problem.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-11-11 09:10:21.812720

Comments

you can use this post but it is in C++

LBerger gravatar imageLBerger ( 2017-05-17 00:24:39 -0600 )edit

however it doesn't find the plus symbol very well.

Have you tried to perform image registration? The code you provided is just a detector output. You have a small, yet sufficient number of feature points describing the plus sign. Were you able to detect keypoints on the second image and align them together? (use the function cv2.drawMatches() to see which keypoint match in a pair of images).

DaePa gravatar imageDaePa ( 2017-05-25 15:50:36 -0600 )edit