Stitcher Error Message Assistance

asked 2019-06-18 11:52:31 -0500

gambret gravatar image


I'm still working on the Stitcher code where I have two images, and I am trying to combine them into one. My code is below:

Stitcher::Mode mode = Stitcher::PANORAMA;
string result_name = "C:\\OpenCV\\opencv4\\bin\\Debug\\result.png";
Mat stitchImages(Mat one, Mat two);
Mat readImageFromFile(string fileName);

int main(int argc, char* argv[])
 Mat img1 = readImageFromFile("C:\\OpenCV\\opencv4\\bin\\Debug\\rs-save-to-disk-output1-Depth.png");
 Mat img2 = readImageFromFile("C:\\OpenCV\\opencv4\\bin\\Debug\\rs-save-to-disk-output2-Depth.png");
 if (img1.empty() || img2.empty()) {
    cout << "Cannot read files" << endl;
    return 1;
Mat stitchedImages = stitchImages(img1, img2);
imwrite(result_name, stitchedImages);
Mat stitchImages(Mat one, Mat two) {
    vector<Mat> Mats{ one, two };
    cout << "Mats size" << Mats.size() << endl;
    Mat result;
    Ptr<Stitcher> stitcher = Stitcher::create(Stitcher::PANORAMA);// SCANS);
    Stitcher::Status status = stitcher->stitch(Mats, result);
    if (status != Stitcher::OK)
        switch (status) {
        case Stitcher::Status::ERR_CAMERA_PARAMS_ADJUST_FAIL:
            cout << "Error is ERR_CAMERA_PARAMS_ADJUST_FAIL" << endl;
        case Stitcher::Status::ERR_HOMOGRAPHY_EST_FAIL:
            cout << "Error is ERR_HOMOGRAPHY_EST_FAIL" << endl;
        case Stitcher::Status::ERR_NEED_MORE_IMGS:
            cout << "Error is ERR_NEED_MORE_IMGS" << endl;
            cout << "Can't stitch images, error code = " << int(status) << endl;

    return result;
Mat readImageFromFile(string fileName) {
return imread(fileName);

The code compiles, and I see the result file in the folder that I designated, but there's nothing in the file. I'm able to see a few issues through the VS debug console, but I am unsure how to proceed with this information.

Can anyone provide assistance for tackling these errors?

Error is ERR_NEED_MORE_IMGS Can't stitch images, error code = 1 libpng warning: Image width is zero in IHDR libpng warning: Image height is zero in IHDR libpng error: Invalid IHDR data

Thank you for your help.

edit retag flag offensive close merge delete



your code runs as it should be. and the message is obvious.

sturkmen gravatar imagesturkmen ( 2019-06-18 14:14:19 -0500 )edit

Hey, thanks!

gambret gravatar imagegambret ( 2019-06-18 15:33:55 -0500 )edit