如何使用CMake将opencv链接到ROS indigo(catkin)(ubuntu 14.04)

时间:2016-05-17 10:59:13

标签: opencv compilation ros

到目前为止还无法使用cv_bridge。我得到了这个编译错误

CMake Error at /opt/ros/indigo/share/cv_bridge/cmake/cv_bridgeConfig.cmake:106 (message):
  Project 'cv_bridge' specifies '/usr/include/opencv' as an include dir,
  which is not found.  It does neither exist as an absolute directory nor in
  '/opt/ros/indigo//usr/include/opencv'.  Ask the maintainer ..

可能是我的CMake中的问题(...?)

cmake_minimum_required(VERSION 2.8.3)
project(XY)

find_package(catkin REQUIRED COMPONENTS
cv_bridge
image_transport
roscpp
rospy
std_msgs
)

#set(OpenCV_DIR "/usr/local/lib/opencv")
find_package(OpenCV REQUIRED core imgproc highgui PATHS /home/polar/soft/lib/opencv/opencv-3.1.0/cmake)
include_directories( ${OpenCV_INCLUDE_DIRS} )

if(OpenCV_FOUND)
# include_directories(${Boost_INCLUDE_DIRS})
message("\n\n OpenCV found!!!! \n\n")   
endif()

对问题的原因有什么想法,请问如何解决? 我过去使用的是ROS fuerte,从未遇到过这样的问题......

1 个答案:

答案 0 :(得分:1)

最后,我修改了文件/opt/ros/indigo/share/cv_bridge/cmake/cv_bridgeConfig.cmake 我变了 set(cv_bridge_FOUND_CATKIN_PROJECT TRUE) if(NOT" include; / usr / include / opencv; / usr / include" STREQUAL"")   设置(cv_bridge_INCLUDE_DIRS"")   set(_include_dirs" include; / usr / include / opencv; / usr / include") 至 set(cv_bridge_FOUND_CATKIN_PROJECT TRUE) if(NOT" include; / usr / local / include / opencv" STREQUAL"")   设置(cv_bridge_INCLUDE_DIRS"")   set(_include_dirs" / usr / local / include / opencv; / usr / include; / usr / local / include") 事实上我只是将usr / include更改为/ usr / local / include。这解决了我的问题。但我不认为这是正确的做法(?)。