Skip to content

Commit eb136eb

Browse files
committed
Do not reset step for single-row Mat created on user data
1 parent 1a9d8e9 commit eb136eb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

modules/core/include/opencv2/core/mat.inl.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,15 +508,15 @@ Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step)
508508
}
509509
else
510510
{
511-
if( rows == 1 ) _step = minstep;
512511
CV_DbgAssert( _step >= minstep );
513512

514513
if (_step % esz1 != 0)
515514
{
516515
CV_Error(Error::BadStep, "Step must be a multiple of esz1");
517516
}
518517

519-
flags |= _step == minstep ? CONTINUOUS_FLAG : 0;
518+
if (_step == minstep || rows == 1)
519+
flags |= CONTINUOUS_FLAG;
520520
}
521521
step[0] = _step;
522522
step[1] = esz;
@@ -541,15 +541,15 @@ Mat::Mat(Size _sz, int _type, void* _data, size_t _step)
541541
}
542542
else
543543
{
544-
if( rows == 1 ) _step = minstep;
545544
CV_DbgAssert( _step >= minstep );
546545

547546
if (_step % esz1 != 0)
548547
{
549548
CV_Error(Error::BadStep, "Step must be a multiple of esz1");
550549
}
551550

552-
flags |= _step == minstep ? CONTINUOUS_FLAG : 0;
551+
if (_step == minstep || rows == 1)
552+
flags |= CONTINUOUS_FLAG;
553553
}
554554
step[0] = _step;
555555
step[1] = esz;

0 commit comments

Comments
 (0)