我使用2个OpenCV匹配函数来匹配2个不同图像中的2个对象。 首先,我使用它的BFMatcher作为第二个它的DescriptorMatcher, 我的代码运行良好,但准确率约为50%.. 所以我的问题是如何才能达到90%的准确度?
以下是我的代码的匹配部分:
" System.out.println("\nMatching..");
Mat res = new Mat();
KeyPoint keyPoints = new KeyPoint();
detector.detect(input, keyPoints);
extractor.compute(input, keyPoints, res);
Map<String, Double> m = new HashMap<String, Double>();
BFMatcher _matcher = new BFMatcher(opencv_core.NORM_L2, true);
DescriptorMatcher dmatcher = new BFMatcher();
//DMatch matches = null;
for (Map.Entry<String, Mat> item : mdescs.entrySet()) {
Mat t = new Mat(item.getValue());
DMatch matches = new DMatch();
DMatchVectorVector dmatches = new DMatchVectorVector();
//DMatch kmatches = new DMatch();
if (ratio) {
dmatcher.knnMatch(res, t, dmatches, 2);
double i1 = getRatio(dmatches);
dmatches = new DMatchVectorVector();
dmatcher.knnMatch(t, res, dmatches, 2);
double i2 = getRatio(dmatches);
/*+ "ratio" + Integer.valueOf(i1 > i2 ? i1 : i2)*/
m.put(item.getKey(), (i1 > i2 ? i1 : i2)/*Double.valueOf(dmatches.size())*/);
} else {
_matcher.match(res, t, matches);
m.put(item.getKey(), Double.valueOf(matches.capacity()));
}
System.out.print(".");"
感谢。