我在二维缝合问题上遇到了麻烦,如此处发布的:link
我想看看在缝合管线中发生的特征匹配。我可以像下面的代码一样自己编写缝合算法来做到这一点。
但是,任何人都可以告诉我如何从拼接管道中获取此信息吗?我想在另一个文件上查看匹配的功能。
double minDist = Double.MAX_VALUE;
double maxDist = 0;
double distance;
for (int i = 0; i < matchesArr.length; i++) {
distance = matchesArr[i].distance;
if (distance < minDist)
minDist = distance;
else if (distance > maxDist)
maxDist = distance;
}
final double thresholdFactor = 3.5;
List<DMatch> good_matches = new Vector<DMatch>();
for (int i = 0; i < matchesArr.length; i++) {
if (matchesArr[i].distance <= thresholdFactor * minDist) {
good_matches.add(matchesArr[i]);
}
}
LinkedList<Point> listImage1 = new LinkedList<Point>();
LinkedList<Point> listImage2 = new LinkedList<Point>();
List<KeyPoint> keyPointsList1 = keyPoints1.toList();
List<KeyPoint> keyPointsList2 = keyPoints2.toList();
for (int i = 0; i < good_matches.size(); i++) {
listImage1.addLast(keyPointsList1.get(good_matches.get(i).queryIdx).pt);
listImage2.addLast(keyPointsList2.get(good_matches.get(i).trainIdx).pt);
}
MatOfDMatch goodMatches = new MatOfDMatch();
goodMatches.fromList(good_matches);
Features2d.drawMatches(processedImage1, keyPoints1, processedImage2, keyPoints2, goodMatches, imgMatch, new Scalar(254, 0, 0), new Scalar(254, 0, 0), new MatOfByte(), 2);
boolean imageMatched = imgcodecs.imwrite("imageMatched.jpg", imgMatch);