简体   繁体   English

如何在Android NDK中使用OpenCV BOWImgDescriptorExtractor?

[英]How to use OpenCV BOWImgDescriptorExtractor in Android NDK?

I have an Android app with native part. 我有一个带有原生部分的Android应用程序。 It will use svm, so I need the BOWImgDescriptorExtractor. 它将使用svm,所以我需要BOWImgDescriptorExtractor。 My problem is that I can't use bowDE.compute(); 我的问题是我不能使用bowDE.compute(); as I use it on PC. 因为我在PC上使用它。 There is no implementation for Android with this arguments: bowDe.compute(Mat& img, vector<KeyPoint>& keypoints, Mat& descriptors); Android没有使用以下参数的实现: bowDe.compute(Mat& img, vector<KeyPoint>& keypoints, Mat& descriptors);

I must use the following method: 我必须使用以下方法:

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 *)

And I have no idea how. 而且我不知道如何。

When I hover on the BOWImgDescriptorExtracotr, I can see the class. 当我将鼠标悬停在BOWImgDescriptorExtracotr上时,我可以看到该课程。 There I can see the method declaration, which is the following: 在那里,我可以看到方法声明,如下所示:

 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

As you can see, the other arguments have their default values, but still for some reason I get an error for invalid arguments. 如您所见,其他参数具有默认值,但由于某种原因,我仍然会收到无效参数的错误。 Although the method that it should be is different from the method that is given in the class.. for some reason.. 尽管由于某些原因它应该与类中给出的方法有所不同。

My code is the following: 我的代码如下:

Mat features;
vector<KeyPoint> keypoints;

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

Here is the output when trying to compile: 这是尝试编译时的输出:

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

Can you give an example or explanation please? 你能举个例子或解释吗? Thanks in advance! 提前致谢!

I think it might have been problem with the IDE (Eclipse Luna). 我认为它可能是IDE(Eclipse Luna)的问题。 After I turned on my computer today and started eclipse, there was no error. 今天打开计算机并开始蚀后,没有任何错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM