Data stored in OpenCV cv::Mat
s are not always continuous in memory, which can be verified via API Mat::isContinuous()
. Instead, it follows the following rules:
- Matrices created by
imread()
,clone()
, or a constructor will always be continuous. - The only time a matrix will not be continuous is when it borrows data from an existing matrix (i.e. created out of an ROI of a big mat), with the exception that the data borrowed is continuous in the big matrix, including
- borrow a single row;
- borrow multiple rows but with full original width.