ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

This looks to be the same problem as https://stackoverflow.com/questions/44577228/multithreaded-cv2-imshow-in-python-does-not-work Each callback is running in a different thread which messes up imshow (and likely other highgui functions). There are some other search results that may be more informative if you search for 'cv2 imshow threads python'.

You could save each received image to member variables and have a single thread (inside a loop with a sleep in __init__ or maybe in a timer update) do all the imshow calls, and possibly need locks around each use or assignment to the images, but I suspect you want the imshows for quick debug purposes and don't want to do a lot of work to overcome their limitations. If you gain confidence in your image publishers then use rqt_image_view to see that callbacks are working, or print some text information (like the width and height of the image) to stdout in the callbacks.