How do I get a rosbridge image message into OpenCV (C++ or python)
I have several "robots" running rosbridge servers on raspberry pis and publishing low frame rate images. On a desktop computer, I need to be able to open a websocket to one of the robots and subscribe to its images. I have used mjpegserver for other purposes and it works fine, but in this case I do not want the image to go to a webpage, but rather to OpenCV for some computationally heavy image processing.
I have the rosbridge servers and clients setup and communicating. The client on the PC gets the image messages and they seem to contain the correct data based on simply printing the messages to the console as they arrive. However I am unable to convert the image into an OpenCV mat so that I can process it. It seems that it is simply a message formatting problem, but I can't find a solution or example on the webpage so if someone can point me in the right direction I would greatly appreciate it.
the imgmsg_to_cv2 fails and produces a complaint about unicode. If I start converting unicode to strings then the "encoding" field is ok, but the data complains that it does not have an array interface. Hopefully there is a simple function to translate the message into a compatible format.
Thanks, Jonathan West
Have you looked into cv_bridge and image_transport?
Thanks for the reply. Yes I am using image_transport on the server side of the rosbridge and I am trying to use cv_bridge on the PC side. that is part of the call "self.bridge.imgmsg_to_cv2"
Ah, I see - I wasn't familiar with the python interface