title: Filtering MatOfDMatch
body: <p>Refer to <a href="http://docs.opencv.org/2.4.2/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.html" rel="noreferrer">http://docs.opencv.org/2.4.2/doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.html</a></p>
  
  <p>At some point in my code I invoke</p>
  
  <pre><code>myDescriptorMatcher.match(descriptors, result);
  </code></pre>
  
  <p>Now, if I want to filter the resulting matches, I believe I have to do something ugly like:</p>
  
  <pre><code>        List&lt;DMatch&gt; matchesList = matches.toList();
          double maxDistance = 0;
          double minDistance = 1000;
  
          int rowCount = matchesList.size();
          for (int i = 0; i &lt; rowCount; i++) {
              double dist = matchesList.get(i).distance;
              if (dist &lt; minDistance) minDistance = dist;
              if (dist &gt; maxDistance) maxDistance = dist;
          }
  
          List&lt;DMatch&gt; goodMatchesList = new ArrayList&lt;DMatch&gt;();
          double upperBound = 6 * minDistance;
          for (int i = 0; i &lt; rowCount; i++) {
              if (matchesList.get(i).distance &lt; upperBound) {
                  goodMatchesList.add(matchesList.get(i));
              }
          }
  
  MatOfDMatch goodMatches = new MatOfDMatch();
  goodMatches.fromList(goodMatchesList);  
  
  Features2d.drawMatches(mPreviousGray.submat(roi), mPrevDetectedFeatures, m.submat(roi), curDetectedFeatures, goodMatches, result);
  </code></pre>
  
  <ol>
  <li>Can this be done without the ugly back and forth conversions to lists?</li>
  <li>I've tried doing this via JNI, but how do I transfer the MatOFDMatch from Java to C++ and back?</li>
  </ol>