Is there a way to wrap a yarp-image in a bottle ?
Yes, there are several. If this is for transmitting/receiving on the network, there's no need to do any wrapping - Images and Bottles have compatible network representations. Otherwise you should be able to do Bottle::read(Image).
Hi, thanks very much, read(Image) works, but I cannot figure out how to get the Image out on the other side again, especially without knowing beforehand that an Image will be sent in the bottle..
From what I see there is no method isImage or something ?
You seem to have CSS turned off.
Please don't fill out this field.
Since you are talking about an "other side", are you communicating on the network? If so, you probably don't need to put the image in a bottle, just send it directly - or if you want to add on other data, just use a yarp::os::PortablePair where one part is the image and the other is e.g. a bottle or whatever you like. That would be more efficient.
If you have a bottle, and want to know if it might be interpretable as an image, you might just check if it starts with vocab item "[mat]" or something like that. Print the bottle out (e.g. with bottle.toString().c_str()) to see what I mean.
If you are working within a single program, then storing an Image inside a Bottle isn't a great idea. Can you give some detail about what you're trying to do?
Hi Paul, thank you very much for your help..
What we do right now is basically building another layer on top of yarp,
and we communicate over network. We want to be able to switch communication layers (yarp, mpi, etc.), so we had to abstract the ports.
I did not want to use different types for the InputPorts, this is why I wanted to wrap the Images in bottles. Now I am able to wrap everything in a bottle, thank you very much !
I used typeid(b.get(0)) == typeid(yarp::os::impl::StoreVocab) to check if its an image or int/float, etc., that seems to work fine..
I will try your solution with the vocab item "[mat]" tomorrow.
Sign up for the SourceForge newsletter: