Ask Your Question
1

How to link own build OpenCV instead of ros-hydro-opencv

asked 2014-07-23 02:59:32 -0500

YuhuaZou gravatar image

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 ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-07-23 08:04:29 -0500

Wolf gravatar image

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;)

edit flag offensive delete link more

Comments

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.

YuhuaZou gravatar image YuhuaZou  ( 2014-07-24 02:26:01 -0500 )edit

There's probably a cleaner solution to be found by making sure which order the different installations appear on the various search paths.

tfoote gravatar image tfoote  ( 2014-09-26 18:41:57 -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

1 follower

Stats

Asked: 2014-07-23 02:59:32 -0500

Seen: 227 times

Last updated: Jul 23 '14