简体   繁体   English

缝合器的OpenCV断言失败

[英]OpenCV Assertion Failed with Stitcher

I'm writing a program that takes a video as input and return a panorama image. 我正在编写一个将视频作为输入并返回全景图像的程序。 I'm executing this code: 我正在执行以下代码:

vector< Mat > vImg;
Mat rImg;
Mat img;



VideoCapture cap("../Debug/vid/vid.avi");

if (!cap.isOpened())
{
    cout << "Can't open video";
    waitKey(0);
    return ;
}


//default stitcher
Stitcher stitcher = Stitcher::createDefault(true);

//set orb finder
Ptr<FeaturesFinder> finder=new OrbFeaturesFinder();
stitcher.setFeaturesFinder(finder); 

//set seam resolution
stitcher.setSeamEstimationResol(0.08);

//set confidence threshold
stitcher.setPanoConfidenceThresh(0.5);

//set warper
Ptr<WarperCreator> warper = new cv::PlaneWarper();
stitcher.setWarper(warper);

//set exposure compensation
Ptr<ExposureCompensator> exposure_compensator = ExposureCompensator::createDefault(ExposureCompensator::GAIN);
stitcher.setExposureCompensator(exposure_compensator);


//set seam finder
Ptr<SeamFinder> seam_finder = new DpSeamFinder(DpSeamFinder::COLOR_GRAD);
stitcher.setSeamFinder(seam_finder);

//set matcher
Ptr<FeaturesMatcher> matcher = new BestOf2NearestMatcher(true);
stitcher.setFeaturesMatcher(matcher);


//sett wave correction
stitcher.setWaveCorrection(true);

cap >> img;
vImg.push_back(img);
vImg.push_back(img);    



int counter = 1;



while (counter < total_frames)
{

    Mat img_loop;

    cap >> img_loop;


    vImg.at(1) = img_loop;



    stitcher.stitch(vImg, rImg);


    if (rImg.rows>0 && rImg.cols>0)
    {
        imshow("debug", rImg);      


        vImg.at(0) = rImg;
    }



    rImg = NULL;


    counter ++;

}

but it gives to me the "Assertion Failed (dims <=2 && data ...)" error. 但它给我“断言失败(尺寸<= 2 &&数据...)”错误。 What the problem could be? 可能是什么问题?

I'm using visual studio 2013 community, opencv 2.4.10 and windows 7 x64 我正在使用Visual Studio 2013社区,OpenCV 2.4.10和Windows 7 x64

EDIT Added the "call stack" 编辑添加了“调用堆栈”

    KernelBase.dll!_RaiseException@16() 
Unknown>        msvcr120d.dll!_CxxThrowException(void *pExceptionObject, const_s__ThrowInfo * pThrowInfo) Riga 154  C++
    opencv_core2410d.dll!774ec7f8() Sconosciuto

EDIT I notice that if I stitch 2 identical images it gives me error. 编辑我注意到,如果我缝合2个相同的图像,它将给我错误。 It is normal? 这是正常的?

If the problem is about memory allocation, You can try to declare your vector as a static. 如果问题与内存分配有关,则可以尝试将向量声明为静态。

static vector<Mat> vImg;

I am not sure about that but i faced this problem while allocating huge array and this trick solved my problem instead of using pointers. 我不确定,但是我在分配巨大数组时遇到了这个问题,这个技巧解决了我的问题,而不是使用指针。

I hope it helps. 希望对您有所帮助。

I resolved implementing manualing the stitching pipeline. 我决定实施手动缝合线。 Thanks to you all! 谢谢大家!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM