Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Pointer to cv::Mat and sizeof underlying structure

Hi,

I have to use an interface which 'transmits' data between different execution units in a pipeline. The interface of the correspoding transmit function looks similar to this:

transmit(TimeStamp time, const void* data, int sizeOfData)

Now I want to transmit OpenCV matrices over this interface. In the first place I used an intermediate data structure like this:

typedef struct {
    int rows;
    int cols;
    int channels;
    unsigned int depth;
    unsigned char* data;
} CVMat;

Function call:

CVMat mat;
transmit(time, &mat, sizeof(CVMat));

On the other side I can reconstruct a new matrix with the transmitted data.

Now I wonder whether its possible to transmit OpenCV matrices directly. But I'm not sure how to deal with the concept of the seperation between data and header. Is it possible to get a void pointer to an OpenCV matrix and what is the correct way to determine the size of the underlying data structure? Is a reconstruction of the matrix possible (cast to cv::Mat)?