函数 Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP);
/** @overload
@param rows Number of rows in a 2D array.
@param cols Number of columns in a 2D array.
@param type Array type. Use CV_8UC1, ..., CV_64FC4 to create 1-4 channel matrices, or
CV_8UC(n), ..., CV_64FC(n) to create multi-channel (up to CV_CN_MAX channels) matrices.
@param data Pointer to the user data. Matrix constructors that take data and step parameters do not
allocate matrix data. Instead, they just initialize the matrix header that points to the specified
data, which means that no data is copied. This operation is very efficient and can be used to
process external data using OpenCV functions. The external data is not automatically deallocated, so
you should take care of it.
@param step Number of bytes each matrix row occupies. The value should include the padding bytes at
the end of each row, if any. If the parameter is missing (set to AUTO_STEP ), no padding is assumed
and the actual step is calculated as cols*elemSize(). See Mat::elemSize.
*/
Mat(int rows, int cols, int type, void* data, size_t step=AUTO_STEP);
rows 二维数组的行数
cols 二维数组的列数
type 数组的类型
data 指向用户数据的指针
step 矩阵每行占据的字节数。这个值必须包含每行补齐的数据。如果不提供这个参数,就假设没有补齐,实际的步长就是等于cols*elemSize()
Mat tmp;
Mat mat(dwCount, dwProfileDataCount, CV_16UC1, (void*)pHeightProfileArray, image_info.width*2);
mat.convertTo(tmp, CV_8UC1, 255.0 / 65535, 0.5);
Mat mat(1000, 3200, CV_8UC1, (void*)image->getMatPtr()->data, 3200);
Mat tep;
mat.convertTo(tep, CV_16UC1, 255.0);