0

I'm using OpenCV 2.4 to convert a video into a long (narrow) mosaic. This is my first time using OpenCV, but so far I've managed the following with some success:

  1. Get frames from video.
  2. Get keypoint descriptors using SIFT.
  3. Sort out the outliers using RANSAC
  4. Find the homography matrix.

The issue is when I apply the homography matrix to one of the frames/images and try and generate the mosaic. Sometimes I get an error complaining that the size of the destination matrix for warpPerspective() is too small. To get around this I guess an overly large size to make sure the result fits in. However, after a copy of frames have been joined together I have a huge image which is mostly black. So my question is, how can I do this in a smart way? How can I calculate the size of the destination matrix I'll need for the mosaic BEFORE I pass it to warpPerspective()? I've been trying things with ROI/Rect but I'm not really sure what I'm doing with that.

If you have any suggestions I'd be eternally grateful.

  • When exactly does warpPerspective say the size is too small? It is capable of warping an image into a matrix which is not large enough to completely hold the image. [Here](http://stackoverflow.com/a/12293128/852487) is an example (see image at bottom of answer) – Hammer Oct 22 '12 at 22:37
  • Adding more specific information would be helpful. A screenshot, a small specific piece of code that illustrates your problem ect. – Hammer Oct 22 '12 at 22:38
  • Why don't you use the stitching module in OpenCV? – Sam Oct 23 '12 at 07:15

1 Answers1

1

apply the homography matrix to points representing the extremeties of your image frame: (0,0,1); (w,0,1) etc. These will give you the bounds of your new image.

Owen
  • 31
  • 2