Courier
Courier

Reputation: 930

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

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

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

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 experience such problems....

Upvotes: 2

Views: 5878

Answers (1)

Courier
Courier

Reputation: 930

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. But I do not think it the correct way to do (?).

Upvotes: 1

Related Questions