Ask Your Question
0

get this error " error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow' " while implementing image stitching

asked 2018-12-29 03:43:03 -0600

Allaye gravatar image

updated 2018-12-31 09:36:49 -0600

int main() { try { bool try_use_gpu = false; vector<mat>imgs; Mat pano; imgs.push_back(imread("newyork1.jpg")); imgs.push_back(imread("newyork2.jpg"));

    //Stitcher::Mode mode = Stitcher::PANORAMA;
    //Ptr<Stitcher> stitcher = Stitcher::create(mode, try_use_gpu);
    Stitcher stitcher = Stitcher::createDefault(try_use_gpu);
    Stitcher::Status status = stitcher.stitch(imgs, pano);

    if (status != Stitcher::OK)
      cout << "Panorama unsuccessful" << endl;
    else {
    imshow("panorama", pano);
    waitKey(0);
    imwrite("panoramaimg.jpg", pano);
        return 0;
    }

i think there might be a problem with my image , any help pls

image description

image description

edit retag flag offensive close merge delete

Comments

please check image path ::

Mat img=imread("newyork1.jpg");
if (img.empty())
{
    cout <<"Check image path");
    return -1;
}
imgs.push_back(img);
img=imread("newyork2.jpg");
if (img.empty())
{
    cout <<"Check image path");
    return -1;
}
imgs.push_back(img);
LBerger gravatar imageLBerger ( 2018-12-29 06:11:37 -0600 )edit

checking the image, works well, there is nothing wrong with the reading of the images, it seems it is my implementation of my panorama

Allaye gravatar imageAllaye ( 2018-12-31 08:32:18 -0600 )edit

@Allaye webserver does not like your image http://answers.opencv.org/upfiles/154...

my browser firefox doesn't like your image but edge likes it @berak in firefox I can sse :

image description

LBerger gravatar imageLBerger ( 2018-12-31 09:41:51 -0600 )edit

don't understand you pls

Allaye gravatar imageAllaye ( 2018-12-31 09:47:55 -0600 )edit
1

okay, that means you have found a way around it right?

Allaye gravatar imageAllaye ( 2018-12-31 10:02:16 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-12-31 08:46:00 -0600

LBerger gravatar image

updated 2018-12-31 08:54:03 -0600

this code works with my image :

    vector<Mat> imgs;
    Mat img = imread("f:/images/pano/pano1.jpg");
    if (img.empty())
    {
        cout << "Check image path";
        return -1;
    }
    imgs.push_back(img);
    img = imread("f:/images/pano/pano2.jpg");
    if (img.empty())
    {
        cout << "Check image path";
        return -1;
    }
    imgs.push_back(img);

    Mat pano;
    Ptr<Stitcher> stitcher = Stitcher::create();
    Stitcher::Status status = stitcher->stitch(imgs, pano);

    if (status != Stitcher::OK)
    {
        cout << "Can't stitch images, error code = " << int(status) << endl;
        return EXIT_FAILURE;
    }
    //![stitching]
    imshow("r", pano);
    waitKey();

you can find a full example here

Image are here http://answers.opencv.org/question/18...

edit flag offensive delete link more

Comments

AM still having the same error with the code

Allaye gravatar imageAllaye ( 2018-12-31 09:03:32 -0600 )edit
1

can it be the image am using?

Allaye gravatar imageAllaye ( 2018-12-31 09:05:11 -0600 )edit

copy my images in your disk and run my code : it works! Now what is your platform and opencv version?

LBerger gravatar imageLBerger ( 2018-12-31 09:06:07 -0600 )edit

it worked, am using an opencv(4.0) intel 8th gen i7

Allaye gravatar imageAllaye ( 2018-12-31 09:11:33 -0600 )edit

so now that the image is the problem, what was the cause pls

Allaye gravatar imageAllaye ( 2018-12-31 09:12:07 -0600 )edit

try : stitcher->setPanoConfidenceThresh(stitcher->panoConfidenceThresh()/2) before stitcher->stitch(imgs, pano);

LBerger gravatar imageLBerger ( 2018-12-31 09:17:57 -0600 )edit

the error is still there

Allaye gravatar imageAllaye ( 2018-12-31 09:27:07 -0600 )edit

can you insert images in your questions?

LBerger gravatar imageLBerger ( 2018-12-31 09:27:59 -0600 )edit

okay have done that

Allaye gravatar imageAllaye ( 2018-12-31 09:37:08 -0600 )edit
1

I think you cannot stitch those images (or it's very difficult) I cannot find common point between thoses images

LBerger gravatar imageLBerger ( 2018-12-31 10:02:14 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-12-29 03:43:03 -0600

Seen: 673 times

Last updated: Dec 31 '18