Ask Your Question
1

How to link opencv to ROS indigo (catkin) with CMake (ubuntu 14.04)?

asked 2016-05-17 06:43:04 -0500

polar gravatar image

Am so far not able to use cv_bridge. Am getting this compilation error

Make 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 ..

May be the problem in my 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()

Any idea on the cause of the problem and how to solve it please? I was using ROS fuerte in the past and never experienced such problems....

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2016-05-17 14:03:49 -0500

William gravatar image

My guess is that you have removed OpenCV from the system (there is no folder /usr/include/opencv and there should be), and instead you're building your own opencv, as evident by the PATHS /home/polar/soft/lib/opencv/opencv-3.1.0/cmake in your find_package call.

I'd recommend ensuring OpenCV is installed using apt-get and removing the PATHS /home/polar/soft/lib/opencv/opencv-3.1.0/cmake from your find_package call.

If you need a custom version of OpenCV, then you'll need to rebuild any ROS packages using OpenCV. For example, the cv_bridge ROS package you are using depends on OpenCV, and is probably the one contributing the include directory /usr/include/opencv which no longer exists since you removed it.

This doesn't have anything to do with Fuerte versus Indigo.

edit flag offensive delete link more
0

answered 2016-05-19 03:35:57 -0500

polar gravatar image

Finally, I modified file /opt/ros/indigo/share/cv_bridge/cmake/cv_bridgeConfig.cmake

I changed

set(cv_bridge_FOUND_CATKIN_PROJECT TRUE)

if(NOT "include;/usr/include/opencv;/usr/include " STREQUAL " ")
  set(cv_bridge_INCLUDE_DIRS "")
  set(_include_dirs "include;/usr/include/opencv;/usr/include")

to

set(cv_bridge_FOUND_CATKIN_PROJECT TRUE)
if(NOT "include;/usr/local/include/opencv" STREQUAL " ")
  set(cv_bridge_INCLUDE_DIRS "")
  set(_include_dirs "/usr/local/include/opencv;/usr/include;/usr/local/include")

In fact I just changed usr/include to /usr/local/include. This solved my problem.

edit flag offensive delete link more

Comments

2

Beware that any future update of that package will undo your fix.

joq gravatar imagejoq ( 2016-05-19 08:07:31 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2016-05-17 06:43:04 -0500

Seen: 3,797 times

Last updated: May 19 '16