OpenCV 编译错误与非自由/feature2d.hpp.
OpenCV compiling error with nonfree/feature2d.hpp
我正在尝试使用 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})
我有点修复它,但我想这不是正确的方法:
ROS已经推出了OpenCV版本。在我的电脑上,我还安装了一个单独的较新的OpenCV版本。我通过更改目录中两个文件夹的名称来修复它 opencv
和 opencv2
目录 /opt/ros/indigo/include
.现在,编译器不再使用ROS的OpenCV,而是我安装的OpenCV,它正在解决我的问题。
再说一次,我认为这不是应该这样做的方式,所以如果有人有更好的主意,请告诉我!
尝试在
包含opencv2之前编写:
#include <vector>
using namespace std;
相关文章:
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 什么是"#include <boost/functional/hash.hpp> "?
- 使用Vulkan hpp vk::enumerateInstanceVersion()会导致segfault
- 如何将class.cpp和class.hpp编译为一个.o文件
- g++ -I 和 -L 命令来查找不起作用的 .hpp 文件
- VS Code C++:不准确的系统包括路径错误(wchar.h,boost/lambda/lambda.hpp)
- Gnuplot_i.hpp C++接口绘制局部变量而不是文件
- 致命错误:找不到'boost/uuid/uuid.hpp'文件
- BGL:当包含 random_spanning_tree.hpp 时,对strong_components的调用无法编译
- 造成致命错误:boost/fusion/iterator/equal_to.hpp 没有这样的文件或目录
- 无法使包含.hpp文件与其中的2个文件一起使用
- 在指向现有内存地址的 hpp 文件中声明成员函数的最佳方法
- 无法打开包含文件'Graphics.hpp'没有这样的文件或目录,Visual Studio的其他包含不起作用
- 编译器正在查找.当"实施"完全在"我的"中时的CPP文件.HPP文件
- 我的项目中某些仅标头文件不能包含使用 CMake 和 Vscode 的"SFML/Graphics.hpp"
- QtCreator使用CMAKE_C_FLAGS来解释C++(hpp)标头
- 如何正确使用hpp文件和cpp文件中的嵌套类
- 错误: C1083: 无法打开包含文件:"boost/asio.hpp": 没有此类文件或目录
- C++ Boost-iostream:包含 filtering_streambuf.hpp 时出现神秘错误
- OpenCV 编译错误与非自由/feature2d.hpp.