简体   繁体   中英

How to use OpenCV BOWImgDescriptorExtractor in Android NDK?

I have an Android app with native part. It will use svm, so I need the BOWImgDescriptorExtractor. My problem is that I can't use bowDE.compute(); as I use it on PC. There is no implementation for Android with this arguments: 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. 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). After I turned on my computer today and started eclipse, there was no error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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