Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

imho, you're missing, that the 3rd arg is is reserved for the type, and your actual pointer has to go after that what about: Mat(638, 314, CV_16U, data_pointer) ?

imho, you're missing, that i think, you want to use this constructor here

apart from the 3rd arg is is reserved for to the type (CV_16U) , and your actual pointer has to go after that what about: Mat(638, 314, CV_16U, data_pointer) ?note, that it's (rows,cols) in opencv, not (width,height)

in the end it will be:

void * data_pointer = ...
Mat m = Mat(314, 628, CV_16U, (uchar*)data_pointer)

i think, you want to use this constructor here

apart from the 3rd arg reserved to the type (CV_16U) , note, that it's (rows,cols) in opencv, not (width,height)

in the end it will be:

void * data_pointer = ...
Mat m = Mat(314, 628, CV_16U, (uchar*)data_pointer)
(uchar*)data_pointer);

you'll also have to very cautios here, since this constructor only makes a shallow copy of your data_pointer (no pixels copied). once, your original pointer gets out of scope, anything is invalid, so please take care, you

  • either stay within the scope of that pointer
  • or clone() the Mat made from it

i think, you want to use this constructor here

apart from the 3rd arg reserved to the type (CV_16U) , note, that it's (rows,cols) in opencv, not (width,height)

in the end it will be:

void * data_pointer = ...
Mat m = Mat(314, 628, CV_16U, (uchar*)data_pointer);

you'll also have to very cautios here, since this constructor only makes a shallow copy of your data_pointer (no pixels copied). once, your original pointer gets out of scope, anything is invalid, so please take care, you

  • either stay within the scope of that pointer
  • or clone() the Mat made from itit, and pass that on.