Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

use cv::imread, this function returns cv::Mat

Mat src = imread("1.tif");
src.release(); // free mem

use Use cv::imread, this function returns cv::Mat

Mat src = imread("1.tif");
src.release(); // free mem

cv::Mat will free memory only if it was allocated by create method (if Mat object owns this memory):

Mat src(100, 100, CV_32FC1);
src.release(); // will free memory

When you create Mat object from your pointer or from old C structs (CvMat, IplImage), Mat object will not free this memory.

float* data = new float[100 * 100];
Mat src(100, 100, CV_32FC1, data);
src.release(); // will not free memory
delete [] data;