I have gone through the instructions for running cmake a number of times, and it works for the basic modules that are included in Opencv, but when it comes to the old 'nonfree' modules, in the Extra Modules git download , it won't compile to be able to run a program that has #include "opencv/xfeatures2d.hpp"
https://github.com/Itseez/opencv_contrib ^This is the place to download the extra modules
This what Terminal gives me when I try to 'make' GIVE NO ERROR AFTER THAT I COMPILE MY PROGRAM GIVING ERROR g++ -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L/usr/local/lib/ -g -o test test.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_stitching -lopencv_xobjdetect -lopencv_nonfree test.cpp: In function ‘int main(int, char)’: test.cpp:44:44: error: no matching function for call to ‘cv::xfeatures2d::SURF::SURF(int&)’ SurfFeatureDetector detector( minHessian ); ^ In file included from test.cpp:20:0: /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:116:20: note: candidate: cv::xfeatures2d::SURF::SURF() class CV_EXPORTS_W SURF : public Feature2D ^ /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:116:20: note: candidate expects 0 arguments, 1 provided /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:116:20: note: candidate: cv::xfeatures2d::SURF::SURF(const cv::xfeatures2d::SURF&) /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:116:20: note: no known conversion for argument 1 from ‘int’ to ‘const cv::xfeatures2d::SURF&’ test.cpp:44:23: error: cannot declare variable ‘detector’ to be of abstract type ‘cv::xfeatures2d::SURF’ SurfFeatureDetector detector( minHessian ); ^ In file included from test.cpp:20:0: /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:116:20: note: because the following virtual functions are pure within ‘cv::xfeatures2d::SURF’: class CV_EXPORTS_W SURF : public Feature2D ^ /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:132:26: note: virtual void cv::xfeatures2d::SURF::setHessianThreshold(double) CV_WRAP virtual void setHessianThreshold(double hessianThreshold) = 0; ^ /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:133:28: note: virtual double cv::xfeatures2d::SURF::getHessianThreshold() const CV_WRAP virtual double getHessianThreshold() const = 0; ^ /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:135:26: note: virtual void cv::xfeatures2d::SURF::setNOctaves(int) CV_WRAP virtual void setNOctaves(int nOctaves) = 0; ^ /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:136:25: note: virtual int cv::xfeatures2d::SURF::getNOctaves() const CV_WRAP virtual int getNOctaves() const = 0; ^ /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:138:26: note: virtual void cv::xfeatures2d::SURF::setNOctaveLayers(int) CV_WRAP virtual void setNOctaveLayers(int nOctaveLayers) = 0; ^ /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:139:25: note: virtual int cv::xfeatures2d::SURF::getNOctaveLayers() const CV_WRAP virtual int getNOctaveLayers() const = 0; ^ /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:141:26: note: virtual void cv::xfeatures2d::SURF::setExtended(bool) CV_WRAP virtual void setExtended(bool extended) = 0; ^ /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:142:26: note: virtual bool cv::xfeatures2d::SURF::getExtended() const CV_WRAP virtual bool getExtended() const = 0; ^ /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:144:26: note: virtual void cv::xfeatures2d::SURF::setUpright(bool) CV_WRAP virtual void setUpright(bool upright) = 0; ^ /usr/local/include/opencv2/xfeatures2d/nonfree.hpp:145:26: note: virtual bool cv::xfeatures2d::SURF::getUpright() const CV_WRAP virtual bool getUpright() const = 0; ^ test.cpp:52:27: error: cannot declare variable ‘extractor’ to be of abstract type ‘cv::xfeatures2d::SURF’ SurfDescriptorExtractor extractor; ^ test.cpp:87:16: error: ‘vector’ was not declared in this scope vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS ); ^ test.cpp:87:16: note: suggested alternative: In file included from /usr/include/c++/5/vector:64:0, from test.cpp:3: /usr/include/c++/5/bits/stl_vector.h:214:11: note: ‘std::vector’ class vector : protected _Vector_base<_Tp, _Alloc> ^ test.cpp:87:23: error: expected primary-expression before ‘char’ vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS ); ^ test.cpp:114:97: error: ‘line’ was not declared in this scope , scene_corners[0] + offset, scene_corners[1] + offset, Scalar(0, 255, 0), 4 ); ^ admin1@admin:~/opexamp$ admin1@admin:~/opexamp$ g++ -I/usr/local/include/opencv -I/usr/local/include/opencv2 -L/usr/local/lib/ -g -o test test.cpp -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_stitching -lopencv_xobjdetect -lopencv_nonfree In file included from test.cpp:19:0: /usr/include/opencv2/nonfree/features2d.hpp:73:21: error: ‘vector’ has not been declared vector<keypoint>& keypoints) const; ^ /usr/include/opencv2/nonfree/features2d.hpp:73:27: error: expected ‘,’ or ‘...’ before ‘<’ token vector<keypoint>& keypoints) const; ^ /usr/include/opencv2/nonfree/features2d.hpp:77:21: error: ‘vector’ has not been declared vector<keypoint>& keypoints, ^ /usr/include/opencv2/nonfree/features2d.hpp:77:27: error: expected ‘,’ or ‘...’ before ‘<’ token vector<keypoint>& keypoints, ^ /usr/include/opencv2/nonfree/features2d.hpp:76:10: error: ‘void cv::SIFT::operator()(cv::InputArray, cv::InputArray, int) const’ cannot be overloaded void operator()(InputArray img, InputArray mask, ^ /usr/include/opencv2/nonfree/features2d.hpp:72:10: error: with ‘void cv::SIFT::operator()(cv::InputArray, cv::InputArray, int) const’ void operator()(InputArray img, InputArray mask, ^ /usr/include/opencv2/nonfree/features2d.hpp:81:5: error: ‘AlgorithmInfo’ does not name a type AlgorithmInfo* info() const; ^ /usr/include/opencv2/nonfree/features2d.hpp:83:49: error: ‘vector’ has not been declared void buildGaussianPyramid( const Mat& base, vector<mat>& pyr, int nOctaves ^ /usr/include/opencv2/nonfree/features2d.hpp:83:55: error: expected ‘,’ or ‘...’ before ‘<’ token void buildGaussianPyramid( const Mat& base, vector<mat>& pyr, int nOctaves ^ /usr/include/opencv2/nonfree/features2d.hpp:84:33: error: ‘vector’ does not name a type void buildDoGPyramid( const vector<mat>& pyr, vector<mat>& dogpyr ) const; ^ /usr/include/opencv2/nonfree/features2d.hpp:84:39: error: expected ‘,’ or ‘...’ before ‘<’ token void buildDoGPyramid( const vector<mat>& pyr, vector<mat>& dogpyr ) const; ^ /usr/include/opencv2/nonfree/features2d.hpp:85:39: error: ‘vector’ does not name a type void findScaleSpaceExtrema( const vector<mat>& gauss_pyr, const vector<mat> ^ /usr/include/opencv2/nonfree/features2d.hpp:85:45: error: expected ‘,’ or ‘...’ before ‘<’ token void findScaleSpaceExtrema( const vector<mat>& gauss_pyr, const vector<mat> ^ /usr/include/opencv2/nonfree/features2d.hpp:89:40: error: ‘vector’ has not been declared void detectImpl( const Mat& image, vector<keypoint>& keypoints, const Mat& ^ /usr/include/opencv2/nonfree/features2d.hpp:89:46: error: expected ‘,’ or ‘...’ before ‘<’ token void detectImpl( const Mat& image, vector<keypoint>& keypoints, const Mat& ^ /usr/include/opencv2/nonfree/features2d.hpp:90:41: error: ‘vector’ has not been declared void computeImpl( const Mat& image, vector<keypoint>& keypoints, Mat& descr ^ /usr/include/opencv2/nonfree/features2d.hpp:90:47: error: expected ‘,’ or ‘...’ before ‘<’ token void computeImpl( const Mat& image, vector<keypoint>& keypoints, Mat& descr ^ /usr/include/opencv2/nonfree/features2d.hpp:125:28: error: ‘vector’ has not been declared CV_OUT vector<keypoint>& keypoints) const; ^ /usr/include/opencv2/nonfree/features2d.hpp:125:34: error: expected ‘,’ or ‘...’ before ‘<’ token CV_OUT vector<keypoint>& keypoints) const; ^ In file included from test.cpp:19:0: /usr/include/opencv2/nonfree/features2d.hpp:128:28: error: ‘vector’ has not been declared CV_OUT vector<keypoint>& keypoints, ^ /usr/include/opencv2/nonfree/features2d.hpp:128:34: error: expected ‘,’ or ‘...’ before ‘<’ token CV_OUT vector<keypoint>& keypoints, ^ /usr/include/opencv2/nonfree/features2d.hpp:127:10: error: ‘void cv::SURF::operator()(cv::InputArray, cv::InputArray, int) const’ cannot be overloaded void operator()(InputArray img, InputArray mask, ^ In file included from test.cpp:19:0: /usr/include/opencv2/nonfree/features2d.hpp:124:10: error: with ‘void cv::SURF::operator()(cv::InputArray, cv::InputArray, int) const’ void operator()(InputArray img, InputArray mask, ^ In file included from test.cpp:19:0: /usr/include/opencv2/nonfree/features2d.hpp:132:5: error: ‘AlgorithmInfo’ does not name a type AlgorithmInfo* info() const; ^ /usr/include/opencv2/nonfree/features2d.hpp:142:40: error: ‘vector’ has not been declared void detectImpl( const Mat& image, vector<keypoint>& keypoints, const Mat& ^ /usr/include/opencv2/nonfree/features2d.hpp:142:46: error: expected ‘,’ or ‘...’ before ‘<’ token void detectImpl( const Mat& image, vector<keypoint>& keypoints, const Mat& ^ /usr/include/opencv2/nonfree/features2d.hpp:143:41: error: ‘vector’ has not been declared void computeImpl( const Mat& image, vector<keypoint>& keypoints, Mat& descr ^ /usr/include/opencv2/nonfree/features2d.hpp:143:47: error: expected ‘,’ or ‘...’ before ‘<’ token void computeImpl( const Mat& image, vector<keypoint>& keypoints, Mat& descr ^ test.cpp:23:21: error: ‘xfeatures2d’ is not a namespace-name using namespace cv::xfeatures2d; ^ test.cpp:23:32: error: expected namespace-name before ‘;’ token using namespace cv::xfeatures2d; ^ test.cpp: In function ‘int main(int, char)’: test.cpp:87:16: error: ‘vector’ was not declared in this scope vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS ); ^ test.cpp:87:16: note: suggested alternative: In file included from /usr/include/c++/5/vector:64:0, from test.cpp:3: /usr/include/c++/5/bits/stl_vector.h:214:11: note: ‘std::vector’ class vector : protected _Vector_base<_Tp, _Alloc> ^ test.cpp:87:23: error: expected primary-expression before ‘char’ vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS ); ^ test.cpp:114:97: error: ‘line’ was not declared in this scope , scene_corners[0] + offset, scene_corners[1] + offset, Scalar(0, 255, 0), 4 );