0
$\begingroup$

Rosanswers logo

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


Originally posted by JWest on ROS Answers with karma: 66 on 2015-03-30

Post score: 0


Original comments

Comment by 2ROS0 on 2015-03-30:
Have you looked into cv_bridge and image_transport?

Comment by JWest on 2015-03-31:
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"

Comment by 2ROS0 on 2015-04-01:
Ah, I see - I wasn't familiar with the python interface

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I found a similar question and the (simple) solution The JSON file is encoded with "Base64" so all I needed is a line like

msg.data = msg.data.decode('Base64')

and then everything is fine.


Originally posted by JWest with karma: 66 on 2015-04-03

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.