【问题标题】:opencv-3.0.0 ubuntu 14.04 "nonfree/nonfree.hpp" build erroropencv-3.0.0 ubuntu 14.04“nonfree/nonfree.hpp”构建错误
【发布时间】:2016-02-07 05:08:08
【问题描述】:

我正在尝试在 opencv-3.0.0 中实现 SURF 算法 为此,我已经包含了头文件

#include <stdio.h>
#include <iostream>
#include "opencv2/core.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/xfeatures2d.hpp"
#include "opencv2/calib3d.hpp"
#include <opencv2/nonfree/nonfree.hpp>
using namespace cv;
using namespace std;

但我不断收到下面提到的错误。我试过到处搜索,但找不到任何解决方案。我已经构建了带有额外依赖项的 opencv 模块。

In file included from /usr/include/opencv2/nonfree/nonfree.hpp:46:0,
             from panaroma.cpp:7:
/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 ) 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 /usr/include/opencv2/nonfree/nonfree.hpp:46:0,
             from panaroma.cpp:7:
/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 /usr/include/opencv2/nonfree/nonfree.hpp:46:0,
             from panaroma.cpp:7:
/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 /usr/include/opencv2/nonfree/nonfree.hpp:46:0,
             from panaroma.cpp:7:
/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& 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;
                                           ^

编辑 1 所以,我实际面临的问题是我试图使用正在开发中的包而不是稳定版本。我只需要做git checkout 3.0.0 即可获得稳定版本。

【问题讨论】:

  • 你的编译器是什么?
  • 尝试用opencv2/nonfree/features2d.hpp替换opencv2/nonfree/nonfree.hpp
  • 请检查我面临的新问题here@Azad

标签: c++ opencv ubuntu


【解决方案1】:

打开位于 /usr/include/opencv2/nonfree/features2d.hpp 的文件 features2d.hpp 您应该是 sudo usr 来编辑文件。 将“vector”头文件添加为#include 然后添加 using namespace std;

这应该可以解决您的问题。 问候, 阿维纳什

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-21
    • 1970-01-01
    • 1970-01-01
    • 2015-06-05
    • 1970-01-01
    • 2016-03-10
    相关资源
    最近更新 更多