Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromopencv/opencv

Commit14e4be0

Browse files
asmorkalovRostislav Vasilikhin
authored and
Rostislav Vasilikhin
committed
Merge pull requestopencv#26080 from asmorkalov:as/HAL_minMaxIdx_ND_offset
Added offset for HAL as ofs2idx expects 1-based indexopencv#26080See details athttps://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- [ ] 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
1 parenta242431 commit14e4be0

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

‎modules/core/src/minmax.cpp‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ typedef void (*MinMaxIdxFunc)(const uchar*, const uchar*, int*, int*, size_t*, s
834834

835835
static MinMaxIdxFuncgetMinmaxTab(int depth)
836836
{
837-
static MinMaxIdxFunc minmaxTab[] =
837+
static MinMaxIdxFunc minmaxTab[CV_DEPTH_MAX] =
838838
{
839839
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_8u), (MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_8s),
840840
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_16u), (MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_16s),
@@ -846,6 +846,8 @@ static MinMaxIdxFunc getMinmaxTab(int depth)
846846
return minmaxTab[depth];
847847
}
848848

849+
// The function expects 1-based indexing for ofs
850+
// Zero is treated as invalid offset (not found)
849851
staticvoidofs2idx(const Mat& a,size_t ofs,int* idx)
850852
{
851853
int i, d = a.dims;
@@ -1511,8 +1513,30 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
15111513
Mat src = _src.getMat(), mask = _mask.getMat();
15121514

15131515
if (src.dims <=2)
1514-
CALL_HAL(minMaxIdx, cv_hal_minMaxIdx, src.data, src.step, src.cols, src.rows, src.depth(), minVal, maxVal,
1515-
minIdx, maxIdx, mask.data);
1516+
{
1517+
CALL_HAL(minMaxIdx, cv_hal_minMaxIdx, src.data, src.step, src.cols*cn, src.rows,
1518+
src.depth(), minVal, maxVal, minIdx, maxIdx, mask.data);
1519+
}
1520+
elseif (src.isContinuous())
1521+
{
1522+
int res =cv_hal_minMaxIdx(src.data,0, (int)src.total()*cn,1, src.depth(),
1523+
minVal, maxVal, minIdx, maxIdx, mask.data);
1524+
1525+
if (res == CV_HAL_ERROR_OK)
1526+
{
1527+
// minIdx[0] and minIdx[0] are always 0 for "flatten" version
1528+
if (minIdx)
1529+
ofs2idx(src, minIdx[1]+1, minIdx);
1530+
if (maxIdx)
1531+
ofs2idx(src, maxIdx[1]+1, maxIdx);
1532+
return;
1533+
}
1534+
elseif (res != CV_HAL_ERROR_NOT_IMPLEMENTED)
1535+
{
1536+
CV_Error_(cv::Error::StsInternal,
1537+
("HAL implementation minMaxIdx ==>"CVAUX_STR(cv_hal_minMaxIdx)" returned %d (0x%08x)", res, res));
1538+
}
1539+
}
15161540

15171541
CV_OVX_RUN(!ovx::skipSmallImages<VX_KERNEL_MINMAXLOC>(src.cols, src.rows),
15181542
openvx_minMaxIdx(src, minVal, maxVal, minIdx, maxIdx, mask))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp