Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named cv_bridge_boost on Mac OS X #34

Closed
Lenskiy opened this issue Jun 18, 2013 · 17 comments
Closed

ImportError: No module named cv_bridge_boost on Mac OS X #34

Lenskiy opened this issue Jun 18, 2013 · 17 comments

Comments

@Lenskiy
Copy link

Lenskiy commented Jun 18, 2013

I am getting exactly the same error as in #18

I am on Mac OS 10.8.4. cv_bridge is of version 1.10.6. What do you think the cause of the error could be?

Here is the log

rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.108 image:=/camera/image_raw camera:=/camera
Waiting for service /camera/set_camera_info ...
OK
Exception in thread Thread-4:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 552, in __bootstrap_inner
    self.run()
  File "/opt/ros/groovy/lib/camera_calibration/cameracalibrator.py", line 68, in run
    self.function(m)
  File "/opt/ros/groovy/lib/camera_calibration/cameracalibrator.py", line 134, in handle_monocular
    drawable = self.c.handle_msg(msg)
  File "/opt/ros/groovy/lib/python2.7/site-packages/camera_calibration/calibrator.py", line 736, in handle_msg
    gray = self.mkgray(msg)
  File "/opt/ros/groovy/lib/python2.7/site-packages/camera_calibration/calibrator.py", line 271, in mkgray
    return self.br.imgmsg_to_cv(msg, "mono8")
  File "/opt/ros/groovy/lib/python2.7/site-packages/cv_bridge/core.py", line 101, in imgmsg_to_cv
    source_type = self.encoding_as_cvtype(img_msg.encoding)
  File "/opt/ros/groovy/lib/python2.7/site-packages/cv_bridge/core.py", line 73, in encoding_as_cvtype
    from cv_bridge.boost.cv_bridge_boost import getCvType
ImportError: No module named cv_bridge_boost
@vrabaud
Copy link
Contributor

vrabaud commented Jun 18, 2013

I guess you have 1.10.4 right ? Can you check you have a cv_bridge_boost.so file in your buidl tree ? Is that target even built ?

@Lenskiy
Copy link
Author

Lenskiy commented Jun 18, 2013

Thank you for a quick reply! package.xml in src/cv_bridge says it's version 1.10.6. The whole repository is a few days old. Regarding cv_bridge_boost there is a dynamic library here /opt/ros/groovy/lib/python2.7/site-packages/cv_bridge/boost/cv_bridge_boost.dylib

Could it be that cv_bridge_boost.dylib is not found? On the other hand it is located in the right place.I will check env variables.

@Lenskiy
Copy link
Author

Lenskiy commented Jun 18, 2013

I've checked (a) path env variables, (b) just in case copied cv_bridge_boost.dylib to /opt/ros/groovy/lib/, (c) tried to install homebrew python. Nothing works. Could it be that the problem is in version of Python? Which is 2.7.2. However, it is doubtful, because other packages work. How can I check cv_bridge version, besides looking at package.xml?
Versions of boost and opencv libraries are 1.49 and 2.4.5.
Any ides what else I can try?

@Lenskiy
Copy link
Author

Lenskiy commented Jun 19, 2013

It is weird, when I run calibration for a stereo pair, I don't get any error messages.

rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.108 right:=/stereo/right/image_raw left:=/stereo/left/image_raw left_camera:=/stereo/left right_camera:=/stereo/right
Waiting for service /stereo/left/set_camera_info ...
OK
Waiting for service /stereo/right/set_camera_info ...
OK

However the calibration windows is still incorrectly visualised. The picture is attached.
screen shot 2013-06-19 at 5 43 51 pm

@vrabaud
Copy link
Contributor

vrabaud commented Jun 19, 2013

On Ubuntu, the lib is definitely there:
/opt/ros/hydro/lib/python2.7/dist-packages/cv_bridge/boost/cv_bridge_boost.so
What is this dylib file on OSX ? What is wrong in that CMake file then ?
https://github.com/ros-perception/vision_opencv/blob/groovy-devel/cv_bridge/src/CMakeLists.txt

@Lenskiy
Copy link
Author

Lenskiy commented Jun 19, 2013

The CMake file is identical. dylib stands for dynamic library, it's the same as *.so on Linux.
I wonder why when I execute stereo calibration there are no errors. I tend to believe the problem is in visualisation. In the both cases the windows shows up, but incorrectly.

@Lenskiy
Copy link
Author

Lenskiy commented Jun 19, 2013

I also tried compiling cv_bridge and the whole groovy with boost 1.49 and 1.53, but it did not help.
I checked what symbols cv_bridge_boost exports, and I could found there is
__ZN9cv_bridge9getCvTypeERKSs

@vrabaud
Copy link
Contributor

vrabaud commented Jun 19, 2013

