Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

if you have a 16bit Mat (CV_16U), please access the underlying memory like:

ushort * ps = mat.ptr<ushort>(); //ptr to 1st element

if you need a copy of that, it's :

size_t len = mat.total() * mat.elemSize(); // in bytes
ushort *cs = new ushort[len]; // *not* float!
memcpy(cs, mat.ptr<ushort>(), len);

if you have a 16bit Mat (CV_16U), please access the underlying memory like:

CV_Assert(mat.type() == CV_16U); // make sure !    
ushort * ps = mat.ptr<ushort>(); //ptr // ptr to 1st element

if you need a copy of that, it's :

size_t len = mat.total() * mat.elemSize(); // in bytes
ushort *cs = new ushort[len]; // *not* float!
memcpy(cs, mat.ptr<ushort>(), len);