From b03dd764a1dfe7452178a73cee4c9ab36f216c0a Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Fri, 4 Oct 2024 16:32:59 +0300 Subject: [PATCH] Relax conditions to allow 0d reshape for UMat. --- modules/core/src/umatrix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/core/src/umatrix.cpp b/modules/core/src/umatrix.cpp index f28aa3693f..a98e98d4b4 100644 --- a/modules/core/src/umatrix.cpp +++ b/modules/core/src/umatrix.cpp @@ -1062,7 +1062,7 @@ UMat UMat::reshape(int _cn, int _newndims, const int* _newsz) const if (isContinuous()) { - CV_Assert(_cn >= 0 && _newndims > 0 && _newndims <= CV_MAX_DIM && _newsz); + CV_Assert(_cn >= 0 && _newndims >= 0 && _newndims <= CV_MAX_DIM && _newsz); if (_cn == 0) _cn = this->channels(); @@ -1072,7 +1072,7 @@ UMat UMat::reshape(int _cn, int _newndims, const int* _newsz) const size_t total_elem1_ref = this->total() * this->channels(); size_t total_elem1 = _cn; - AutoBuffer newsz_buf( (size_t)_newndims ); + AutoBuffer newsz_buf( (size_t)std::max(_newndims, 1) ); for (int i = 0; i < _newndims; i++) {