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

Revision history [back]

click to hide/show revision 1
initial version

Hello previous me,

So you have the opencv3 package installed, which provides libraries in /opt/ros/kinetic/lib, and you also have OpenCV compiled from source, installed to usr/local. The trick is to tell catkin to use the libraries from usr/local.

By default, catkin is hardwired to look for packages in your workspace, then in /opt/ros/kinetic. CMake by itself will use the libraries in /usr/local. I tried to prioritize /usr/local by modifying the CMAKE_PREFIX_PATH environment variable, as suggested in pre kinetic posts, but no luck.

So if I cannot modify catkin itself, I should to explicitly tell CMake which OpenCV to use. I had to change my declaration from

find_package(OpenCV REQUIRED)

to

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

So that will pull in the correct libraries. If another package is built that requires OpenCV, catkin will also pull in the wrong dependencies. Mixed dependencies is a bad thing. So you have to add the modified OpenCV configuration to any other packages that require OpenCV.

Hello previous me,

So you have the opencv3 package installed, which provides libraries in /opt/ros/kinetic/lib, and you also have OpenCV compiled from source, installed to usr/local. The trick is to tell catkin to use the libraries from usr/local.

By default, catkin is hardwired to look for packages in your workspace, then in /opt/ros/kinetic. CMake by itself will use the libraries in /usr/local. I tried to prioritize /usr/local by modifying the CMAKE_PREFIX_PATH environment variable, as suggested in pre kinetic posts, but no luck.

So if I cannot modify catkin itself, I should to explicitly tell CMake which OpenCV to use. I had to change my declaration from

find_package(OpenCV REQUIRED)

to

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

So that will pull in the correct libraries. If another package is built that requires OpenCV, catkin will also pull in the wrong dependencies. Mixed dependencies is a bad thing. So you have to add the modified OpenCV configuration to any other packages that require OpenCV.

OpenCV. This includes the vision_opencv package that provides cv_bridge.

Hello previous me,

So you have the opencv3 package installed, which provides libraries in /opt/ros/kinetic/lib, and you also have OpenCV compiled from source, installed to usr/local. The trick is to tell catkin to use the libraries from usr/local.

By default, catkin is hardwired to look for packages in your workspace, then in /opt/ros/kinetic. CMake by itself will use the libraries in /usr/local. I tried to prioritize /usr/local by modifying the CMAKE_PREFIX_PATH environment variable, as suggested in pre kinetic posts, but no luck.

So if I cannot modify catkin itself, I should to explicitly tell CMake which OpenCV to use. I had to change my declaration from

find_package(OpenCV REQUIRED)

to

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

So that will pull in the correct libraries. If another package is built that requires OpenCV, catkin will also pull in the wrong dependencies. Mixed dependencies is a bad thing. So you have to add the modified OpenCV configuration to any other packages that require OpenCV. This includes the vision_opencv package that provides cv_bridge.

UPDATE 10/12/2017: Please see my fork of vision_opencv for the necessary changes and my cvTest example package.

Hello previous me,

So you have the opencv3 package installed, which provides libraries in /opt/ros/kinetic/lib, and you also have OpenCV compiled from source, installed to usr/local. The trick is to tell catkin to use the libraries from usr/local.

By default, catkin is hardwired to look for packages in your workspace, then in /opt/ros/kinetic. CMake by itself will use the libraries in /usr/local. I tried to prioritize /usr/local by modifying the CMAKE_PREFIX_PATH environment variable, as suggested in pre kinetic posts, but no luck.

So if I cannot modify catkin itself, I should to explicitly tell CMake which OpenCV to use. I had to change my declaration from

find_package(OpenCV REQUIRED)

to

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

So that will pull in the correct libraries. If another package is built that requires OpenCV, catkin will also pull in the wrong dependencies. Mixed dependencies is a bad thing. So you have to add the modified OpenCV configuration to any other packages that require OpenCV. This includes the vision_opencv package that provides cv_bridge.

UPDATE 10/12/2017: Please see my fork of vision_opencv for the necessary changes and my cvTest example package.

package. In the example, I demonstrate the use of my custom version of OpenCV 3.3 build with CUDA 8.