2016-04-29 165 views
1

我正在嘗試使用OpenCV拼接器編寫代碼來拼接一組圖像,並不斷提出這個錯誤。OpenCV拼接器拋出調整大小錯誤

OpenCV Error: Assertion failed (dsize.area() > 0 || (inv_scale_x > 0 && inv_scale_y > 0)) in cv::resize, file C:\Users\car4p\Downloads\opencv-master\opencv-master\modules\imgproc\src\imgwarp.cpp, line 3230

我已經搜索周圍,發現這不是閱讀圖像的問題,圖像都顯示正常,並有超過0 cols。我相信輸出有錯誤,但無法弄清楚如何修復它。如果有人已經處理過這個或知道解決方案,將不勝感激。

我寫在C++中,sticher類使用的OpenCV 3.1和Visual Studio 2015年

代碼讀取圖像

imgs.push_back(imread("testerer1.jpg")); 
imgs.push_back(imread("testerer2.jpg")); 
imgs.push_back(imread("testerer3.jpg"));  
imgs.push_back(imread("testerer4.jpg")); 

代碼拼接圖像

Mat stitchImages(vector<Mat> imgs) { 
    Stitcher stitchs; 
    vector<Mat> stitchedImg; 

    stitchs.createDefault(false); 

    Stitcher::Status status = stitchs.stitch(imgs, stitchedImg); 

    return stitchedImg[0]; 
} 
+0

請花時間輸入或複製/粘貼代碼(我的計數正好是8行)。不要將文本和/或代碼作爲圖像發佈。 – Sabuncu

+0

非常感謝。這是我的第一篇文章,我非常感謝幫助。我已經正確地添加了代碼,現在對於給您帶來的不便表示抱歉。 – Car4p17

+0

謝謝,看起來不錯。你見過這個:http://stackoverflow.com/questions/31996367/opencv-resize-fails-on-large-image-with-error-215-ssize-area-0-in-funct - 如果你有,它沒有幫助,請在你的問題中提及它。 – Sabuncu

回答