How to fix OpenCV x ROS/cv_bridge version issues?

asked 2021-09-01 15:52:02 -0500

msantos gravatar image

Hi,

After reading the questions #q352756, #q382266 and #q293333. I believe the issue I am having:

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

Is sort of conflict between different OpenCV versions/installations, as suggested in the answers for the question #q385309 I made a few days ago. I have installed OpenCV (for C++) from this tutorial, but it looks like ROS melodic (or Ubuntu 18?) come with a built-in OpenCV lib, to be used together. Is my understanding OK?

When I ran locate OpenCVConfig.cmake I got:

/home/user/.local/share/Trash/files/opencv/cmake/templates/OpenCVConfig.cmake.in
/home/user/.local/share/Trash/files/opencv.2/build/OpenCVConfig.cmake
/home/user/.local/share/Trash/files/opencv.2/build/unix-install/OpenCVConfig.cmake
/home/user/.local/share/Trash/files/opencv.2/opencv-master/cmake/templates/OpenCVConfig.cmake.in
/opt/opencv/cmake/templates/OpenCVConfig.cmake.in
/opt/opencv/release/OpenCVConfig.cmake
/opt/opencv/release/unix-install/OpenCVConfig.cmake
/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake
/usr/share/OpenCV/OpenCVConfig.cmake

And specially for the last 4 lines, I think I have at least two different installations of OpenCV. How can I fix it, in order to have just one (the ros-suitable one)?

I can be also good to mention:

the output for pkg-config --modversion opencv is:

3.2.0 and for sudo apt-get install libopencv-dev is:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
libopencv-dev is already the newest version (3.2.0+dfsg-4ubuntu0.1).
The following packages were automatically installed and are no longer required:
  libc-ares2 libgraphviz-dev libgvc6-plugins-gtk libhttp-parser2.7.1 libllvm7 libnvidia-cfg1-455 libnvidia-common-455 libnvidia-compute-455 libnvidia-compute-455:i386 libnvidia-decode-455
  libnvidia-decode-455:i386 libnvidia-encode-455 libnvidia-encode-455:i386 libnvidia-extra-455 libnvidia-fbc1-455 libnvidia-fbc1-455:i386 libnvidia-gl-455 libnvidia-gl-455:i386 libnvidia-ifr1-455
  libnvidia-ifr1-455:i386 libopenal-dev libqtpropertybrowser4 libxdot4 linux-hwe-5.4-headers-5.4.0-54 linux-hwe-5.4-headers-5.4.0-56 linux-hwe-5.4-headers-5.4.0-58 linux-hwe-5.4-headers-5.4.0-59
  linux-hwe-5.4-headers-5.4.0-60 linux-hwe-5.4-headers-5.4.0-62 linux-hwe-5.4-headers-5.4.0-65 linux-hwe-5.4-headers-5.4.0-66 linux-hwe-5.4-headers-5.4.0-67 linux-hwe-5.4-headers-5.4.0-70
  linux-hwe-5.4-headers-5.4.0-72 linux-hwe-5.4-headers-5.4.0-73 linux-hwe-5.4-headers-5.4.0-74 linux-hwe-5.4-headers-5.4.0-77 nodejs-doc nvidia-compute-utils-455 nvidia-dkms-455 nvidia-utils-455
  xserver-xorg-video-nvidia-455
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
edit retag flag offensive close merge delete

Comments

1

Did you see #q289264?

gvdhoorn gravatar image gvdhoorn  ( 2021-09-02 01:33:05 -0500 )edit

Hi, To be honest I checked it i the previous topic you suggested, but not understood well. I will try to follow those steps. Perhaps I'll point it out if something goes wrong.

Thanks.

msantos gravatar image msantos  ( 2021-09-02 13:27:41 -0500 )edit

Hi, @gvdhoom, I tried to: -Completely remove ROS from my System. -Remove all the OpenCV installations that I did. Then, no ROS, no Open CV. I just installed ROS again.

It seems to install a open CV with it:

Setting up libopencv-shape-dev:amd64 (3.2.0+dfsg-4ubuntu0.1) ...

And I can check there is an OpenCV installed after installing ROS. However, my catkin_make still not able to find its references...

msantos gravatar image msantos  ( 2021-09-22 15:17:53 -0500 )edit

I'm not sure I understand your last comment.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-23 05:21:40 -0500 )edit

I tried to compile with the "natural" openCV installed with/by ROS, when reinstalling ROS. And it was giving the same compilation error.

I searched and set this "ROS-given" OpenCV manually, to be able to compile.

Since the error is now different:

/home/user/Documents/ROS/cv2_ws/devel/lib/test_opencv_pkg/rgbd_odometry(_start+0x2a)[0x55f1f9db9e8a]
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::lock_error> >'
pure virtual method called
terminate called recursively
Aborted (core dumped)

Can I assume the main issue for this question is now gone? And then, close this question, for sure.

msantos gravatar image msantos  ( 2021-09-23 13:22:08 -0500 )edit

You've now most likely arrived at the situation we typically warn people about when they ask how to "upgrade to version X of dependency Y" (where Y is a library which gets set to a specific version by the ROS buildfarm).

The coredump is probably caused by an ABI incompatibility caused by linking two different versions of the same dependency to your node, or to one of its dependencies.

This would be the reason why you'd need to build all dependees from source.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-23 13:57:56 -0500 )edit

But in that case, following the procedures you shared earlier in this thread. Should I clone OpenCV inside my WS and build it, instead of using the "ROS provided" OpenCV? If you see my original question and my last comment, looks like I could fix the mistake of having two different openCV installations. Now I have just the one installed with ROS.

Does this error I am having now (pure virtual stuff) seem to be a code error one? Because it is different from the version compatibility error I've had before purging ROS and OpenCV

msantos gravatar image msantos  ( 2021-09-23 14:38:43 -0500 )edit

I'm again unsure as to what you've done exactly. I interpreted:

I searched and set this "ROS-given" OpenCV manually

to mean you have a from-source compiled OpenCV version (other than the one packaged by the ROS buildfarm) and have pointed CMake at it while building a ROS package which depends on OpenCV.

If that's not the case, then ignore my comment.

gvdhoorn gravatar image gvdhoorn  ( 2021-09-23 14:42:14 -0500 )edit