2

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

Courier
  • 920
  • 2
  • 11
  • 36
  • did you add it to `package.xml` accordingly ? `cv_bridge` `cv_bridge` – Vtik May 17 '16 at 11:07
  • yes. In fact I specified the need of cv_bridge when creating the package – Courier May 17 '16 at 11:09
  • weird, try this answer http://stackoverflow.com/questions/36613363/ros-cant-find-opencv-the-path-usr-local – Vtik May 17 '16 at 11:14
  • Does not seem providing a solution to the problem – Courier May 17 '16 at 11:45
  • it seems like you are trying the new OpenCV 3.1 with ros indigo. did you try using [openCV3](http://wiki.ros.org/opencv3) or did you install it yourself ? maybe it's better using `ros-indigo-opencv3`. I didn't try it myself though ! – Vtik May 17 '16 at 12:22
  • I installed opencv 3.1 myslef. In fact I just reinstalled following this link http://stackoverflow.com/questions/25726768/opencv-3-0-trouble-with-installation – Courier May 18 '16 at 03:45
  • Just to point out that previously removed and re-installed ros-indigo.... maybe this is the source of the problem.. (?) – Courier May 18 '16 at 03:47

1 Answers1

1

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 (?).

Courier
  • 920
  • 2
  • 11
  • 36
  • I get an error that the make[2]: *** No rule to make target `/usr/lib/x86_64-linux-gnu/libopencv_ts.so.2.4.8', needed by `/home/johann/catkin_ws/devel/lib/libimage_converter.so'. Stop. after following your steps, have you had anything similar? – JTIM Jul 27 '16 at 12:32
  • I had this issue a time ago. I ended up wiping out everything and reinstalling opencv. Have you installed both opencv from source and that coming with ros (full desktop)? If so, remove ros and uninstall the standalone opencv (with sudo make uninstall, make clean, etc..). Reinstall ROS and opencv again. BUT NOTE, install opencv with `./configure --prefix=DIFF_PATH`, where `DIFF_PATH` sould be different from `/usr/*` so as to avoid any system confusion. Eg. I usually set `DIFF_PATH=~/soft/lib/opencv/build`. Hope this helps. – Courier Jul 28 '16 at 07:34