shivam mitra
shivam mitra

Reputation: 232

Including nonfree modules in 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;
}

The following code gives an error:

/home/shivam/1.cpp:2:45: fatal error: opencv2\features2d\features2d.hpp: No such file or directory
 #include <opencv2\features2d\features2d.hpp>

But the header file is included in include\opencv2\features2d\features2d.hpp. Have a look at this screenshot: location of features2d.hpp 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} )

Upvotes: 1

Views: 4252

Answers (1)

Miki
Miki

Reputation: 41765

In OpenCV 3.0.0 nonfree module is in xfeatures2d, not features2d.

This code will compile:

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

Upvotes: 4

Related Questions