次のコード ( JavaでopenCV -libraries for Image Processingを使用して記述) は、クラス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
が asにmatchChannel_0
なり、値matchChannel_3
がすべて 0 になります。
image1とimage2を別の picturesに設定すると、値が異なります。
値は何を意味しますか? 彼らは確かに試合について何かを伝えなければならないが、私は正確に何をどのように理解することができない. 「そのチャンネルの大きな値はこれを意味し、他のチャンネルはそれを意味します」のような答えが必要です。このページのopenCVチュートリアルでは説明されていないため、誰かがこれを明確にすることができます。