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

specify openCV version ROS melodic, Ubuntu 18.04

asked 2020-05-19 09:56:43 -0600

marko1990 gravatar image

updated 2020-05-19 10:02:02 -0600

Hello everyone,

I am a bit confused here, the problem which happens to me is, I have made a ROS node some time ago, the node has been working just fine, until recently I decided to install the new openCV 4.3 (cloned and installed from source). I have done it because I wanted to use the third party library which I wanted to depend on the openCV 4.3 so I can have some additional options. In my node's CMakeList.txtI have defined OpenCV_DIR to point the OpenCVConfig.cmake of the openCV4.3. I think this went through just fine. From what I know, the Ubuntu 18.04 comes with already installed OpenCV3.2 and this is the version which is used by the cv_bridge package. When I run the node the problem which happens is:

OpenCV Error: Assertion failed (tlsSlots.size() > slotIdx) in releaseSlot, file /build/opencv-L2vuMj/opencv-3.2.0+dfsg/modules/core/src/system.cpp, line 1092 terminate called after throwing an instance of 'cv::Exception' what(): /build/opencv-L2vuMj/opencv-3.2.0+dfsg/modules/core/src/system.cpp:1092: error: (-215) tlsSlots.size() > slotIdx in function releaseSlot

If I have to guess I would say this is because there are two conflict libraries loaded, after running:

ldd <binary> | grep libopencv_core

I got this back:

libopencv_core.so.3.2 => /usr/lib/x86_64-linux-gnu/libopencv_core.so.3.2 (0x00007fe9de973000) libopencv_core.so.4.3 => /usr/local/lib/libopencv_core.so.4.3 (0x00007fe9db2e2000)

So this confirms the conflict between libraries, so since I have loaded the openCV 4.3 (with the third party library) I would say that the libopencv_core.so.3.2 is loaded because of the cv_bridge package. cv_bridge is used to get the image from the sensor_msgs::ImageConstPtrand this image is given as an argument to the object of the third party library (which previously has been built with the opencv 4.3) I tried to debug and the cv_bridge works just fine, but when the third party object tries to execute certain functions, it raises a previously mentioned exception. I think it is because of the conflict, do you guys have any idea how to fix this? Or do you have any idea for a workaround? This is frustrating because I am using the cv_bridge only in one line, just to get the image for the third party library.

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2020-05-21 02:58:14 -0600

marko1990 gravatar image

There cannot be a binary or a lib which depends or loads two version of the same source, in this case there will always be a conflict.

edit flag offensive delete link more
0

answered 2022-01-02 11:10:30 -0600

Asan A. gravatar image

I had a similar problem, and solved it by modifying cv_bridgeConfig.cmake file.

cd /opt/ros/melodic/share/cv_bridge/cmake

sudo gedit cv_bridgeConfig.cmake

Replaced line 96

set(_include_dirs "include;/usr/include;/usr/include/opencv2")

and line 119#

set(libraries "cv_bridge;/usr/local/lib/libopencv_core.so.4.5.4;/usr/local/lib/libopencv_imgproc.so.4.5.4;/usr/local/lib/libopencv_imgcodecs.so.4.5.4")

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2020-05-19 09:56:43 -0600

Seen: 2,919 times

Last updated: Jan 02 '22