can someone explain to me how OpenCV CvMat line alignment works (or its C ++ version of cv::Mat )? For example, let's say I have a matrix
CvMat *cvmat = cvCreateMat(2,3,CV_8UC1); cvSet2D( cvmat, 0, 0, cvScalar(1) ); cvSet2D( cvmat, 0, 1, cvScalar(2) ); cvSet2D( cvmat, 0, 2, cvScalar(3) ); cvSet2D( cvmat, 1, 0, cvScalar(4) ); cvSet2D( cvmat, 1, 1, cvScalar(5) ); cvSet2D( cvmat, 1, 2, cvScalar(6) );
According to the CvMat documentation, the rows should be aligned by 4 bytes, that is, the first row of the matrix should be supplemented with one zero, and the second should begin with an offset of +4). However, if I debug this piece of code, the data is continuous (ie cvmat->data is [1,2,3,4,5,6] ), and I do not see 4-byte alignment. Is this a mistake in the documentation and is it always safe to consider the continuity of data as CvMat or cv::Mat (if the matrix is ββnot part of another from c)? Or are there some special configurations that might have some data gaps as a result of memory alignment?
source share