Ask Your Question
1

Creating a panorama from multiple images. How to reduce calculation time?

asked 2013-06-12 01:03:36 -0600

sakulm gravatar image

updated 2013-06-17 02:03:10 -0600

SR gravatar image

Hello everyone

Is there a possibility to reduce calculation time when stitching more than two images with opencv stitcher class? I noticed that it grows rather exponentially the more images I want to stitch (why?). Is it possible that opencv stitcher tries to stitch every single image with every other image because I got a defined order for stitching my images. So maybe this would be a way to reduce calculation time. I hope you understand what I mean and maybe you can give me some advice to solve my problem.

edit retag flag offensive close merge delete

Comments

1

Use ROI in stitcher.

nikkadim gravatar imagenikkadim ( 2013-07-19 13:53:50 -0600 )edit

2 answers

Sort by » oldest newest most voted
3

answered 2013-07-31 18:07:58 -0600

You have to use the setMatchingMask function. This function isn't in the documentation, but it's used when matching two images (see the below extracted from matcher.cpp

for (int i = 0; i < num_images - 1; ++i)
    for (int j = i + 1; j < num_images; ++j)
        if (features[i].keypoints.size() > 0 && features[j].keypoints.size() > 0 && mask_(i, j))
            near_pairs.push_back(make_pair(i, j));

Where mask_(i,j) is your mask set by setMatchingMask. If you successfully used this function, please create a pull request for the doc, it will help others...

edit flag offensive delete link more

Comments

Hmm it is crazy to see how much documentation should still be added :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-01 02:38:36 -0600 )edit

You can also look into the source of the stitcher and create your own that is using threads or similar (OpenMP, Boost etc.). The stitching pipeline actually offers plenty of space for optimization and right now I'm actually working on my thesis for stitching multiple aerial images together, georeferencing and orthorectifying them. For example in the registration stage you have 1)load image in cv::Mat container, 2)undistort using calibration matrix, 3)convert to grayscale, 4)resize to medium resolution and 5)find features. This routine is to be applied for each and every image (2 or N images for that matter). After that the matching process itself can be optimized for multiple images.

rbaleksandar gravatar imagerbaleksandar ( 2014-05-01 06:16:16 -0600 )edit
1

And here's an additional note I'd like to add: as for the stitcher itself be very careful what type of images you want to use it on. And with type I mean how the images were shot. The stitcher as it is right now presumes that the camera that has shot those has undergone pure rotation (rotation around it's own axis which is the case with wide-view panoramic pictures). If your images were shot using translation movement (as is my case with an UAV flying over an area and taking pictures, that is a parallel movement above the scene we shoot), the results will be really bad (talking from personal experience here).

rbaleksandar gravatar imagerbaleksandar ( 2014-05-01 06:21:47 -0600 )edit
Duffycola gravatar imageDuffycola ( 2014-07-30 06:13:24 -0600 )edit

I've read it along with a lot of others but thanks for the headsup. :)

rbaleksandar gravatar imagerbaleksandar ( 2014-08-01 05:24:58 -0600 )edit
0

answered 2014-05-01 06:05:42 -0600

damiannelus gravatar image

Hi, i've build simple stitching app with JavaCV. And as mentioned in opening question for this topic calculation time grows with number of images growth. Does author solved the problem and can share experience?

Following approaches comes to my mind: - dive into stitching algorithm and recreate stich method step by step with blocks delivered in jCV (or maybe openCV4Android). - with information about shift between images (from magnetic field sensor and accelerometer) i can compute partial panoramas, then partial panoramas can build bigger panorama and so on.

Do you have any other suggestions? What do you think about those suggested by me? Thanks for any answear and I'll be very grateful for every discussion.

edit flag offensive delete link more

Comments

Read my comment above :)

rbaleksandar gravatar imagerbaleksandar ( 2014-05-01 06:22:13 -0600 )edit

Let me please add the remark that JavaCV is not an official supported OpenCV package. It is a wrapper around the existing interface. OpenCV has his own Java interface of which you can find the docs here. So it would be better to address javaCV problems at the correct forum

StevenPuttemans gravatar imageStevenPuttemans ( 2014-05-02 03:34:01 -0600 )edit

Steven, i've noticed the difference and firstly asked my question in javacv mailing list from where i've been redirected here. Kind of circle ;-) But, as we speaking of differences between wrapper and interface. Is there in official OpenCV java's interface Stitcher class or does the full stitching pipeline need to be build step by step?

damiannelus gravatar imagedamiannelus ( 2014-05-02 08:01:07 -0600 )edit

The official java interface of OpenCV doesn't contain the C++ stitcher class as far as I know.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-05-02 08:03:12 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-06-12 01:03:36 -0600

Seen: 6,085 times

Last updated: May 01 '14