我正在使用libnonfree-dev的非自由库的opencv 2.4.8。下面是我的make VERBOSE=1输出:
/usr/bin/c++ -DEIGEN_USE_NEW_STDVECTOR -DEIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET -DFLANN_STATIC -DROSCONSOLE_BACKEND_LOG4CXX -DROS_BUILD_SHARED_LIBS=1 -DROS_PACKAGE_NAME="test_code" -Dqh_QHpointer -Wno-deprecated -g -I/opt/ros/indigo/include -I/usr/include/opencv -I/usr/include/opencv2/nonfree -I/usr/include/vtk-5.8 -I/usr/include/pcl-1.7 -I/usr/include/eigen3 -I/usr/include/ni -Wall -o CMakeFiles/test_code.dir/src/main.cpp.o -c /home/amai/working_workspace/src/test-code/src/main.cpp
当我包含时,我得到这个错误:
In file included from /usr/include/opencv2/nonfree/nonfree.hpp:46:0,
from /home/amai/working_workspace/src/test-code/src/ImageProcessing.h:4,
from /home/amai/working_workspace/src/test-code/src/ROSUnwrapper.h:13,
from /home/amai/working_workspace/src/test-code/src/main.cpp:17:
/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 /home/amai/working_workspace/src/test-code/src/ImageProcessing.h:4,
from /home/amai/working_workspace/src/test-code/src/ROSUnwrapper.h:13,
from /home/amai/working_workspace/src/test-code/src/main.cpp:17:
/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 /home/amai/working_workspace/src/test-code/src/ImageProcessing.h:4,
from /home/amai/working_workspace/src/test-code/src/ROSUnwrapper.h:13,
from /home/amai/working_workspace/src/test-code/src/main.cpp:17:
/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;
我试过使用命名空间std;在此之前,包括像这个解决方案指定,但它没有帮助。我已经安装了非自由库,并确保它们像许多解决方案所描述的那样被链接起来,但到目前为止,唯一已经消除了向量相关错误的是放入以下行:
#include <vector>
using namespace std;
直接放入include文件中。但是,这并不能消除其他include问题。
此问题是由于安装没有CUDA支持的OpenCV库导致的。要解决这个问题,使用CUDA从源代码编译OpenCV。