SIGABRT error when attempting basic panorama stitching with openCV

I’m trying to stitch two images together with the stitcher class in ofxOpenCv and also using ofxCv.

I load in 2 images and convert them to OpenCV data with toCv() in ofxCv. I then push the Mat into a vector and then attempt to stitch.

The issue is that I get a SIGABRT error on the line below:

cv::Stitcher::Status status = stitcher.stitch(imgs, pano);

The error:

OpenCV Error: Assertion failed (ssize.area() > 0) in resize, file /Users/danielrosser/Documents/openFrameworks/scripts/apothecary/build/opencv/modules/imgproc/src/imgwarp.cpp, line 1834
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /Users/danielrosser/Documents/openFrameworks/scripts/apothecary/build/opencv/modules/imgproc/src/imgwarp.cpp:1834: error: (-215) ssize.area() > 0 in function resize

Not too sure what I’m doing wrong with the implementation maybe need to do something else with the second argument in the line I get the error on.

Any help would be great!

See below for the code.

void ofApp::setup(){
    
    image1.load("i_1.JPG");
    image2.load("i_2.JPG");
    
    image1.setImageType(OF_IMAGE_COLOR);
    image2.setImageType(OF_IMAGE_COLOR);
    
    Mat mImage1 = toCv(image1);
    Mat mImage2 = toCv(image2);
    
    imgs.resize(2);
    
    imgs.push_back(mImage1);
    imgs.push_back(mImage2);

}

//--------------------------------------------------------------
void ofApp::update(){
    
ofSetWindowTitle(ofToString(ofGetFrameRate()));

}

//--------------------------------------------------------------
void ofApp::draw(){
    
    ofSetColor(255);
    
    bool try_use_gpu = false; //true; //
    cv::Stitcher stitcher = cv::Stitcher::createDefault(try_use_gpu);
    cv::Stitcher::Status status = stitcher.stitch(imgs, pano);
    

    if (status != cv::Stitcher::OK){
        cout << "Can't stitch images, error code = " << status << endl;
        
    }
    
    for(int i=0;i< 2;i++){
        drawMat(imgs[i], i*500, 0);
        }
    
    ofSetColor(255);
    drawMat(pano, 0, 400);
}

Relevant h file stuff:

 #include "../../../addons/ofxOpenCv/libs/opencv/include/opencv2/stitching/stitcher.hpp"
    
 vector<cv::Mat> imgs;
 cv::Mat pano;
 ofImage image1, image2;
 vector<ofImage> img2;

Bit of a silly mistake.

The line: imgs.resize(2); caused the size of imgs to equal 4 after the images below were pushed into it. I had thought I was just sizing it to 2.

So removing imgs.resize(2); resolves issue.