#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中。
看一下这个截图:
c&#43;&#43; - 在OpenCV 3.0.0中包含非自由模块-LMLPHP
这是我的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} )

最佳答案

在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;
}

09-11 19:46