我编写了下面的代码来了解有关特征检测的感觉。
但我无法理解的是,为什么我们需要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);
答案 0 :(得分:3)
我并不完全熟悉Java API,但我想这个过程在任何语言中都是相似的。
如果您只想检测功能(关键点),那么您不需要使用匹配项。
但是,如果您想在两张图片之间匹配功能,那么还有更多工作要做。
一般步骤如下: