Robotics StackExchange | Archived questions

add an array with XmlRpc::XmlRpcValue

Hello everybody,

I would like to add an array in a file thanks to XmlRpc::XmlRpcValue. But in the XmlRpc::XmlRpcValue there is no TypeArray in the constructor. So how can I add my array which a cv::Mat.

for example :

void functionForExample(XmlRpc::XmlRpcValue& xmlRV) { cv::Mat tab; ... xmlRV[ "tab" ] = XmlRpc::XmlRpcValue( ?? ); }

thanks for your help.

Asked by cosmoff on 2019-09-09 10:37:27 UTC

Comments

Answers

cv::Mat is not an array, it's a very complex class used to describe openCV image matrices. You cannot pass it directly to the XmlRpc functions.

By the looks of it you're trying to send an OpenCV image to an Rpc client or server. This can be done but you'll need to do a bit more work yourself.

There is an XmlRpc constructor which accepts arbitrary length data buffers, it's described here.

You'll need to first serialise your opencv image, effectively writing it to an image file in memory. You will use the imencode function to do this. You can then send the image using the XmlRpc constructor I described above.

The receiving side will need to use the opencv function imdecode to extract the original cv::Mat from the serialised data.

Hope this helps.

Asked by PeteBlackerThe3rd on 2019-09-10 06:38:20 UTC

Comments