c++ - What does cv::Mat's deallocate method do? -
the following code
int main(int argc, char** argv) { cv::mat1b i1(cv::size(1, 2)); i1.at<uchar>(0, 0) = 1; i1.at<uchar>(1, 0) = 1; cv::mat1b mask(i1.size()); mask.at<uchar>(0, 0) = 1; mask.at<uchar>(1, 0) = 0; cv::mat1b masked; mask.copyto(masked, mask); masked.release(); //or .deallocate() cout << masked << endl; i1.copyto(masked, 1 - mask); cout << masked << endl; return 0; } behaves differently when masked.release() replaced masked.deallocate(). in latter case seems matrix masked not modified @ , output masked sum of masked , invert masked matrices, equal original im1 matrix. deallocate() member method do? use opencv 3.1.
deallocate() deallocate data directly form cv::mat. however, release() decrease ref_count of cv::mat , if hits 0, call deallcoate itself.
summary: use release until know doing.
be aware not need invoke of them. release invoked during destructor of cv::mat.
p.s using data of cv::mat after deallocating considered undefined behavior.
Comments
Post a Comment