0

I've started to learn OpenCV two weeks ago, so don't be too harsh.

I have two high-resolution images with a nearby 30% overlap. The first photo is rotated relative to the second and transformed (photos from different angles). I need to make one combined image.

I decided to use KeyPoints to find the same areas in different images. I used the BRISK detector. After detecting I used KeyPointsFilter::retainBest() function to left only 1000 the best areas. After that, I computed descriptors and using DescriptorMatcher::create(DescriptorMatcher::BRUTEFORCE) function matched all the descriptors. But I've got too many different matches. So Further I sorted all the matches and selected matches with prevailing shifting. Thus I've got about 100 KeyPoints that really match each other on different images (matching result got with drawMatches() function is shown below)

Matching result

But images are not just shifted. They are rotated and transformed, so I can't just use Mat::copyTo() function for merging two images into a new larger one, because there is no common shifting distance for all the keyPoints. Is there any function in OpenCV that can connect two images with preliminary angle transform?

Sweta Jain
  • 3,248
  • 6
  • 30
  • 50
  • See my answer here https://stackoverflow.com/questions/39938767/perspective-image-stitching/39945374 . It should give you enough hint on how to move forward – saurabheights Nov 24 '21 at 14:45
  • 1
    I believe your next step is to compute homography matrix(basically definies rotation and translation) to know where each pixel of image should move so that when you warp this image to a bigger image containing image2, image1 pixels lie along with image2 and properly stitched. Its a little mathematical, but this tutorial should do the job https://docs.opencv.org/4.x/d9/dab/tutorial_homography.html – saurabheights Nov 24 '21 at 14:49
  • The homography matrix was the thing I needed. All works. Thank you!) The last thing I need to do is to make correction of lens distortion. – Aleksey Lomako Nov 30 '21 at 06:13
  • Cool. u talking about radial/barrel distortion? Also, can I just drop 2 line answer with link to my other answer :D – saurabheights Nov 30 '21 at 12:37

0 Answers0