Ask Your Question

OpenCV Machtching Feature

asked 2013-05-15 04:12:25 -0600

NightLife gravatar image

updated 2013-05-15 04:29:42 -0600

The function matcher(features, pairwise_matches) in OpenCV, suppose that the input images are not in order, so it tries to find the right order by processing the features and compare one image with others.

It waste too much time for many input images like 20. The pairwise_matches is 400 for 20 input images. I want to insert the images in the right order to avoid comparing one with all others (just with the next one and reduce the pairwise_matches from 400 to 19 !!!).

How can I implement it?!!

Thanks in Advance

edit retag flag offensive close merge delete



Uhm, what? Input images in "order"? How would you order images? Do you mean you want to align them? And what is the real problem? Put them in order and then loop over them to create the pairwise_matches. Changing a loop from brute force comparing images to only comparing with the next one shouldn't be a problem.

Notas gravatar imageNotas ( 2013-05-15 07:05:14 -0600 )edit

Hi Notas,

Maybe my question is not clear, but as you said, I need to compare the image just with the next image. I am confused right now. Would you please tell more in detail.

NightLife gravatar imageNightLife ( 2013-05-15 13:52:50 -0600 )edit

It is not clear what exactly your problem is. The ordering (again, order them in which way?) or the matching of one image with the other. Because the last one is trivial because all you need to do is find keypoints and match them.

Notas gravatar imageNotas ( 2013-05-15 16:32:48 -0600 )edit

Dear Notas,

About Ordering:

When the images are applied to the "stitching_detailed.cpp" as the arguments, the "matcher(features, pairwise_matches)" function try to find matches between all images and choose the best mached image for image number x. This procedure is done for all input images(compare it with all other input images to find the best match).

I know that each input image in my algorithm has the best match with the image in next, I mean "image i" with "image i+1" and so on. So I want to skip comparing "image i" with all images except "image i+1". Because I know that they are in right order(The photos sequentially taken) the best matches for each image is the next one, so it is not neccessary to compare it with all inputs. It is exactly the problem that I have.

NightLife gravatar imageNightLife ( 2013-05-16 00:01:18 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-03-04 01:25:37 -0600

Dhaval Kriplani gravatar image

vector<matchesinfo> pairwise_matches;
BestOf2NearestMatcher matcher(false, 0.3f);

Mat matchMask(features.size(),features.size(),CV_8U,Scalar(0));
for (int i = 0; i < num_images -1; ++i)<char>(i,i+1) =1;

matcher(features, pairwise_matches, matchMask);

Replace this code in your stitching_detailed.cpp and you'll be able to perform linear pairwise matching, as you already know the sequence of images.

edit flag offensive delete link more

Question Tools


Asked: 2013-05-15 04:12:25 -0600

Seen: 468 times

Last updated: Mar 04 '17