I'm trying to understand clearly how Mat (OpenCV) works in many specific cases. The cases I'm inquiring in this post are the following:
When a Mat pointer is reassigned to other location, will the previous header and data memory be freed automatically? for example:
Mat *m = XXX;
m = YYY;
If I call sourceMat.release(), does it also release the header m?
Mat m = sourceMat(Rect);
For the 2nd question, the answer is NO.
From the OpenCV's doc, Mat Mat::operator()(const Rect& roi) const
will make a new header. So releasing the sourceMat
will not affect m
.