roslibjs subscribe to sensor_msgs/image
Hello,
I couldn't find an example of how to subscribe to a sensor_msgs/image and display it in a html5 canvas. I already have a page running and I can somehow access the data, but it won't display in an image nor in a html5 canvas. This is an excerpt of my test code:
imageTopic.subscribe(function(message)
{
var imagedata = "data:image/jpeg;base64," + message.data;
document.getElementById('xy_image').setAttribute('src', imagedata);
imageTopic.unsubscribe();
});
First of all: how can I access the frames without subscribing to the topic every time and unsubscribing to it again? Second: The message.data seems correct, but the header doesnt work and the image is not displayed. I tried png as well, with no success. I would be happy if you could help me out - maybe with a basic example.
Thanks in advance