[OpenCV and Python 2] "No module named cv_bridge_boost" on Windows

asked 2018-09-04 04:43:56 -0600

Eduardo Alvarado gravatar image

updated 2018-09-04 06:34:50 -0600

I am writing a python script on Windows, which uses the package cv_bridge. I already have installed Python 2.7.18 and pip in Windows 10, as well as OpenCV (cv2) and the package cv_bridge.

I can import OpenCV without problem in my python script by doing import cv2

The problem comes with the following line:

from cv_bridge.boost.cv_bridge_boost import getCvType

It returns the following error:

ImportError: No module named cv_bridge_boost

The way I used to install cv_bridge was by installing the setup.py of the package (https://github.com/ros-perception/vision_opencv)

Then, I realized that this method didn't create any boost.cv_bridge_boost inside my Python path (C:\Python27\Lib\site-packages\cv_bridge). So, what I did, was to seach in my Ubuntu System (where the package cv_bridge works fine), and copy the missing files.

Finally, I ended up having in my C:\Python27\Lib\site-packages\ the following: a cv2 folder which contains all OpenCV files, and a cv_bridge folder (the package). Inside, a folder boost with the files __init__,py and cv_bridge_boost.so.

I though that was the correct way, but even having the file, the script is still returning the same error.

By searching I saw that the problem is probably in this last file (cv_bridge_boost.so), but until now I just found solutions for MacOS. What about Windows? Did someone have a problem with this file before? Thank you in advance.

edit retag flag offensive close merge delete

Comments

You tagged this as Kinetic: just making sure, you do have a ROS 1 Kinetic install on Windows?

gvdhoorn gravatar image gvdhoorn  ( 2018-09-04 05:03:08 -0600 )edit

No, it´s not installed. The Python script that I am writing doesn't need of roscore to work. However, I need single packages from Kinetic for the script, so I´ve been installing them (such as rosbag). The script is totally independent from roscore.

Eduardo Alvarado gravatar image Eduardo Alvarado  ( 2018-09-04 06:09:26 -0600 )edit

.so files are shared object files for Linux based platforms, you cannot use those on Windows.

You'll have to somehow get the cv_bridge_boost libraries built on Windows. That is what I meant with my question "you have installed * on Windows?".

gvdhoorn gravatar image gvdhoorn  ( 2018-09-04 11:10:34 -0600 )edit

Understood then. Since I don´t have ROS installed on Windows, only the packages that I build on Ubuntu, is there any possibility to obtain such libraries to use the package cv_bridge on Windows? There must be a way, but oddly I don't find any.

Eduardo Alvarado gravatar image Eduardo Alvarado  ( 2018-09-05 00:29:45 -0600 )edit

I'm not terribly familiar with the build process of those cv_bridge_python libraries, but you'd probably have to somehow get them build. That may not be trivial (as C++<->Python integration never is, and you're doing it on an 'unsupported' platform). I'm sorry I can't help you with this now.

gvdhoorn gravatar image gvdhoorn  ( 2018-09-05 01:24:03 -0600 )edit

Perhaps you can tell us what you ultimately want to do. This might be an xy-problem and we might be spending time on solving something that isn't needed.

gvdhoorn gravatar image gvdhoorn  ( 2018-09-05 01:24:56 -0600 )edit

My Python script which runs on Windows, takes video-data from a .bag file and shows it on a GUI, which uses QWidgets (PyQT). I already managed to use the rosbag API to take the video, but in order to display it I need to convert it by using OpenCV.

Eduardo Alvarado gravatar image Eduardo Alvarado  ( 2018-09-05 02:22:34 -0600 )edit

Here´s where cv_bridge comes out, linking the .bag file and OpenCV. In my script I use a function which belongs to the package (imgmsg_to_cv2), which takes the image from the .bag and converts it to cv2, and it needs to access cv_bridge_boost. That would be a preview about what my script does

Eduardo Alvarado gravatar image Eduardo Alvarado  ( 2018-09-05 02:27:28 -0600 )edit