1

I'm trying to create kind of a panorama using the Stitcher::stitch function on OpenCV.

I take around 24 pictures to stitch them but the final result (Status = OK) is a 1x1 image (black pixel).

If I remove some of the images, it works OK but maybe I'm missing some parts of the image.

What am I doing bad? Thank you in advance.

Update:

I'm trying to add rois taking the 50% of every image. For the first image I take the right 50%. For the last, the left 50%, and for the rest I take 50% of left and 50% of right:

vector<Mat> imgs;
imgs.push_back(imread("/Users/myImages/IMG_0073.jpg"));
imgs.push_back(imread("/Users/myImages/IMG_0074.jpg"));
imgs.push_back(imread("/Users/myImages/IMG_0075.jpg"));
imgs.push_back(imread("/Users/myImages/IMG_0076.jpg"));
imgs.push_back(imread("/Users/myImages/IMG_0077.jpg"));
imgs.push_back(imread("/Users/myImages/IMG_0078.jpg"));

processImage(imgs);

and my function is:

void processImage(vector imgs){

vector<vector<Rect>> rois;
vector<Rect> roisVect;
for (int j = 0; j < imgs.size(); j++) {
    if (j == 0) {
        Rect rect1 = Rect(imgs.at(j).cols*50/100, 0, imgs.at(j).cols*50/100,imgs.at(j).rows);
        roisVect.push_back(rect1);
        rois.push_back(roisVect);
        
        roisVect.clear();
    } else if (j == imgs.size() - 1) {
        Rect rect2 = Rect(0, 0, imgs.at(j).cols*50/100, imgs.at(j).rows);
        roisVect.push_back(rect2);
        rois.push_back(roisVect);
        
        roisVect.clear();
    } else {
        Rect rect3 = Rect(imgs.at(j).cols*50/100, 0, imgs.at(j).cols*50/100, imgs.at(j).rows);
        Rect rect4 = Rect(0, 0, imgs.at(j).cols*50/100, imgs.at(j).rows);
        roisVect.push_back(rect4);
        roisVect.push_back(rect3);
        rois.push_back(roisVect);
        
        roisVect.clear();
    }
    
}
Mat pano;
Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
Stitcher::Status status = stitcher.stitch(imgs, rois, pano);
cout << endl << status;
cout << endl << pano.size();
if (!pano.empty())
    imshow("pano", pano);
waitKey(10);

imwrite("/Users/myImages/final" + to_string(imgs.size()) + ".jpg", pano);

}

And my results (cout) are:

0 // (OK)

[1 x 1]

4

0 回答 0