I tried to use the stitcher module in opencv to stitch images. Below is my code(core part).
int main() {
Mat img1 = imread("5.jpg");
Mat img2 = imread("6.jpg");
//Mat img3 = imread("11.jpg");
imgs.push_back(img1);
imgs.push_back(img2);
//imgs.push_back(img3);
Mat pano; // Mat to store the output pano image
Stitcher stitcher = Stitcher::createDefault(try_use_gpu); // create a Stitcher object
Stitcher::Status status = stitcher.stitch(imgs, pano); // stitch the input images together
cout << "hello" <<endl;
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << int(status) << endl;
return -1;
}
imshow("pano",pano);
imwrite(result_name, pano); // write the result to the output image
waitKey(0);
return 0;
}
"imgs" in the code above is a vector of Mat type. I saw a lot of similar codes as this in the net but I don't know why my code has a big limitation on the size of the input images. If the input images size is around 800600, it works well. But when the size is 650650 or 1280*640 or something else, the console prompt will just close very soon after the program ends. And not any images are saved on "panoResult.jpg". Also not any image is displayed. The visual studion 2010 is just displaying "Image_stitching2.exe: Native' has exited with code -1 (0xffffffff)." when I am debuging.
Can anyone helps with this? I really need to get progress on this since I have already spent several hours to fix it but just not correct. Any tips or help is great for me.
Thank you very much.