我使用opencv 2.4.8和libnonfree-dev中的非空闲库。 这是我的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;在指定包含类似this解决方案之前,但它没有帮助。我已经安装了非自由库并确保它们像许多解决方案所描述的那样被链接,但到目前为止,唯一消除了与向量相关的错误的是放置这些行:
#include <vector>
using namespace std;
直接进入包含文件。但是,这不会消除其他包含问题。
答案 0 :(得分:2)
此问题是由安装没有CUDA支持的OpenCV库引起的。要解决此问题,请使用CUDA从源代码编译OpenCV。