使用拼接器模块拼接图像时的尺寸问题

时间:2013-10-29 05:10:48

标签: opencv image-stitching opencv-stitching

我尝试使用OpenCV中的缝合模块缝合图像。下面是我的代码(核心部分)。

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”是Mat类型的向量。

我在网上看到了很多类似的代码,但我不知道为什么我的代码对输入图像的大小有很大的限制。如果输入图像大小约为800 * 600,则效果很好。但是当尺寸为650 * 650或1280 * 640或其他尺寸时,控制台提示将在程序结束后很快关闭。并且没有图像保存在“panoResult.jpg”中。也没有显示图像。我正在调试时,Visual Studio 2010只显示Image_stitching2.exe: Native' has exited with code -1 (0xffffffff).

任何人都可以帮忙吗?我真的需要在这方面取得进展,因为我已经花了几个小时来修复它,但只是不正确。任何提示或帮助对我来说都很棒。

0 个答案:

没有答案
相关问题