Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV compile error of nonfree/feature2d.hpp

I am trying to compile a c++ program with SIFT/SURF, and when I include I get this error message:

/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:83:49: error: ‘vector’ has not been declared
     void buildGaussianPyramid( const Mat& base, vector<Mat>& pyr, int nOctaves ) const;
                                                 ^
/usr/include/opencv2/nonfree/features2d.hpp:83:55: error: expected ‘,’ or ‘...’ before ‘<’ token
     void buildGaussianPyramid( const Mat& base, vector<Mat>& pyr, int nOctaves ) const;
                                                       ^
/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>& dog_pyr,
                                       ^
/usr/include/opencv2/nonfree/features2d.hpp:85:45: error: expected ‘,’ or ‘...’ before ‘<’ token
     void findScaleSpaceExtrema( const vector<Mat>& gauss_pyr, const vector<Mat>& dog_pyr,
                                             ^
/usr/include/opencv2/nonfree/features2d.hpp:89:40: error: ‘vector’ has not been declared
     void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
                                        ^
/usr/include/opencv2/nonfree/features2d.hpp:89:46: error: expected ‘,’ or ‘...’ before ‘<’ token
     void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
                                              ^
/usr/include/opencv2/nonfree/features2d.hpp:90:41: error: ‘vector’ has not been declared
     void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
                                         ^
/usr/include/opencv2/nonfree/features2d.hpp:90:47: error: expected ‘,’ or ‘...’ before ‘<’ token
     void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
                                               ^
/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 SURF_detector.cpp:12: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 SURF_detector.cpp:12: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 SURF_detector.cpp:12:0:
/usr/include/opencv2/nonfree/features2d.hpp:142:40: error: ‘vector’ has not been declared
     void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
                                        ^
/usr/include/opencv2/nonfree/features2d.hpp:142:46: error: expected ‘,’ or ‘...’ before ‘<’ token
     void detectImpl( const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat() ) const;
                                              ^
/usr/include/opencv2/nonfree/features2d.hpp:143:41: error: ‘vector’ has not been declared
     void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;
                                         ^
/usr/include/opencv2/nonfree/features2d.hpp:143:47: error: expected ‘,’ or ‘...’ before ‘<’ token
     void computeImpl( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const;

I am trying to use ROS and catkin, and it has all worked up until I have tried implementing SIFT/SURF. I have also tried to compile with normal g++ with no luck. I have tried to install OpenCV three times with different methods, but still the same results.

I am using Ubuntu 14.04 with OpenCV 2.4.10

like image 409
Adam Leon Kleppe Avatar asked Nov 28 '25 13:11

Adam Leon Kleppe


1 Answers

I had the exact same problem, SIFT/SURF have been moved to the opencv_contrib module on github now https://github.com/Itseez/opencv_contrib

you'll have to build opencv from start with the module included in the cmake process, they have a tutorial showing you how to do this

the features now have the namespace cv::xfeatures2d to reflect the contribution changes

hope that helps

like image 169
Evan O' Keeffe Avatar answered Dec 01 '25 07:12

Evan O' Keeffe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!