diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 7b6c3f497f..5f4f91dc43 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -895,7 +895,7 @@ Mat::Mat(Size _sz, int _type, void* _data, size_t _step) size_t esz = CV_ELEM_SIZE(_type), esz1 = CV_ELEM_SIZE1(_type); size_t minstep = cols*esz; - if( _step == AUTO_STEP ) + if( _step == AUTO_STEP || (_step < minstep && rows == 1)) { _step = minstep; } diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index deb5791f29..aded7bb74e 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -1200,5 +1200,17 @@ TEST(Imgproc_Remap, issue_23562) } } +TEST(Imgproc_Resize, issue_26497) +{ + std::vector vec = {0.f, 1.f, 2.f, 3.f}; + Mat A(vec), B; + resize(A, B, Size(2,2), 0, 0, INTER_LINEAR); + double minv = 0, maxv = 0; + cvtest::minMaxIdx(B, &minv, &maxv, nullptr, nullptr, noArray()); + EXPECT_EQ(B.size(), Size(2, 2)); + EXPECT_LE(0., minv); + EXPECT_LE(maxv, 3.); +} + }} // namespace /* End of file. */