当使用 openCV 的 cv::Mat 时,
http://docs.opencv.org/modules/core/doc/basic_structures.html
我知道会使用某种智能指针。
我的问题是,为了进行一些内存优化,
我应该调用 cv::Mat release() 来释放未使用的矩阵吗?
还是应该相信编译器会自动处理? 例如,考虑以下代码:
我应该调用 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 ?