0
$\begingroup$

Rosanswers logo

Hi All

I've build OpenCV 2.4.9 from source and installed in "/opt/opencv". Meanwhile I have installed ROS Hydro which has ros-hydro-opencv2. Now I'm developing a catkin package that depends on OpenCV. My Cmake settings is as follows:

cmake_minimum_required(VERSION 2.8)
project(marker_finder)

set(CMAKE_PREFIX_PATH "/opt/opencv" ${CMAKE_PREFIX_PATH})

####################################################
# Dependencies:
find_package(catkin REQUIRED COMPONENTS roscpp roslib)
find_package( OpenCV REQUIRED )

####################################################
# Build library.
    
catkin_package(
  INCLUDE_DIRS include
  LIBRARIES marker_finder
  CATKIN_DEPENDS roscpp roslib
  DEPENDS opencv
  )

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
  )


message(STATUS ${OpenCV_INCLUDE_DIRS})

SET(MF_LIB_SRCS
  src/...  
  )
  
SET(MF_LIB_HDRS
  include/...
  )

add_library (marker_finder ${MF_LIB_SRCS} ${MF_LIB_HDRS})

target_link_libraries (marker_finder
  GL
  GLU
  ${catkin_LIBRARIES}
  ${OpenCV_LIBRARIES})
  
install(TARGETS marker_finder LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
install(DIRECTORY include/marker_finder/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})

The output of

message(STATUS ${OpenCV_INCLUDE_DIRS})

is

/opt/ros/hydro/include/opencv/opt/ros/hydro/include

Which is not what I expected.

/opt/opencv/include

So how can I make CMake find the correct OpenCV package I want ?


Originally posted by YuhuaZou on ROS Answers with karma: 11 on 2014-07-23

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

My personal workaround for this was to specify the version to the version (different from ros opencv version) I installed (it was to /usr/local/include in my case, though)

  find_package( OpenCV 2.4.7 EXACT REQUIRED )

Nicer solutions welcome;)


Originally posted by Wolf with karma: 7555 on 2014-07-23

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by YuhuaZou on 2014-07-24:
Thanks! This could be a solution. The version of my own build OpenCV is the same with that of the ros-hydro-opencv2. So I have to manually change the version info in "OpenCVConfig.cmake" to make them be different. It works now. But still looking forward to better solution.

Comment by tfoote on 2014-09-26:
There's probably a cleaner solution to be found by making sure which order the different installations appear on the various search paths.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.