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);
2 | No.2 Revision |
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);