Ask Your Question
0

Why cv_bridge uses opencv3.2 in ros melodic?

asked 2019-05-23 15:54:51 -0600

GeorgeG gravatar image

updated 2019-06-01 05:35:51 -0600

I have OpenCV 3.4 in my Ubuntu 18. I have installed ros melodic according to the website instructions. However, I have been getting the error:

/opt/ros/melodic/lib/image_view/image_view: error while loading shared libraries: libopencv_core.so.3.2: cannot open shared object file: No such file or directory

I found out that in the file: /ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake

there is the following line hardcoded in opencv3.2:

set(libraries "cv_bridge;/usr/lib/x86_64-linux-gnu/libopencv_core.so.3.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.3.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgcodecs.so.3.2.0")

I would like to ask why is this hardcoded to opencv 3.2 and how can I set it to 3.4? I tried to change it but I can not rebuild it.

Update: I eventually installed OpenCV 3.2 and it worked properly.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-05-24 02:57:06 -0600

gvdhoorn gravatar image

It is "hard coded" to 3.2 because that is the version of OpenCV that is officially supported by ROS for Melodic Morenia on Ubuntu Bionic. See also REP 3: Target Platforms - Platforms by Distribution - Melodic Morenia (May 2018 - May 2023).

Note the 3.2 in the row for OpenCV in the table titled Requirements, and also note the * there with the note:

" * " means that this is not the upstream version (available on the official Operating System repositories) but a package distributed by OSRF or the community (package built and distributed on custom repositories).

In order to keep the set of supported platforms managable, some choices have to be made, and as it's very difficult to find a set of dependencies that can be supported across the different OS and architectures that you see in that table, it may happen that you don't get the newest versions of some packages -- such as OpenCV.


You're next question is probably going to be: "but I need OpenCV 3.4, so how do I use OpenCV 3.4 with ROS Melodic?".

The answer would be: you'd have to build everything that uses OpenCV (even indirectly) from source in your / a Catkin workspace. See #q289264 for an overview of the steps (that Q&A is about PCL, but that's just an example).

At a high-level: you'll want to have OpenCV 3.4 installed on your system, checkout the sources of packages that depend on OpenCV in your workspace, update the build scripts (ie: CMakeLists.txt) of those packages (so that they require OpenCV 3.4 instead of 3.2) and then build the workspace.

After that, you should be able to use OpenCV 3.4 with your locally build ROS Melodic.

Note: you cannot mix-and-match versions of system dependencies. This means that also future packages you install that (indirectly) depend on OpenCV you must build those from source.

edit flag offensive delete link more

Comments

I see, I already have tried in one laptop to have OpenCV 3.4 and just these three libraries from OpenCV 3.2 and it works fine, except that I am getting constantly a warning for conflict. However, in another laptop that I have only OpenCV 3.4, even if I build my project with appropriate CMakeLists the systems still complains and needs 3.2. So eventually I can have 3.4, but I have to have these three libraries from OpenCV3.2? Because even if I change this hard coded line it still complains for 3.2, so I suppose it needs to be rebuild somehow, but I don't see any CMakeList file for only this.

GeorgeG gravatar imageGeorgeG ( 2019-05-24 03:40:53 -0600 )edit

You need to build the packages from sources. You cannot just change version numbers in .cmake files in /opt/ros (in fact, you're not even supposed to be editing any files in /opt/ros).

gvdhoorn gravatar imagegvdhoorn ( 2019-05-24 03:42:30 -0600 )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

2 followers

Stats

Asked: 2019-05-23 15:20:52 -0600

Seen: 1,460 times

Last updated: Jun 01 '19