本文介绍了在OpenCV 3.0.0中包含非自由模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <opencv2\features2d\features2d.hpp>
using namespace cv;
using namespace cv::xfeatures2d;
using namespace std;
int main(int argc, char *argv[])
{
Ptr<SURF> surf = SURF::create();
return 0;
}
以下代码给出错误:
/home/shivam/1.cpp:2:45: fatal error: opencv2\features2d\features2d.hpp: No such file or directory
#include <opencv2\features2d\features2d.hpp>
但是头文件包含在include \ opencv2 \ features2d \ features2d.hpp中.看一下这个截图:这是我的1.cpp的cmake文件
But the header file is included in include\opencv2\features2d\features2d.hpp.Have a look at this screenshot:Here is my cmake file for 1.cpp
cmake_minimum_required(VERSION 2.8)
project( 1 )
find_package( OpenCV REQUIRED )
add_executable( 1 1.cpp )
target_link_libraries( 1 ${OpenCV_LIBS} )
推荐答案
在OpenCV 3.0.0中,nonfree
模块位于xfeatures2d
中,而不位于features2d
中.
In OpenCV 3.0.0 nonfree
module is in xfeatures2d
, not features2d
.
此代码将编译:
#include <opencv2\opencv.hpp>
#include <opencv2\xfeatures2d.hpp>
using namespace cv;
using namespace cv::xfeatures2d;
int main(int argc, char *argv[])
{
Ptr<SURF> surf = SURF::create();
return 0;
}
这篇关于在OpenCV 3.0.0中包含非自由模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!