Mat::release not working correctly (Bug #855)


Added by hype blade about 14 years ago. Updated about 14 years ago.


Status:Done Start date:
Priority:High Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:core
Target version:-
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

Hi there,
I just found another bug, that causes the Mat::release() function not to work correctly. When releasing a matrix not all variables are reset. Mat::cols and Mat::dims still have the old value!

Example:
// creating a Mat object
cv::Mat_<float> myMat(100,100);
// now release the hole matrix
myMat.release();
// but not everything is gone, myMat.cols and myMat.dims
// do still hold valid values!
if(myMat.cols != 0){
cerr<<"cols should be 0"<<endl;
}
if(myMat.dims!= 0){
cerr<<"dims should be 0"<<endl;
}

// fortunately myMat.emtpy() still tells us the matrix is empty!
bool isEmpty = myMat.empty()
if(!isEmpty){
cerr<<"should be emtpy"<<endl;
}


History

Updated by Vadim Pisarevsky about 14 years ago

Hello,

Mat::release() does not have to clear all the variables. It's not stated in the specs. Use if(mat.empty()) to check if the matrix is empty or not.

  • Status changed from Open to Done
  • (deleted custom field) set to invalid

Updated by hype blade about 14 years ago

Hi Vadim,
yes I know that it is not stated in the documentation - but don't you think it's kind of odd that some variables are reset and some others don't?!

So you're probably completely right by saying that this isn't a bug, but is definitetly an inconvenience that, in my opinion, should be fixed...

Also available in: Atom PDF