Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

If your need is to convert the data of the image, you don't need to do much. If function image.isContinuous() returns true (which is usually the case) then it is already byte array. You can access it by calling image.data. If image.isContinuous() returns false (for example you worked with ROI of image), you will need to move the data. Easiest way will be by calling image.clone().

As for the header of image, you don't need to send all of its fields. Value of reference counter for example will have no meaning for someone who received this file from the network. Send only the fields that will allow recipient to create Mat by himself. Those are width, height and type of the image.