简体   繁体   English

Opencv SIFT未定义引用问题

[英]Opencv SIFT undefined references issue

In function keypoint_calc(cv::Mat)': FilePath/MyFirstOpenCVJNI-master/jni/first-opencvjni.cpp:35: undefined reference to cv::xfeatures2d::SIFT::create(int, int, double, double, double)' 在函数keypoint_calc(cv::Mat)': FilePath/MyFirstOpenCVJNI-master/jni/first-opencvjni.cpp:35: undefined reference to cv :: xfeatures2d :: SIFT :: create(int,int,double,double,double )”

./obj/local/arm64-v8a/objs/first-opencvjni/first-opencvjni.o: In function sift_descriptor(cv::Mat, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >)': FilePath/MyFirstOpenCVJNI-master/jni/first-opencvjni.cpp:45: undefined reference to cv::xfeatures2d::SIFT::create(int, int, double, double, double)' ./obj/local/arm64-v8a/objs/first-opencvjni/first-opencvjni.o:在函数sift_descriptor(cv::Mat, std::vector<cv::KeyPoint, std::allocator<cv::KeyPoint> >)': FilePath/MyFirstOpenCVJNI-master/jni/first-opencvjni.cpp:45: undefined reference to cv :: xfeatures2d :: SIFT :: create(int,int,double,double,double)'

#include <jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc_c.h>
#include <opencv/cv.h>
#include <opencv2/opencv.hpp>
#include <GLES2/gl2.h>
#include <android/log.h>

#include <opencv2/flann/flann.hpp>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/nonfree/features2d.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/xfeatures2d.hpp>
#include <iostream>

#define  LOG_TAG    "cpp-file"

are my includes. 是我的包括。

And on those mentioned lines i have following code. 在这些提到的行上我有以下代码。

cv::Ptr<cv::xfeatures2d::SIFT> feature_detector = cv::xfeatures2d::SIFT::create(200);

and

cv::Ptr<cv::xfeatures2d::SIFT> feature_detector = cv::xfeatures2d::SIFT::create(200);

I'm a noob to JNI any help would be highly appreciated. 我是JNI的菜鸟,任何帮助都会受到高度赞赏。

Undefined reference is reported by the linker . 链接器报告未定义的引用 Your project ( Android.mk or CMakeLists.txt ) should include the OpenCV libraries. 您的项目( Android.mkCMakeLists.txt )应包含OpenCV库。 SIFT is patented, therefore it is not part of the free prebuilt OpenCV Android distribution. SIFT获得专利,因此它不是免费的预构建OpenCV Android发行版的一部分。 You can either build libnonfree.so separately and use it as a prebuilt shared library in your app, or compile SIFT as a static library. 您可以单独构建libnonfree.so并将其用作应用程序中的预构建共享库,也可以将SIFT编译为静态库。

Detailed instructions can be found here and here , but they may require adaptation for the latest (3.2) version, and the new NDK release. 详细说明可以在这里这里找到,但它们可能需要适应最新的(3.2)版本和新的NDK版本。 If you don't care about the latest version, you can also download prebuilt binaries . 如果您不关心最新版本,还可以下载预构建的二进制文件

After days of struggle finally able to solve the contrib module, after some work around came across a pretty nice self explainable article to build the opencv with Extra modules. 经过几天的努力终于能够解决contrib模块,经过一些努力遇到了一个非常好的自我解释的文章来构建带有额外模块的opencv。 The link for the same is here 相同的链接在这里

And in case some one wants to use an already built opencv master with contrib extra modules, they can feel free to use it from my repo, the link for the same is this , This article works only on windows, just for the sake of information as i've failed to follow up the same on a mac. 如果有人想要使用已经构建的带有contrib额外模块的opencv master,他们可以随意使用我的repo,同样的链接就是这个 ,这篇文章只适用于windows,只是为了信息因为我没能在Mac上跟进。

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

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