When I use batchDistance in OpenCV4Android, I get the following assertion error:
10-16 17:33:22.770: E/cv::error()(30470): OpenCV Error: Assertion failed (_nidx.needed() == (K > 0)) in void cv::batchDistance(const cv::_InputArray&, const cv::_InputArray&, const cv::_OutputArray&, int, const cv::_OutputArray&, int, int, const cv::_InputArray&, int, bool), file X:\Dev\git\opencv-2.4\modules\core\src\stat.cpp, line 1771
10-16 17:33:22.775: E/AndroidRuntime(30470): FATAL EXCEPTION: main
10-16 17:33:22.775: E/AndroidRuntime(30470): CvException [org.opencv.core.CvException: X:\Dev\git\opencv-2.4\modules\core\src\stat.cpp:1771: error: (-215) _nidx.needed() == (K > 0) in function void cv::batchDistance(const cv::_InputArray&, const cv::_InputArray&, const cv::_OutputArray&, int, const cv::_OutputArray&, int, int, const cv::_InputArray&, int, bool)
I'm using batchDistance as follows:
Mat distances = new Mat();
Mat nidx = new Mat();
assert(nidx.empty());
Core.batchDistance(queryDescriptors,
mTrainDescriptors,
distances,
Core.NORM_HAMMING2,
nidx
);
I've used nidx = new Mat()
because I saw that in C++ the default was noArray()
, which should be equal to an empty Mat. In Java, the method .needed()
doesn't exist, so I don't know what's actually the problem.
Please help me fix this or help me find another way to calculate the pairwise distance of the descriptors in two Mat
's.