Ask Your Question
1

Stitcher module errors

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

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;
    images.push_back(img1);
    images.push_back(img2);

    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
2

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

Alexey Spizhevoy gravatar image

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

V.G. gravatar image

Hi,

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.

Alexey

edit flag offensive delete link more

Comments

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 -0600 )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 -0600 )edit
1

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?

http://pastebin.com/TPZKHhP5

zenberg gravatar imagezenberg ( 2012-09-18 10:24:02 -0600 )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 -0600 )edit

Thank you very much!

Can you please help me with this one as well? http://answers.opencv.org/question/2474/roi-errors-and-the-stitcher-module/

zenberg gravatar imagezenberg ( 2012-09-21 00:41:44 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 2,193 times

Last updated: Oct 02 '12