以下代码(使用用于图像处理的openCV -libraries 以Java编写)生成MatOfDMatch类的输出。问题是我不明白数组中的值告诉我关于匹配的内容:
FeatureDetector fastFeatureDetector = FeatureDetector
.create(FeatureDetector.FAST);
DescriptorExtractor surfDescriptorExtractor = DescriptorExtractor
.create(DescriptorExtractor.SURF);
DescriptorMatcher flannDescriptorMatcher = DescriptorMatcher
.create(DescriptorMatcher.FLANNBASED);
Mat image1 = Highgui.imread(myPicPath);
Mat image2 = Highgui.imread(myPicPath2);
ArrayList<MatOfKeyPoint> keypoints1 = new ArrayList<MatOfKeyPoint>();
keypoints1.add(new MatOfKeyPoint());
ArrayList<MatOfKeyPoint> keypoints2 = new ArrayList<MatOfKeyPoint>();
keypoints2.add(new MatOfKeyPoint());
fastFeatureDetector.detect(image1, keypoints1.get(0));
fastFeatureDetector.detect(image2, keypoints2.get(0));
Mat descriptor1 = new Mat();
Mat descriptor2 = new Mat();
surfDescriptorExtractor.compute(image1, keypoints1.get(0),
descriptor1);
surfDescriptorExtractor.compute(image2, keypoints2.get(0),
descriptor2);
ArrayList<MatOfDMatch> matches = new ArrayList<MatOfDMatch>();
matches.add(new MatOfDMatch());
flannDescriptorMatcher.match(descriptor1,
descriptor2, matches.get(0));
Mat outImg = new Mat();
Features2d.drawMatches(image1, keypoints1.get(0), image2,
keypoints2.get(0), matches.get(0), outImg,
new Scalar(0, 255, 0), new Scalar(0, 0, 255), new MatOfByte(),
Features2d.NOT_DRAW_SINGLE_POINTS);
Highgui.imwrite(myOutpuPicPath,
outImg);
//The following code part is not part of the Matching process (which is above part),
//I include it here because it prints the MatOfDMatchvalues in a readable fashion
ArrayList<Double> matchChannel_0 = new ArrayList<Double>();
ArrayList<Double> matchChannel_1 = new ArrayList<Double>();
ArrayList<Double> matchChannel_2 = new ArrayList<Double>();
ArrayList<Double> matchChannel_3 = new ArrayList<Double>();
for (int j = 0; j < matches.get(0).size().height; j++) {
matchChannel_0.add(matches.get(0).get(j, 0)[0]);
matchChannel_1.add(matches.get(0).get(j, 0)[1]);
matchChannel_2.add(matches.get(0).get(j, 0)[2]);
matchChannel_3.add(matches.get(0).get(j, 0)[3]);
}
System.out.println(matchChannel_0 + "\n" + matchChannel_1 + "\n"
+ matchChannel_2 + "\n" + matchChannel_3);
将image1和image2设置为相同的 pic,让所有值都matchChannel_1
变为 asmatchChannel_0
并且值matchChannel_3
都变为 0。
将image1和image2设置为不同的图片,值就不同了。
这些值是什么意思?他们肯定要告诉一些关于比赛的事情,但我不知道究竟是什么以及如何。我需要一个答案,例如“该渠道中更大的价值意味着这个以及另一个渠道中的那个”。有人可以澄清这一点,因为本页上的 openCV 教程没有解释这一点。