stitcher::stitch black output [closed]
I'm trying to use stitcher::stitch to stitch two images. I have tested my code with many images, but each time the output image is just a black image. The code that I have put together is:
#include <stdio.h>
#include <iostream>
#include "opencv2/stitching.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/xfeatures2d/nonfree.hpp"
#include "opencv2/xfeatures2d.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
using namespace cv;
using namespace cv::xfeatures2d;
int main() {
Mat imageNow;
std::vector<Mat> myImages;
Mat im1 = imread("panorama_image1.jpg");
Mat im2 = imread("panorama_image2.jpg");
if (!im1.data || !im2.data) {
std::cout << "There was a problem reading one or more images." << std::endl;
return -1;
}
myImages.push_back(im1);
myImages.push_back(im2);
Stitcher stitcher = Stitcher::createDefault();
Mat myPanorama;
stitcher.stitch(myImages, myPanorama);
imwrite("myPanorama.jpg", myPanorama);
return 0;
}
Can anyone suggest an improvement? Thanks.
There is no problem with your program. Try :
Thanks @LBerger. I made the change you suggested, but it didn't change the result.
Of course but what is value in stdout (error number in stitcher class)?
I'm getting the stdout value 0.
Can you use this two images?
No the result does not change when I use those images. I am able to run a modified version (updated to OpenCV 3.0 syntax) of the code at that link (which of course doesn't use stitcher), but my code continues to generate a blank, black image.
What is your opencv version and your OS?
I'm running opencv 3.1.0 on OS X 10.11.4.
insert
and before Mat imagenow; :
That did the trick. Thank you.