Robotics StackExchange | Archived questions

sensor_msgs/Image to jpg using roslibjs

I'm trying to display a jpg image from the sensormsgs/Image topic onto my webpage. I have been able to extract the images using imageview in the terminal, so I know that the images are being sent correctly, I just don't know how to decode them in javascript.

I've tried the solution in this answer (https://answers.ros.org/question/252548/roslibjs-subscribe-to-sensor_msgsimage/), but this does not work for me because I need to subscribe to a sensormsgs/Image topic, not a sensormsgs/CompressedImage topic.

I've found the tutorial for doing this in python (https://wiki.ros.org/cv_bridge/Tutorials/ConvertingBetweenROSImagesAndOpenCVImagesPython) but I can't figure out how this would be done in javascript.

Any suggestions on how to convert a sensor_msgs/Image message to a jpg?

Asked by rmango on 2020-12-01 15:52:03 UTC

Comments

If you can view it in a browser and it doesn't have to be a jpg, the following QA would be helpful: https://stackoverflow.com/questions/50620821/uint8array-to-image-in-javascript

Asked by miura on 2020-12-02 10:26:31 UTC

Answers

I was able to get my webpage working using image_transport republish as shown here (https://answers.ros.org/question/320116/sensor_msgsimage-data-to-sensor_msgscompressedimage-data/). However, this doesn't seem like the ideal solution. If anyone knows how to process a sensor_msgs/Image without republishing please let me know!

Asked by rmango on 2020-12-01 18:26:00 UTC

Comments