Graduation mat inside std :: vector

Using OpenCV 2.2 , I am trying to free up memory to trigger a release in Mat. inside std :: vector, for example:

std::vector < Mat > matVec;

However, it seems

for (int k = 0; k < matVec.size(); k++)
{

   matVec[k].release();

}

doesn't free memory (it still compiles, though).

I know that there is a new memory management in OpenCV 2.2 , but I could not determine the problem.

A similar example with a type IplImage*instead of Mat (using Mat cvReleaseImage()instead of a member function .release()) works fine.

Any clues?

+3
source share
2 answers

.release()should be called only in exceptional circumstances, it is not for everyday use. Just clean the vector:

std::vector<cv::Mat>().swap(matVec);

Mat s, ( cv::Mat), , cv::Mat, IplImage, . - , ). , , .release() :

matVec[k] = cv::Mat();
+7

- matVec[k]. , matVec matVec vector of Mat* .

, OpenCV Mat Mat.

+1
source

All Articles