Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Use the following:

T* external_mem = .... // external memory of type T
cv::Mat wrapped(rows, cols, cv::DataType<T>::depth, external_mem, CV_AUTOSTEP); // does not copy

Use the following:

T* external_mem = .... // external memory of type T
cv::Mat wrapped(rows, cols, cv::DataType<T>::depth, external_mem, CV_AUTOSTEP); // does not copy

Or shorter if you know the type T, e.g. T = float:

float* external_mem = .... // external memory of type float
cv::Mat wrapped(rows, cols, CV_32FC1, external_mem, CV_AUTOSTEP); // does not copy

Use the following:

T* external_mem = .... // external memory of type T
cv::Mat wrapped(rows, cols, cv::DataType<T>::depth, external_mem, CV_AUTOSTEP); // does not copy

Or shorter if you know the type T, e.g. T = float:

float* external_mem = .... // external memory of type float
cv::Mat wrapped(rows, cols, CV_32FC1, external_mem, CV_AUTOSTEP); // does not copy

Remember to free/delete the pointer external_mem after usage. The Mat wrapped does not release the memory for you when it is destructed.

Use the following:

T* external_mem = .... // external memory of type T
cv::Mat wrapped(rows, cols, cv::DataType<T>::depth, cv::DataType<T>::type, external_mem, CV_AUTOSTEP); // does not copy

Or shorter if you know the type T, e.g. T = float:

float* external_mem = .... // external memory of type float
cv::Mat wrapped(rows, cols, CV_32FC1, external_mem, CV_AUTOSTEP); // does not copy

Remember to free/delete the pointer external_mem after usage. The Mat wrapped does not release the memory for you when it is destructed.