在OpenCV 3.0.0中包含非自由模块

时间:2015-09-12 19:29:52

标签: c++ opencv

#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中。 看看这个截图: location of features2d.hpp 这是我的1.cpp

的cmake文件
cmake_minimum_required(VERSION 2.8)
project( 1 )
find_package( OpenCV REQUIRED )
add_executable( 1 1.cpp )
target_link_libraries( 1 ${OpenCV_LIBS} )

1 个答案:

答案 0 :(得分:3)

在OpenCV 3.0.0中,nonfree模块位于xfeatures2d,而不是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;
}