c++ - 在 OpenCV 3.0.0 中包含非自由模块

标签 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} )

最佳答案

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

关于c++ - 在 OpenCV 3.0.0 中包含非自由模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32542847/

相关文章:

c# - 使用Kinect C#VS 2013保存彩色框

c++ - C++中的UE4播放时间

c++ - 堆数组性能慢

android - 如何在 Android 上使用 OpenCV 提高人脸检测性能?

python - 是否可以在 python 中使用 opencv 直方图检测文本颜色和位置?

python - 如何改变盒子的不透明度(cv2.rectangle)?

c++ - OpenCV中两个数组的互相关

c++ - cpp文件中的C++变量能否定义为特殊符号β

c++ - XCode 主题到 Notepad++?

c++ - 如何确保 Qt Widget.repaint 已完成运行?