Ask Your Question

image_view disparity_view stereo_view OSX

asked 2011-11-14 08:31:15 -0500

tingfan gravatar image

updated 2011-11-14 08:35:37 -0500

**This post is not about asking a question but to document a workaround.

When running image_view/disparity_view/stereo_view tools in MacOSX. The program opens an standard opencv window but shows a blank (black/white) image. When you move the mouse cursor over the window, the cursor turns into a spinning wheel indicating the window is not responding.

Reason: These programs use "cv::startWindowThread()" instead of "cv::waitkey()" to handle UI update. However, cv::startWindowThread is not implemented in opencv highgui Carbon/Cocoa/QT backend which are typically used on OSX.

Workaround Add cv::waitKey() to the main thread. Here's the example for image_view.cpp

--- src/nodes/image_view.cpp    (revision 37880)
+++ src/nodes/image_view.cpp    (working copy) 
@@ -1,5 +1,6 @@  
   #include <ros/ros.h>  #include <nodelet/loader.h>
  +#include <opencv2/highgui/highgui.hpp>    
   int main(int argc, char **argv)  { 
@@-15,7 +16,9 @@    my_argv.push_back("--shutdown-on-close"); // Internal
     manager.load(ros::this_node::getName(), "image_view/image", remappings, my_argv);
-  ros::spin();
+  while(ros::ok())
+  { 
+     cv::waitKey(5);
+  }    return 0;  }
edit retag flag offensive close merge delete


You should submit this as a ticket on the appropriate trac.
Mac gravatar image Mac  ( 2011-11-14 10:30:52 -0500 )edit
@Mac, the ticket probably should go to opencv's track where the backend of startWindowThread should be implemented. However, I don't have enough knowledge right now how that could be done. So I decided to post a workaround here for now. Thanks for your input.
tingfan gravatar image tingfan  ( 2011-11-14 14:55:15 -0500 )edit
Still, put a bug somewhere, so it gets fixed.
Mac gravatar image Mac  ( 2011-11-15 03:08:13 -0500 )edit

This seems to be still a problem and I can not find any viable workaround. Proposed solution is okay for image_view library, any fix suggestions for camera_calibration?

berkaydeniz gravatar image berkaydeniz  ( 2014-03-25 04:57:36 -0500 )edit

actually, you just need to replace rospy.spin with while not ros.is_shutdown(): cv.WaitKey(5) in and

deniz gravatar image deniz  ( 2014-03-25 14:46:59 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2011-11-15 13:31:21 -0500

Patrick Mihelich gravatar image
Thanks for the report. As Mac said, please open a ticket ( so that the OpenCV devs fix this.
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-11-14 08:31:15 -0500

Seen: 647 times

Last updated: Nov 14 '11