我写了下面的代码来感受一下特征检测。但我无法理解的是,为什么我们需要MatOfMatch
对象,它需要什么?
代码
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat img_0 = Highgui.imread(PATH_0);
Mat img_0_rev = Highgui.imread(PATH_1);
Mat img_output = new Mat();
FeatureDetector fDetect = FeatureDetector.create(FeatureDetector.SIFT);
MatOfKeyPoint mKeyPoints_0 = new MatOfKeyPoint();
fDetect.detect(img_0, mKeyPoints_0);
System.out.println("mKeyPoint_0: " + mKeyPoints_0.size());
MatOfKeyPoint mKeyPoints_1 = new MatOfKeyPoint();
fDetect.detect(img_0_rev, mKeyPoints_1);
System.out.println("mKeyPoint_1: " + mKeyPoints_1.size());
MatOfDMatch mDMatch = new MatOfDMatch();
//Features2d.drawKeypoints(mKeyPoints_0, mKeyPoints_0, outImage, Scalar color, Features2d.DRAW_RICH_KEYPOINTS);
Features2d.drawMatches(img_0, mKeyPoints_0, img_0_rev, mKeyPoints_1, mDMatch, img_output);