我正在尝试使用Ubuntu 14.04下的catkin_make在ROS indigo中编译C ++代码。我收到以下错误:
/usr/local/include/opencv2/nonfree/features2d.hpp:73:21: error: ‘vector’ has not been declared
vector<KeyPoint>& keypoints) const;
^
/usr/local/include/opencv2/nonfree/features2d.hpp:73:27: error: expected ‘,’ or ‘...’ before ‘<’ token
vector<KeyPoint>& keypoints) const;
^
/usr/local/include/opencv2/nonfree/features2d.hpp:77:21: error: ‘vector’ has not been declared
vector<KeyPoint>& keypoints,
^
/usr/local/include/opencv2/nonfree/features2d.hpp:77:27: error: expected ‘,’ or ‘...’ before ‘<’ token
vector<KeyPoint>& keypoints,
有没有人有线索,问题可能是什么?请注意,此错误发生在OpenCV的feature2d.hpp中(因此它不是我制作的文件)。我已经尝试重新安装OpenCV和ROS,但这并没有解决错误。
如果有人知道如何解决这个问题,我将非常感激。
谢谢,
雪
编辑:这是CMakeLists.txt:
cmake_minimum_required (VERSION 2.8.3)
project (test)
set (test_VERSION "1.0.0")
find_package( OpenCV REQUIRED )
if ( NOT OpenCV_FOUND )
message(FATAL_ERROR "Package OpenCV required, but not found!")
endif( NOT OpenCV_FOUND )
find_package( Eigen3 REQUIRED )
include_directories(
${EIGEN3_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${OpenCV_INCLUDE_DIRS}
)
set (SOURCE
src/test.cpp)
add_library (test ${SOURCE})
set_target_properties (test PROPERTIES
COMPILE_FLAGS "-std=c++11")
target_link_libraries( test ${OpenCV_LIBS} ${EIGEN3_LIBRARY_DIRS})
答案 0 :(得分:2)
我有点修复它,但我想这不是正确的做法:
ROS已经推出了OpenCV版本。在我的电脑上,我还安装了一个单独的较新的OpenCV版本。我通过更改目录opencv
中的两个文件夹opencv2
和/opt/ros/indigo/include
的名称来修复它。现在,编译器不再使用ROS的OpenCV,而是我安装的那个,这正在解决我的问题。
同样,我认为不应该如何做,所以如果有人有更好的想法,请告诉我!
答案 1 :(得分:-1)
尝试在包含opencv2之前编写:
#include <vector>
using namespace std;