3
当使用openCV cv :: Mat。 http://docs.opencv.org/modules/core/doc/basic_structures.html 我知道某些智能指针正在被使用。我的问题是 ,为了做一些内存优化。
我应该调用cv :: Mat release()来释放未使用的矩阵吗?
还是我应该相信编译器来做到这一点?openCV cv :: mat release
例如觉得这个代码:
cv::Mat filterContours = cv::Mat::zeros(bwImg.size(),CV_8UC3);
bwImg.release();
for (int i = 0; i < goodContours.size(); i++)
{
cv::RNG rng(12345);
cv::Scalar color = cv::Scalar(rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255));
cv::drawContours(filterContours,goodContours,i,color,CV_FILLED);
}
/*% Fill any holes in the objects
bwImgLabeled = imfill(bwImgLabeled,'holes');*/
imageData = filterContours;
filterContours.release(); //should I call this line or not ?
当矩阵超出范围时,它将被释放(除非该矩阵的数据有不同的引用) – Micka
@Micka如果这是一个计算时间很长的非常长的函数,会发生什么情况。它会帮助释放吗? – Gilad
它会给你一些回忆,这可能会帮助你或者可能不会帮你 – Micka