Robotics StackExchange | Archived questions

Using external opencv version - kinetic

I need to use OpenCV dnn for a ROS node. Since the default OpenCV version that comes with kinetic does not have support for all the functionality that I need, I installed OpenCV4. Then I did the following in the CMake to get it to work.

set(OpenCV_DIR "/usr/local/lib/")
FIND_PACKAGE(OpenCV 4 REQUIRED)

This works fine. Problem arises when I try to use some image related packages (which might be trying to use the ROS OpenCV).

In my node, next I need some image_geometry functionalities. But when I put image_geometry in the find_package, it starts to give me compile errors starting from the message error: ‘dnn’ in namespace ‘cv’ does not name a type. These are the same compile errors I get if I use the cv_bridge instead of OpenCV4.

Does anybody have a workaround for this? Some way to point image_geometry (or any other ROS package using OpenCV) to an OpenCV version other than the ROS OpenCV version.

Asked by teshansj on 2019-08-19 06:06:42 UTC

Comments

I believe OpenCV is no different from other system dependencies in this case. See whether #q289264 helps.

Asked by gvdhoorn on 2019-08-19 08:21:49 UTC

Try running the following code at top:

import sys
sys.path.remove('/opt/ros/kinetic/lib/python2.7/dist-packages')

Asked by parzival on 2019-08-19 15:31:25 UTC

@parzival This node is in c++

Asked by teshansj on 2019-08-19 22:43:07 UTC

Answers