mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
Merge pull request #25563 from asmorkalov:as/HAL_min_max_idx
Transform offset to indeces for MatND in minMaxIdx HAL #25563 Address comments in https://github.com/opencv/opencv/pull/25553 ### 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 - [x] 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
This commit is contained in:
parent
5bd64e09a3
commit
1f1ba7e402
@ -1510,18 +1510,29 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
|
||||
|
||||
Mat src = _src.getMat(), mask = _mask.getMat();
|
||||
|
||||
int _minIdx, _maxIdx;
|
||||
int* min_offset = (cn == 1) ? minIdx : &_minIdx;
|
||||
int* max_offset = (cn == 1) ? maxIdx : &_maxIdx;
|
||||
if (src.dims <= 2)
|
||||
{
|
||||
CALL_HAL(minMaxIdx, cv_hal_minMaxIdx, src.data, src.step, src.cols*cn, src.rows, src.depth(),
|
||||
minVal, maxVal, min_offset, max_offset, mask.data);
|
||||
CALL_HAL(minMaxIdx, cv_hal_minMaxIdx, src.data, src.step, src.cols*cn, src.rows,
|
||||
src.depth(), minVal, maxVal, minIdx, maxIdx, mask.data);
|
||||
}
|
||||
else if (src.isContinuous())
|
||||
{
|
||||
CALL_HAL(minMaxIdx, cv_hal_minMaxIdx, src.data, 0, (int)src.total()*cn, 1, src.depth(),
|
||||
minVal, maxVal, min_offset, max_offset, mask.data);
|
||||
int res = cv_hal_minMaxIdx(src.data, 0, (int)src.total()*cn, 1, src.depth(),
|
||||
minVal, maxVal, minIdx, maxIdx, mask.data);
|
||||
|
||||
if (res == CV_HAL_ERROR_OK)
|
||||
{
|
||||
if (minIdx)
|
||||
ofs2idx(src, minIdx[0], minIdx);
|
||||
if (maxIdx)
|
||||
ofs2idx(src, maxIdx[0], maxIdx);
|
||||
return;
|
||||
}
|
||||
else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED)
|
||||
{
|
||||
CV_Error_(cv::Error::StsInternal,
|
||||
("HAL implementation minMaxIdx ==> " CVAUX_STR(cv_hal_minMaxIdx) " returned %d (0x%08x)", res, res));
|
||||
}
|
||||
}
|
||||
|
||||
CV_OVX_RUN(!ovx::skipSmallImages<VX_KERNEL_MINMAXLOC>(src.cols, src.rows),
|
||||
|
@ -2446,6 +2446,32 @@ TEST(Core_minMaxIdx, regression_9207_2)
|
||||
EXPECT_EQ(14, maxIdx[1]);
|
||||
}
|
||||
|
||||
TEST(Core_MinMaxIdx, MatND)
|
||||
{
|
||||
const int shape[3] = {5,5,3};
|
||||
cv::Mat src = cv::Mat(3, shape, CV_8UC1);
|
||||
src.setTo(1);
|
||||
src.data[1] = 0;
|
||||
src.data[5*5*3-2] = 2;
|
||||
|
||||
int minIdx[3];
|
||||
int maxIdx[3];
|
||||
double minVal, maxVal;
|
||||
|
||||
cv::minMaxIdx(src, &minVal, &maxVal, minIdx, maxIdx);
|
||||
|
||||
EXPECT_EQ(0, minVal);
|
||||
EXPECT_EQ(2, maxVal);
|
||||
|
||||
EXPECT_EQ(0, minIdx[0]);
|
||||
EXPECT_EQ(0, minIdx[1]);
|
||||
EXPECT_EQ(1, minIdx[2]);
|
||||
|
||||
EXPECT_EQ(4, maxIdx[0]);
|
||||
EXPECT_EQ(4, maxIdx[1]);
|
||||
EXPECT_EQ(1, maxIdx[2]);
|
||||
}
|
||||
|
||||
TEST(Core_Set, regression_11044)
|
||||
{
|
||||
Mat testFloat(Size(3, 3), CV_32FC1);
|
||||
@ -2807,7 +2833,6 @@ TEST(Core_MinMaxIdx, rows_overflow)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(Core_Magnitude, regression_19506)
|
||||
{
|
||||
for (int N = 1; N <= 64; ++N)
|
||||
|
Loading…
Reference in New Issue
Block a user