如何在Android NDK中使用OpenCV BOWImgDescriptorExtractor

How to use OpenCV BOWImgDescriptorExtractor in Android NDK?

本文关键字:OpenCV BOWImgDescriptorExtractor NDK Android      更新时间:2023-10-16

我有一个带有本地部分的Android应用程序。它将使用svm,所以我需要BOWImgDescriptorExtractor。我的问题是,我不能像在PC上使用bowDE.compute();那样使用它。没有这个参数的Android实现:bowDe.compute(Mat& img, vector<KeyPoint>& keypoints, Mat& descriptors);

我必须使用以下方法:

void compute(const cv::Mat &, std::vector<cv::KeyPoint,std::allocator<cv::KeyPoint>> &, cv::Mat &, std::vector<std::vector<int,std::allocator<int>>,std::allocator<std::vector<int,std::allocator<int>>>> *, cv::Mat *)

我不知道怎么做。

当我将鼠标悬停在BOWImgDescriptorExtracotr上时,我可以看到类。在那里我可以看到方法声明,如下所示:

 void compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& imgDescriptor,
                  vector<vector<int> >* pointIdxsOfClusters=0, Mat* descriptors=0 );
    // compute() is not constant because DescriptorMatcher::match is not constant

正如您所看到的,其他参数都有其默认值,但由于某种原因,我仍然会收到无效参数的错误。尽管它应该是的方法与类中给定的方法不同。。出于某种原因。。

我的代码如下:

Mat features;
vector<KeyPoint> keypoints;
detector->detect(matGray, keypoints);
KeyPointsFilter::retainBest(keypoints, 1500);
bowDE.compute(matGray, keypoints, features);

以下是尝试编译时的输出:

SVMDetector.cpp:45:45: error: no matching function for call to 'cv::BOWImgDescriptorExtractor::compute(cv::Mat&, std::vector<cv::KeyPoint>&, const cv::Mat&)'
SVMDetector.cpp:45:45: note: candidate is:
OpenCV-2.4.9-android-sdk/sdk/native/jni/include/opencv2/features2d/features2d.hpp:1592:10: note: void cv::BOWImgDescriptorExtractor::compute(const cv::Mat&, std::vector<cv::KeyPoint>&, cv::Mat&, std::vector<std::vector<int> >*, cv::Mat*)
OpenCV-2.4.9-android-sdk/sdk/native/jni/include/opencv2/features2d/features2d.hpp:1592:10: note:   no known conversion for argument 3 from 'const cv::Mat' to 'cv::Mat&'
make: *** [/<some path>/local/armeabi-v7a/objs/svm_detector/SVMDetector.o] Error 1

你能举个例子或解释一下吗?提前感谢!

我认为IDE(Eclipse Luna)可能有问题。在我今天打开电脑并启动eclipse之后,没有出现任何错误。