2

I am trying to stitch a panorama using mobile phone camera with an attachable 170 degree wide angle lens. The resulting photo is distorted (fisheye). I understand that to stitch these photos using Stitcher::stitch(InputArrayOfArrays images, OutputArray pano) they must be undistorted first.

First, I did the undistort(InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray newCameraMatrix=noArray() ) and save the results to jpg files. Then, I read the jpg images, stitched them to be a panorama image and this worked well.

Next, I joined the process into a single process. So I did not save the undistorted image, but keep them in cv::Mat and use it as the stitcher input. This one fails with error code ERR_NEED_MORE_IMGS.

My question is, why does it work if the stitcher input (ImgArray) comes from imread, but fails if the input comes directly from undistort output? How to make the second case work?

//Load photo source (distorted)
Mat imageDistorted, imageUndistorted;
vector<Mat> ImgArray;

for (int p=1; p<=6; p++){
    imageDistorted = imread( "/file1.jpg" ); //read file2, file3, ...
    if(imageDistorted.data){
        undistort(imageDistorted, imageUndistorted, camVariables, distCoeffs);

        ImgArray.push_back( imageUndistorted );

    }
}

//Apply Stitching algorithm
Mat panoImg;
Stitcher stitcher = Stitcher::createDefault();

Stitcher::Status status = stitcher.stitch(ImgArray, panoImg);
Kevin
  • 311
  • 1
  • 7
  • Stitcher returns ERR_NEED_MORE_IMGS when it can't find enough features in images to connect them. Saving images as jpegs certainly can add some features by degrading quality, so there is a potential reason for that weird behavior. – Ap31 Sep 26 '16 at 09:24

0 Answers0