androidopencvhomographyimage-stitching

Opencv4Android,stitching two images


I have to stitch two images and I use openCV4Android.I read docs and some threads in about stitching images,for example: Panorama – Image Stitching in OpenCV , Homography between images using OpenCV for Android , Stitch multiple images , Error matching with ORB in Android and others.At first,it seems easy.But the result is strange!Below,you can see two images that I used for test and result:

Here is "image1":

enter image description here

This is "image2":

enter image description here

You can see drawed features:

enter image description here

And this is result of warping image1:

enter image description here

What I did wrong?Or it may be I did not understand good?


Solution

  • Quick answer:

    I would say that you don't have enough overlap between your images. If you look at your matches (what you call "drawed features"), most of them are wrong. As a first test, try to stitch two images that have, say, 80% overlap.

    More details:

    Big picture:

    When you stitch two images, you assume that there exists an affine transform (your "homography") that will project features from one image onto the other one. When you know this transform, then you know the relative position of your images and you can "put them together". If the homography transform that you find is bad, then the stitching will be bad as well.

    How do we find the homography transform, then?

    But why doesn't it work here?

    If you look at your "drawed features", you will see that only a few ones on the "Go" part of "Google" and some in the boorkmarks correspond, when the others are wrong. It means that most of your matches are bad, and then it makes it possible to find a homography that works for this data, but that is wrong.

    In order to have a better homography, you would need much more "good" matches. Consequently, you probably need to have more overlap between your images.

    NOTE: try your code with the images used in "Panorama – Image Stitching in OpenCV"