0
$\begingroup$

I want to use cv_bridge in a conda environment. It works well in base environment but not in the conda environment. I am getting the following error :

from cv_bridge.boost.cv_bridge_boost import getCvType
ImportError: /lib/x86_64-linux-gnu/libp11-kit.so.0: undefined symbol: ffi_type_pointer, version LIBFFI_BASE_7.0

I tried installing the package using dpkg but it still didnt work. Any suggestions, please?

$\endgroup$

2 Answers 2

1
$\begingroup$

I have also faced the exact same issue with cv_bridge inside a conda environment (Ubuntu 20.04, ROS Noetic, Python 3.8 env).

The workaround that works for me is to instead use ros-numpy when I want to convert an Image message from ROS to a numpy array. You can then do other transformations on it as needed. Do note that since its dependent on ROS, you need to install it by either sudo apt install ros-${ROS_DISTRO}-ros-numpy or cloning to your workspace.

Example:

# im = self.cv_bridge.imgmsg_to_cv2(rgb_image_message) # Earlier version
im = ros_numpy.numpify(rgb_image_message)
$\endgroup$
3
  • $\begingroup$ Ohh thanks!Do i publish this like a normal msg then? $\endgroup$
    – CM A
    Commented Sep 10, 2023 at 15:36
  • $\begingroup$ Yes, sure! It can also be used to convert the array back to a ros message. In the above example, if you want to re-publish the im numpy array back as an Image message, then you can do: img_msg = ros_numpy.msgify(Image, im, encoding='bgr8') You can change the encoding depending on the image type (depth, rgb, bgr etc). More examples are shown in the ros-numpy README. $\endgroup$
    – ninception
    Commented Sep 11, 2023 at 18:08
  • $\begingroup$ Hi , im getting an error saying in ros_numpy has no attribute msgify() , and i checked the list of functions in the module and it only has ['builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'path', 'spec'] $\endgroup$
    – CM A
    Commented Sep 11, 2023 at 19:40
0
$\begingroup$

If you want to use a ROS package like cv_bridge in a conda environment with conda-forge packages, a possible option is to install ROS itself directly in the conda environment with RoboStack, i.e. running:

conda install -c conda-forge -c robostack-staging ros-noetic-cv-bridge

if you are using Noetic or

conda install -c conda-forge -c robostack-staging ros-humble-cv-bridge

if you are using Humble.

In general, your problem is related to the fact that you can't mix apt packages (like cv_bridge in your case) and conda packages (as Python). Similar problem may happen if you try to mix conda packages from conda-forge and from the defaults/anaconda channel, as in general they are not ABI compatible. RoboStack packages are only ensured to be ABI compatible with conda-forge packages.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.