1 | initial version |
it is the same as: (just for clarifying)
Mat aux = cur_img(Rect(0,0,100,100));
Mat res_img = aux.reshape(1,1);
When you do this operation:
Mat aux = image(Rect(0,0,100,100));
Your are calling this operator
C++: Mat Mat::operator()(const Rect& roi) const
This operation makes a new header for the specified sub-array of *this, thus it is a 0(1) operation, that is, no matrix data is copied. So, matrix elements are no longer stored continuosly without gaps at the end of each row.
Mat res_img = aux.reshape(1,1);
No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of rows the matrix must be continuous
bool myCheckMatContinuity(const Mat& m)
{
//return (m.flags & Mat::CONTINUOUS_FLAG) != 0;
return m.rows == 1 || m.step == m.cols*m.elemSize();
}
Mat aux = image(Rect(0,0,100,100));
bool cont= myCheckMatContinuity(aux); //false!
Mat res_img = aux.reshape(1,1); //error
2 | No.2 Revision |
it is the same as: (just for clarifying)
Mat cur_img = imread(fileList.fileNames[i],0);
Mat aux = cur_img(Rect(0,0,100,100));
Mat res_img = aux.reshape(1,1);
When you do this operation:
Mat aux = image(Rect(0,0,100,100));
Your are calling this operator
C++: Mat Mat::operator()(const Rect& roi) const
This operation makes a new header for the specified sub-array of *this, thus it is a 0(1) operation, that is, no matrix data is copied. So, matrix elements are no longer stored continuosly without gaps at the end of each row.
Mat res_img = aux.reshape(1,1);
No data is copied. That is, this is an O(1) operation. Consequently, if you change the number of rows the matrix must be continuous
bool myCheckMatContinuity(const Mat& m)
{
//return (m.flags & Mat::CONTINUOUS_FLAG) != 0;
return m.rows == 1 || m.step == m.cols*m.elemSize();
}
Mat aux = image(Rect(0,0,100,100));
bool cont= myCheckMatContinuity(aux); //false!
Mat res_img = aux.reshape(1,1); //error