# compile with different opencv

I would like to compile a ros package skimap_ros with a local version on opencv. All my attempts at overriding the libraries in the CMakeLists.txt have failed ...it keeps taking the opencv from /usr. Does anyone know how to do this in ROS. Thank you\

getting erros of the form:

/usr/include/opencv2/nonfree/features2d.hpp:143:47: error: expected ‘,’ or ‘...’ before ‘<’ token void computeImpl( const Mat& image, vector<keypoint>& keypoints, Mat& descriptors ) const;

path is wrong should be /home/rjn/opencv-2.4.13.3/install/

have tried specifying on catkin build line

-DOpenCV_DIR="-L/home/rjn/opencv-2.4.13.3/install/lib -I/home/rjn/opencv-2.4.13.3/install/include"

and

-DCPPFLAGS="-L/path/to/opencv2.4.9/lib -I/path/to/opencv2.4.9/include"

and overriding directly in CMakeLists

The directory: exist

/home/rjn/opencv-2.4.13.3/install/include/opencv2/nonfree

edit retag close merge delete

Sort by » oldest newest most voted

It would be nice if you can share what have you tried but this is how I would do it:

find_package(OpenCV REQUIRED
NO_MODULE #Should be optional, tells CMake to use config mode
PATHS /usr/local # Tells CMake to look here
NO_DEFAULT_PATH #and don't look anywhere else
)

more

I had plenty of trouble using find_package to locate the good opencv version ( even with the no default path option and the PATH option correctly set up, it did not work ) and I was doing some awfull stuf inside my cmakelist in order to correct it.

So if you also have troubles with it, somebody gave me an easy way to deal with it:

Delete all your workspace builded files (in your workspace you have 3 folders : src/build/devel, delete build and devel), simply call find_package(OpenCV) in the CMakeLists files ( without any location ) then your catkin make call should be :

catkin_make -DOpenCV_DIR=<your OpenCV path>


it should compile with your desired version ;)

Edit : only your first catkin_make call needs the OpenCV_DIR option, once the workspace is builded, the location is kept in memory. But each time you purge your package, you will need to think about adding the OpenCV_DIR option.

more

Without find_package(OpenCV) in CMakeLists file?

( 2017-10-06 08:12:33 -0500 )edit

It sitll needs the find package Opencv but you don't have to specify the location inside your CmakeList. (answer edited)

( 2017-10-06 08:17:35 -0500 )edit

As an answer to the edit in the question : The opencvDir is the directory in which you find the OpenCVConfig.cmake file ( usualy in the /installed directory of your installation ). Sorry for the delay

( 2017-10-09 11:18:58 -0500 )edit

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

## Stats

Asked: 2017-10-05 17:44:14 -0500

Seen: 1,574 times

Last updated: Oct 06 '17