c++ - opencv DMatch imgIdx is greater than the size of the training set -
I have 1000 patterns (images that I want to see on a particular view), my current algorithm for each pattern descriptor Receives, stores them in vector and trains FlannbasedMatcher to use vector.
If I do a knnm with k = 3 then I match with an imgIdx> 1000, the cause of this question (I have k = 2 and the same problem), I Could not get anything, could someone give me a hand with this.
UPDATE: I was adding the pattern descriptor twice, that is why I was getting imgIdx above 1000, now I have the problem that k == 2
I get distance 0 and one with> 0, distance ratio is 0 and my theory is that I'm getting distance 0 because pattern matching is exactly like the scene, but when I do this without training, distance me 0 is not getting any ideas, why?
This is basically the code that I am running
const PTR & lieutenant; Flan :: Index Param & gt; & Amp; Index Mercury = New Flann :: KDTT Indipesparam (4); Constant PTR & lt; Flann :: SearchParams & gt; & Amp; SearchParons = New Flane :: SearchWithin (64); CV :: PTR & LT; CV :: DescriptorMatcher & gt; Matcher = new cv :: FlannBasedMatcher (index, search, perm); Matcher-> clear (); Std :: vector & lt; Anakin :: RichImg * & gt; * Pattern = loadPatterns (); Std :: vector & lt; CV :: Mat & gt; Pdescriptors (pattern-> Size ()); For (Int i = 0; I Size (); i ++) {Rich Img * p = patterns-> On (i); Pdescriptors.at (i) = p- & gt; Mill descriptor (); } This- & gt; Detector- & gt; Addition (repentant); This- & gt; Detector- & gt; train (); Std :: vector & lt; Std :: vector & lt; CV :: DMatch & gt; & Gt; M_knnMatches; Const CV :: Matt & amp; QueryDescriptors = getSceneDescriptors (); Return (queryDescriptors.empty ()); If (queryDescriptors.type ()! = CV_32F) {queryDescriptors.convertTo (query descriptor, CV_32F); } Matcher- & gt; KnnMatch (query descriptor, m_nmmatch, 3); (Size_t i = 0; i & lt; m_knnMatches.size (); i ++) for (const cv :: DMatch & match_0 = M_NM matches [I] [0]; CONST CV :: DMH & amp; 1: m_knnMatches [i] [1]; CONST CV :: DMH & 1: 2 = M_NN Mats [I] [2]; STD :: cout & lt; "match_0: IMGIDX (" & lt; & Lt; match_0.imgIdx & lt; & lt; ") Distance (" << match_0.distance <") & lt; & lt; std :: endl; std :: cout & Lt; & lt; "1: 4: IGIdx ("
and the results are:
match_0: imgIdx (403) distance (0) 1: iGidx (1403) distance (0) 2: imgidx (ii jidx (1090) distance (0.270127) match_0: imgidx (403) distance 1403) distance (0) 2: IMGIDX (1985) distance (0.227835)
Note: I have just posted a light version of my code (the code I need to understand what I am doing) and The result is that only one part of what I get is (There are 800+ lines in the original results)
Comments
Post a Comment