androidimageopencvhomography

OpenCV,Warp images by Homography matrix


I followed Panorama – Image Stitching in OpenCV to do same task on Android,by using openCV4Android.My problem is in about warping image by founded homography matrix.I tested these images:

image1:

enter image description here

image2:

enter image description here

Result of warping image1 by founded homography is:

enter image description here

You can see that result is good warped but first part of that(left side) is cut! So stitching result was:

enter image description here

And result of above images in referenced link page,is:

enter image description here

Why warping by homography cut that?Or may be I did some things wrong?


Solution

  • OK! Finally I could solve the problem.I saw this answer and understand what causes this problem and how I can solve that:

    The problem occurs because the homography maps part of the image to negative x,y values which are outside the image area so cannot be plotted. what we wish to do is to offset the warped output by some number of pixels to 'shunt' the entire warped image into positive coordinates(and hence inside the image area)...So just premultiply your homography by a matrix similar to the above, and your output image will be offset.