Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you can just wrap a Mat header around that:

given it's like this:

typedef uchar BYTE; 
typedef struct tagRGBTRIPLE {
  BYTE rgbtBlue;
  BYTE rgbtGreen;
  BYTE rgbtRed;
} RGBTRIPLE;

// demo data:  
RGBTRIPLE p[] = {{1,2,3}, {4,5,6}, {7,8,9}, {2,4,8}};

Mat a(2,2,CV_8UC3, p);

cout << a << endl;

[  1,   2,   3,   4,   5,   6;
   7,   8,   9,   2,   4,   8]

but, careful ! a Mat constructor with an "external" data pointer does neither allocate memory, nor copy the data !

(so your p pointer must not go out of scope, before you're finished with a)

you probably need like: Mat b = a.clone(); or some other processing, that does a "deep copy" after that !