The following code (written in Java using openCV-libraries for Image Processing) produces an output of class MatOfDMatch. The problem is i dont understand what the values inside the array are telling me about the match:
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);
Setting image1 and image2 to the same pic, lets all values in matchChannel_1
become as matchChannel_0
and values matchChannel_3
become all 0.
Setting image1 and image2 to different pictures, the values become different.
What do the values mean? They sure have to tell something about the match, but i cant figure out what exactly and how. I need an answer like "bigger values in that channel means this and in the other channel that". Could someone clarify this, as it is not explained by the openCV tutorial on this page.