在我的代码中的某个时刻,我调用
myDescriptorMatcher.match(descriptors, result);
现在,如果我想过滤结果匹配,我相信我必须做一些丑陋的事情,比如:
List<DMatch> matchesList = matches.toList();
double maxDistance = 0;
double minDistance = 1000;
int rowCount = matchesList.size();
for (int i = 0; i < rowCount; i++) {
double dist = matchesList.get(i).distance;
if (dist < minDistance) minDistance = dist;
if (dist > maxDistance) maxDistance = dist;
}
List<DMatch> goodMatchesList = new ArrayList<DMatch>();
double upperBound = 6 * minDistance;
for (int i = 0; i < rowCount; i++) {
if (matchesList.get(i).distance < 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);
- 这可以在没有丑陋的来回转换到列表的情况下完成吗?
- 我已经尝试通过 JNI 执行此操作,但是如何将 MatOFDMatch 从 Java 传输到 C++ 并返回?