Ask Your Question

Revision history [back]

java opencv Features2d.drawMatches - Assertion failure

I'm trying to create an image depicting matches between keypoints in images generated from sift files, using the Features2d.drawMatches method from openCV java API. I'm using openCV 3.4.1. I can't seem to figure out what kind of argument the method will take as an output parameter - I keep getting the following Assertion Error: "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" My code:

private void matchPoints() {
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");
Features2d.drawMatches(mat1, matKey1, mat2, matKey2, matDMatch, output);
HighGui.imshow("Matches", output);

The assertion error shows up regardless of if the commented line is there or not.