ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

compile with different opencv

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

rnunziata gravatar image

updated 2017-10-06 10:38:12 -0500

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 flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
0

answered 2017-10-06 03:11:20 -0500

ROSkinect gravatar image

updated 2017-10-06 09:57:18 -0500

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
)
edit flag offensive delete link more

Comments

Hello, I have two opencv folder under /usr/local which is opencv and opencv2. If I want to use opencv2 as the include library, then I should specific /usr/local/opencv2 in the PATHS option? Thanks in advance.

BCJ gravatar image BCJ  ( 2020-06-13 23:17:00 -0500 )edit

You can add next OpenCV the version you want to work with, for eg. find_package(OpenCV 4.01 REQUIRED ...

ROSkinect gravatar image ROSkinect  ( 2020-06-14 09:16:25 -0500 )edit
0

answered 2017-10-06 07:59:38 -0500

TTDM gravatar image

updated 2017-10-06 08:22:27 -0500

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.

edit flag offensive delete link more

Comments

Without find_package(OpenCV) in CMakeLists file?

ROSkinect gravatar image ROSkinect  ( 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)

TTDM gravatar image TTDM  ( 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

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

Question Tools

3 followers

Stats

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

Seen: 3,909 times

Last updated: Oct 06 '17