From 445022682e98e996dd2139557d6c62d14811b246 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov <2536374+asmorkalov@users.noreply.github.com> Date: Thu, 27 Jun 2024 19:11:05 +0300 Subject: [PATCH] Merge pull request #25789 from asmorkalov:as/HAL_meanStdDev_tails Fill mean and stdDev tails with zeros for HAL branch in meanStdDev #25789 as it's done for other branches. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- modules/core/src/mean.dispatch.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/modules/core/src/mean.dispatch.cpp b/modules/core/src/mean.dispatch.cpp index b6ea926255..52c0954ff8 100644 --- a/modules/core/src/mean.dispatch.cpp +++ b/modules/core/src/mean.dispatch.cpp @@ -544,6 +544,10 @@ void meanStdDev(InputArray _src, OutputArray _mean, OutputArray _sdv, InputArray int dcn = (int)mean_mat.total(); CV_Assert( mean_mat.type() == CV_64F && mean_mat.isContinuous() && (mean_mat.cols == 1 || mean_mat.rows == 1) && dcn >= cn ); + + double* dptr = mean_mat.ptr(); + for(k = cn ; k < dcn; k++ ) + dptr[k] = 0; } if (_sdv.needed()) @@ -555,6 +559,11 @@ void meanStdDev(InputArray _src, OutputArray _mean, OutputArray _sdv, InputArray int dcn = (int)stddev_mat.total(); CV_Assert( stddev_mat.type() == CV_64F && stddev_mat.isContinuous() && (stddev_mat.cols == 1 || stddev_mat.rows == 1) && dcn >= cn ); + + double* dptr = stddev_mat.ptr(); + for(k = cn ; k < dcn; k++ ) + dptr[k] = 0; + } if (src.isContinuous() && mask.isContinuous()) @@ -646,23 +655,17 @@ void meanStdDev(InputArray _src, OutputArray _mean, OutputArray _sdv, InputArray if (_mean.needed()) { const double* sptr = s; - int dcn = (int)mean_mat.total(); double* dptr = mean_mat.ptr(); for( k = 0; k < cn; k++ ) dptr[k] = sptr[k]; - for( ; k < dcn; k++ ) - dptr[k] = 0; } if (_sdv.needed()) { const double* sptr = sq; - int dcn = (int)stddev_mat.total(); double* dptr = stddev_mat.ptr(); for( k = 0; k < cn; k++ ) dptr[k] = sptr[k]; - for( ; k < dcn; k++ ) - dptr[k] = 0; } }