Since dbca650 , stereo cam uses the same code to convert to grayscale and the crash will most likely happen (it just has not been released yet). So the problem really is that you cannot load your *dylib file.
If you go in the folder where it is installed, start ipython and do "import cv_bridge_boost", what do you get ?

@Lenskiy
Copy link
Author

Lenskiy commented Jun 20, 2013

If I rename cv_bridge_boost.dylib to cv_bridge_boost.so and imports now. I don't have cameras with me, I am going to check if calibration works and get back to you. Also I found there could be some issue with python. I had python installed from brew, but I did not link it. I was expecting the default pre-installed python is used, not the brew one. It looks like they got mixed up. Have to resolve it too.

@Lenskiy
Copy link
Author

Lenskiy commented Jun 20, 2013

Vincent, there is progress! I connected the camera and after renaming the dylib to so it starts loading the library.
I am not sure why it cannot find dylib but looks for so. Any ideas what should be corrected for future releases for Mac users?

Unfortunately there are still problems.. I am not sure if have to create a new ticket.
Problem (1) When I calibrate stereo camera, the result is the same as before, no errors printed out, only broken window appears the same one I posted above. Is there any code difference in GUI initialisation between single and stereo camera calibration.

Problem (2) Even in a single camera case, the calibration process starts. It detects the pattern, however when it is ready to calibrate I cannot click calibrate, the window does not respond to any mouse actions.

@vrabaud
Copy link
Contributor

vrabaud commented Jun 20, 2013

For 1, can you please try trunk and let me know if it is fixed.
For 2, I know it works on Linux, I don't know on OSX.
For the original dylib issues, @wjwwood , can you please let me know if it is normal or whether there should be a .so file on Linux ? Can you import a boost python module compiled as a .dylib ? Thx.

@Lenskiy
Copy link
Author

Lenskiy commented Jun 20, 2013

I tried, nothing has changed. Still in the case of stereo calibration image don't show up. Single camera calibration does not allow me to click calibrate. Maybe @wjwwood has got some ideas? I will try to compare the code so single and stereo calibration, although don't have much experience coding in python. Regarding GUI in the calibration window, is it implemented by means of opencv GUI?

@wjwwood
Copy link
Member

wjwwood commented Jun 20, 2013

On OS X, shared libraries should be postfixed with .dylib, and on Linux the same libraries should be .so. CMake automagically does the proper postfixing for shared libraries.

If you code is explicitly using .so somewhere it needs to specifically look for .dylib when on OS X.

@wjwwood
Copy link
Member

wjwwood commented Jun 20, 2013

I would note though, that .so works on OS X too, but isn't the proper fix usually.

@Lenskiy
Copy link
Author

Lenskiy commented Jun 20, 2013

There is no my code involved. There are only pure groovy packages, specifically image_pipeline and cv_bridge. I would like to know if someone can replicate this issue.
Anyways the whole problem now boiled down to visualisation. Unless there are some other libraries which extensions should be renamed.
I will try to rebuild groovy one more time :( I reinstalled python, who knows it might have some effect.

@wjwwood
Copy link
Member

wjwwood commented Jun 20, 2013

Yeah I was meaning that some of the groovy packages might be doing this incorrectly. I haven't had time to try and reproduce this. I'll look into it today if I get the new bloom released on time.

@Lenskiy
Copy link
Author

Lenskiy commented Jun 30, 2013

Here is the answers for the above stated problems
Problem 1: To calibrate stereo camera without hardware synchronisation, the approximate=0.01 flag should be used. If it's set up then problem 1 becomes problem 2.
Problem 2: On Mac OS X there is some problem with the visualisation. OpenCV cannot be built with OpenGL support if Cocoa is used as backend. I believe that was the problem. I also tried QT with OpenGL but QT window does not respond. I could not compile Carbon due to compilation problems. So the only option was to build OpenCV with GTK backend. To to so, I had to modify CMakeLists.txt in opencv folder as follows

Line 129:
OCV_OPTION(WITH_GTK            "Include GTK support"                         OFF  )

LINE 135:
OCV_OPTION(WITH_OPENGL         "Include OpenGL support"                      ON  IF (NOT ANDROID) )

LINE 617:
        status("    Carbon:" NO)
LINE 616:
        status("    Carbon:" NO)

LINE 140:
OCV_OPTION(WITH_QT             "Build with Qt Backend support"               OFF  IF (NOT ANDROID AND NOT IOS) )

Then gtk should be installed

brew install gtk+
brew install gtkglext

and /opt/X11/lib/pkgconfig should be added to ~/.profile

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig:$PKG_CONFIG_PATH

after building opencv, I could run calibration without a problem.

As mentioned before cv_bridge_boost.dylib should be renamed to cv_bridge_boost.so.

PS: I hope I did not forget to mention any steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants