我正在尝试使用openCV Java API中的Feature2d.drawMatches方法创建一个图像,该图像描述从sift文件生成的图像中关键点之间的匹配。 我似乎无法弄清楚该方法将采用哪种参数作为输出参数-我不断收到以下断言错误:
OpenCV(3.4.1) Error: Assertion failed (!outImage.empty()) in
cv::drawKeypoints, file C:\build\master_winpack-bindings-win32-vc14-
static\opencv\modules\features2d\src\draw.cpp, line 115
Exception in thread "main" CvException [org.opencv.core.CvException:
cv::Exception: OpenCV(3.4.1) C:\build\master_winpack-bindings-win32-vc14-
static\opencv\modules\features2d\src\draw.cpp:115: error: (-215)
!outImage.empty() in function cv::drawKeypoints
]
at org.opencv.features2d.Features2d.drawMatches_1(Native Method)
at org.opencv.features2d.Features2d.drawMatches(Features2d.java:71)
at com.company.GUI.ImagesView.matchPoints(ImagesView.java:94)
at com.company.GUI.ImagesView.(ImagesView.java:69)
at com.company.Main.main(Main.java:17)
我的代码:
private void matchPoints() {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
MatOfKeyPoint matKey1 = new MatOfKeyPoint(keyPoints1);
MatOfKeyPoint matKey2 = new MatOfKeyPoint(keyPoints2);
MatOfDMatch matDMatch = new MatOfDMatch(matches);
Mat output = new Mat();
//output = new Mat(matKey1.rows(), matKey1.cols(), CvType.CV_8U, Scalar.all(0));
if (!output.empty())
System.out.println("not empty");
else
System.out.println("empty");
Features2d.drawMatches(mat1, matKey1, mat2, matKey2, matDMatch, output);
HighGui.imshow("Matches", output);
}
尽管下面的empty()检查为这两个Mats返回了不同的值,但是否取消注释了注释行,却显示出完全相同的断言错误。 我很茫然,将不胜感激。