Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

there are 3 cases, where you'd get non-continouos Mat's.

  • it's a roi
  • bmp images and the like sometimes come padded
  • you made a mat from a pixel pointer ( i.e some non-opencv capture device ) and that might be padded, too

since you have to reorder the memory in all those cases, checking for continuity and a clone() acll will solve it.

if ( ! mat.isContinuous() )
{ 
    mat = mat.clone();
}

there are 3 cases, where you'd get non-continouos non-continuous Mat's.

  • it's a roi
  • bmp images and the like sometimes come padded
  • you made a mat from a pixel pointer ( i.e some non-opencv capture device ) and that might be padded, too

since you have to reorder the memory in all those cases, checking for continuity and a clone() acll will solve it.

if ( ! mat.isContinuous() )
{ 
    mat = mat.clone();
}