Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problems using Stitcher::stich

Hello.

I'm trying to use Stitcher::Status as this example:

vector<Mat> imgs;
// I add images...
Mat pano;
Stitcher stitcher = Stitcher::createDefault(false);
Stitcher::Status status = stitcher.stitch(imgs, pano);
cout << endl << status << endl;

The printed result is "0". But I get a 1x1 black pixel image.

Sometimes, if I remove one image from the vector<Mat> I get a result, but if I add more it doesn't work.

I'm taking pictures as panorama, but with createPanorama I get an Assertion error:

imgs.size() == imgs_.size()

What am I doing bad? Thank you.

Problems using Stitcher::stich

Hello.

I'm trying to use Stitcher::Status as this example:

vector<Mat> imgs;
// I add images...
Mat pano;
Stitcher stitcher = Stitcher::createDefault(false);
Stitcher::Status status = stitcher.stitch(imgs, pano);
cout << endl << status << endl;

The printed result is "0". But I get a 1x1 black pixel image.

Sometimes, if I remove one image from the vector<Mat> I get a result, but if I add more it doesn't work.

I'm taking pictures as panorama, but with createPanorama I get an Assertion error:

imgs.size() == imgs_.size()

What am I doing bad? Thank you.

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]