Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Convert void buffer pointer to Mat

I have a module which receives a void pointer to a buffer. The original data type is uint16.

When I try putting the variable into a Mat, I get weird errors from Mat imBuff = cv::Mat(628, 314, frame, CV_16U); like missing '}' which isn't missing.

When I try various conversions using reinterpret_cast, I get cast from 'void*' to 'xxx' loses precision. For example, Mat imBuff = cv::Mat(628, 314, reinterpret_cast<uint16_t &gt;(frame),="" cv_16u);="" fives="" 'uint126_t'="" {aka="" short="" unsigned="" int}'="" loses="" precision<="" p="">

Any ideas on how to solve this?

Or, do I have to go back to the source file and change it there?

thanks Ralph

click to hide/show revision 2
No.2 Revision

updated 2016-10-16 00:37:42 -0600

berak gravatar image

Convert void buffer pointer to Mat

I have a module which receives a void pointer to a buffer. The original data type is uint16.

When I try putting the variable into a Mat, I get weird errors from

Mat imBuff = cv::Mat(628, 314, frame, CV_16U);

like missing '}' which isn't missing.

When I try various conversions using reinterpret_cast, I get cast from 'void*' to 'xxx' loses precision. For example,

 Mat imBuff = cv::Mat(628, 314, reinterpret_cast<uint16_t &gt;(frame),="" cv_16u);="" fives="" 'uint126_t'="" {aka="" short="" unsigned="" int}'="" loses="" precision<="" p="">
>(frame), CV_16U);
 

fives 'uint126_t' {aka short unsigned int}' loses precision

Any ideas on how to solve this?

Or, do I have to go back to the source file and change it there?

thanks Ralph