2013-07-26 64 views
2

我嘗試使用合成全景無estimateTransform ... 它非常好與estimateTransform使用撰寫全景無estimateTransform

stitcher.estimateTransform(imgs); 
stitcher.composePanorama(pano); 

但我發現另一種方式來計算imagerotation等,這就是爲什麼我要使用composepanorama這樣的:

vector<Mat> imgs; 

imgs.push_back(image1); 
imgs.push_back(image2); 
imgs.push_back(image3); 
imgs.push_back(image4); 
imgs.push_back(image5); 
imgs.push_back(image6); 

stitcher.composePanorama(Inputimages,pano); 

但每次我TRIE這個我得到這個錯誤:

Error: Assertion failed (imgs.size() == imgs_.size()) in unknown function, file ......\src\opencv\modules\stitching\src\stitcher.cpp , line 128 

回答

1

如果你進入stitcher.cpp

Stitcher::Status Stitcher::composePanorama(InputArrayOfArrays images, OutputArray pano) 
{ 
    LOGLN("Warping images (auxiliary)... "); 

    std::vector<UMat> imgs; 
    images.getUMatVector(imgs); 
    if (!imgs.empty()) 
    { 
     CV_Assert(imgs.size() == imgs_.size()); 

因此,如果全球矢量imgs_沒有初始化,你會得到斷言錯誤。由於imgs_在初始化:

Stitcher::Status Stitcher::estimateTransform(InputArrayOfArrays images, const std::vector<std::vector<Rect> > &rois) 
{ 
    images.getUMatVector(imgs_); 

這就是爲什麼如果你不composePanorama之前調用estimateTransform你的代碼崩潰。