Ask Your Question

Stitcher module errors

asked 2012-09-16 23:27:41 -0500

zenberg gravatar image

I'm trying to use the OpenCV Stitcher Module on iOS to stitch two photos into one.

Here's my code:

- (UIImage *)stitchImages
    cv::Stitcher stitcher = cv::Stitcher::createDefault(TRUE);

    cv::Mat img1 = [openCVUtil cvMatWithImage:[UIImage imageNamed:@"1.jpg"]];
    cv::Mat img2 = [openCVUtil cvMatWithImage:[UIImage imageNamed:@"2.jpg"]];

    cv::vector<cv::Mat> images;

    cv::Mat imgOut;
    cv::Stitcher::Status status = stitcher.composePanorama(images, imgOut);
    if(status == cv::Stitcher::Status::OK) {
        UIImage *outImg = [openCVUtil imageWithCVMat:imgOut];
        return outImg;
    return nil;

At the end I'm getting this error:

OpenCV Error: Assertion failed (imgs.size() == imgs_.size()) in composePanorama

Can you please explain what am I doing wrong?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2012-09-17 03:42:11 -0500

Alexey Spizhevoy gravatar image

updated 2012-10-02 05:43:38 -0500

V.G. gravatar image


You should use the method stitch instead. The method composePanorama composes images under assumption that motions between the images were estimated earlier using the method estimateTransform. See the stitching module docs.


edit flag offensive delete link more


Thank you for your help! I made changes and got this error:

Finding features... OpenCV Error: Assertion failed (image.type() == CV_8UC3) in find, file /Users/user/slave/ios_framework/src/opencv/modules/stitching/src/matchers.cpp, line 351

Maybe I should change something in my function that converts UIImage to cv::Mat?

zenberg gravatar imagezenberg ( 2012-09-17 10:42:44 -0500 )edit

One possible way to convert 4-channel image into 3-channel one is to use the function cvtColor. It's mainly used to convert images between color spaces, but it also supports CV_RGBA2RGB flag.

Alexey Spizhevoy gravatar imageAlexey Spizhevoy ( 2012-09-17 11:01:49 -0500 )edit

Thanks again. I wanted to paste the code in my previous message, but unfortunately there's a character limitation in comments, so I decided to paste it to another resource and give you the link.

Can you please help me to understand what's wrong with it?

zenberg gravatar imagezenberg ( 2012-09-18 10:24:02 -0500 )edit

You're trying to process 4-channel images, when only 3-channel images are supported. That's what you're doing wrong. See above a possible solution.

Alexey Spizhevoy gravatar imageAlexey Spizhevoy ( 2012-09-18 11:03:15 -0500 )edit

Thank you very much!

Can you please help me with this one as well?

zenberg gravatar imagezenberg ( 2012-09-21 00:41:44 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2012-09-16 23:27:41 -0500

Seen: 1,758 times

Last updated: Oct 02 '12