Ask Your Question
0

knnMatch() returning strange match counts and indices

asked 2013-11-05 08:34:45 -0600

Kika gravatar image

updated 2013-11-06 03:01:29 -0600

In the match object populated by knnMatch() (K=1, either unique or not) I get strange pattern of match counts for each entry returned - the counts order is typically [x, y, 7, 8, x, y, 7, 8, ...] (x/y typically 0 or 1 which make sense). Once in a while wild numbers (e.g. 8521267) are set there.

In addition, the indices of the first matches are also often wild numbers, built from 0xEEEEEEEE/0xABABABAB/0xCDCDCDCD, which seem to indicate they point to some wrong heap areas.

I include a snapshot of the compact returned values from VS 2012 and the test code I used, still before meaningful code has been run.

Hope someone can explain this, point to something wrong I did, or is that a real bug? Any workaround in this case?

I was also suspecting a possible incompatibility between STL versions between my build and the OpenCV library, but I didn't see such issues when searching.

This happens with 2.4.6

--- Returned values ---
-       matches { size=128 }    ::vector<std::vector<cv::DMatch,std::allocator<cv::DMatch> >,std::allocator<std::vector<cv::DMatch,std::allocator<cv::DMatch> > > >
        [size]  128 __int64
        [capacity]  128 __int64
+       [0] { size=1 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [1] { size=1 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [2] { size=7 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [3] { size=8 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [4] { size=1 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [5] { size=1 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [6] { size=7 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [7] { size=8 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [8] { size=1 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [9] { size=1 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [10]    { size=7 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [11]    { size=8 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [12]    { size=0 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [13]    { size=0 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [14]    { size=7 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [15]    { size=8 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [16]    { size=1 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [17]    { size=1 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [18]    { size=7 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [19]    { size=8 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [20]    { size=0 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [21]    { size=1 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [22]    { size=7 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [23]    { size=8521267 }    std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [24]    { size=0 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
+       [25]    { size=1 }  std::vector<cv::DMatch,std::allocator<cv::DMatch> >
...
 
--- Test Function (based on sample code) ---

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2 ...
(more)
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
-1

answered 2013-11-05 09:56:31 -0600

Moster gravatar image

Its for sure related to crosscheck that you have enabled in one of your BFMatchers. I had the same issue

http://answers.opencv.org/question/17895/bfmatcher-crosscheck/

edit flag offensive delete link more

Comments

I think your case is different - cross-check is eliminating some results so indeed it causes empty entries. In my case the entries that are not empty also contain garbage - except for some that contain 1 match.
Beyond that I get 7/8/plenty matches (in that strange pattern) for many keypoints while I asked for up to one match. And the same happens for that knnMatch() call also without cross-check.

Kika gravatar imageKika ( 2013-11-05 20:11:40 -0600 )edit

Question Tools

Stats

Asked: 2013-11-05 08:34:45 -0600

Seen: 776 times

Last updated: Nov 06 '13