nareshmlx/opencv-pr huggingface dataset:
**File:** modules/core/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #25196: core: add universal intrinsics for fp16

**Code Changes:**
```diff
@@ -182,6 +182,13 @@ template<> inline void EXPECT_COMPARE_EQ_<double>(const double a, const double b
     EXPECT_DOUBLE_EQ( a, b );
 }
 
+#if CV_SIMD_FP16
+template<> inline void EXPECT_COMPARE_EQ_<__fp16>(const __fp16 a, const __fp16 b)
+{
+    EXPECT_LT(std::abs(float(a - b)), 0.126);
+}
+#endif
```

Review comment:
Looks like `EXPECT_EQ` has problem with fp16 value since it gives non-zero value after I make a type conversion with `float()`. But now it comes to accuracy problem that maybe we need to take care of specifically for fp16. Helpful printings: ``` i = 0, a = 1.000000, b = 8.000000, a / b = 0.125000, c = 0.125000 i = 1, a = 2.000000, b = 7.000000, a / b = 0.285714, c = 0.285645 /Users/fengyuantao/Workspace/fytao/workspace/fp16_bf16_arithm/opencv/modules/core/test/test_intrin_utils.hpp:552: Failure Expected equality of these values: float(dataA[i] / dataB[i]) Which is: 0.285714 float(resC[i]) Which is: 0.285645 Google Test trace: /Users/fengyuantao/Workspace/fytao/workspace/fp16_bf16_arithm/opencv/modules/core/test/test_intrin_utils.hpp:550: i=1 i = 2, a = 3.000000, b = 6.000000, a / b = 0.500000, c = 0.500000 i = 3, a = 4.000000, b = 5.000000, a / b = 0.800000, c = 0.799805 /Users/fengyuantao/Workspace/fytao/workspace/fp16_bf16_arithm/opencv/modules/core/test/test_intrin_utils.hpp:552: Failure Expected equality of these values: float(dataA[i] / dataB[i]) Which is: 0.8 float(resC[i]) Which is: 0.799805 Google Test trace: /Users/fengyuantao/Workspace/fytao/workspace/fp16_bf16_arithm/opencv/modules/core/test/test_intrin_utils.hpp:550: i=3 i = 4, a = 5.000000, b = 4.000000, a / b = 1.250000, c = 1.250000 i = 5, a = 6.000000, b = 3.000000, a / b = 2.000000, c = 2.000000 i = 6, a = 7.000000, b = 2.000000, a / b = 3.500000, c = 3.500000 i = 7, a = 8.000000, b = 1.000000, a / b = 8.000000, c = 8.000000 ``` Get printings: ```.diff diff --git a/modules/core/test/test_intrin_utils.hpp b/modules/core/test/test_intrin_utils.hpp index b7f919f6af..b3dd482c0a 100644 --- a/modules/core/test/test_intrin_utils.hpp +++ b/modules/core/test/test_intrin_utils.hpp @@ -548,7 +548,8 @@ template<typename R> struct TheTest for (int i = 0; i < VTraits<R>::vlanes(); ++i) { SCOPED_TRACE(cv::format("i=%d", i)); - EXPECT_EQ(dataA[i] / dataB[i], resC[i]); + printf("i = %d, a = %f, b = %f, a / b = %f, c = %f\n", i, dataA[i], dataB[i], dataA[i] / dataB[i], resC[i]); + EXPECT_EQ(float(dataA[i] / dataB[i]), float(resC[i])); } return *this; @@ -2038,7 +2039,7 @@ void test_hal_intrin_float16() .test_interleave() .test_addsub() .test_mul() - // .test_div() // wrong results + .test_div() // wrong results ```
**File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #25196: core: add universal intrinsics for fp16

**Code Changes:**
```diff
@@ -61,6 +61,11 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
 #else
 #define CV_SIMD128_64F 0
 #endif
+#if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
+    #define CV_SIMD128_FP16 1
+#else
+    #define CV_SIMD128_FP16 0
+#endif
 
```

Review comment:
I suspect, it should be `const v_float16x8& x` for both fp32 and fp16 versions.
**File:** modules/core/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #25196: core: add universal intrinsics for fp16
**Review Line:** 188

**Code Changes:**
```diff
 }
 
+#if CV_SIMD_FP16
+template<> inline void EXPECT_COMPARE_EQ_<__fp16>(const __fp16 a, const __fp16 b)
+{
+    EXPECT_LT(std::abs(float(a - b)), 0.126);
+}
+#endif
+
 // pack functions do not do saturation when converting from 64-bit types
 template<typename T, typename W>
```

Review comment:
why 0.126? Please add link/formulae/description why the constant is used.
**File:** modules/core/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #25196: core: add universal intrinsics for fp16

**Code Changes:**
```diff
@@ -182,6 +182,13 @@ template<> inline void EXPECT_COMPARE_EQ_<double>(const double a, const double b
     EXPECT_DOUBLE_EQ( a, b );
 }
 
+#if CV_SIMD_FP16
+template<> inline void EXPECT_COMPARE_EQ_<__fp16>(const __fp16 a, const __fp16 b)
+{
+    EXPECT_LT(std::abs(float(a - b)), 0.126);
+}
+#endif
```

Review comment:
please remove, if not needed any more.
**File:** modules/core/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #25196: core: add universal intrinsics for fp16
**Review Line:** 567

**Code Changes:**
```diff
     }
 
+    // Handle accuracy for fp16
+    TheTest & test_div_fp16()
+    {
+#if CV_SIMD_FP16
+        Data<R> dataA, dataB;
+        dataB.reverse();
+        R a = dataA, b = dataB;
+
+        Data<R> resC = v_div(a, b);
```

Review comment:
I propose to add skip message to else branch to make it obvious from test. FP16 support may be disabled.
**File:** modules/core/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #25196: core: add universal intrinsics for fp16
**Review Line:** 188

**Code Changes:**
```diff
 }
 
+#if CV_SIMD_FP16
+template<> inline void EXPECT_COMPARE_EQ_<__fp16>(const __fp16 a, const __fp16 b)
+{
+    EXPECT_LT(std::abs(float(a - b)), 0.126);
+}
+#endif
+
 // pack functions do not do saturation when converting from 64-bit types
 template<typename T, typename W>
```

Review comment:
The biggest difference I observed is 0.125. It looks like a FP16 accurarcy problem to me. So set `0.126` to make tests green.
**File:** modules/core/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #25196: core: add universal intrinsics for fp16
**Review Line:** 567

**Code Changes:**
```diff
     }
 
+    // Handle accuracy for fp16
+    TheTest & test_div_fp16()
+    {
+#if CV_SIMD_FP16
+        Data<R> dataA, dataB;
+        dataB.reverse();
+        R a = dataA, b = dataB;
+
+        Data<R> resC = v_div(a, b);
```

Review comment:
Using plain printf() or any fancy macros for this purpose?
**File:** modules/core/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #25196: core: add universal intrinsics for fp16
**Review Line:** 567

**Code Changes:**
```diff
     }
 
+    // Handle accuracy for fp16
+    TheTest & test_div_fp16()
+    {
+#if CV_SIMD_FP16
+        Data<R> dataA, dataB;
+        dataB.reverse();
+        R a = dataA, b = dataB;
+
+        Data<R> resC = v_div(a, b);
```

Review comment:
I do not have strong opinion, just to see that tests are skipped. It's very easy to loose fp16 support and have false impression that it's used and works well.
**File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #25196: core: add universal intrinsics for fp16

**Code Changes:**
```diff
@@ -61,6 +61,11 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
 #else
 #define CV_SIMD128_64F 0
 #endif
+#if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
+    #define CV_SIMD128_FP16 1
+#else
+    #define CV_SIMD128_FP16 0
+#endif
 
```

Review comment:
Signatures are all updated to `const dtype &x`.
**File:** modules/core/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #25196: core: add universal intrinsics for fp16
**Review Line:** 567

**Code Changes:**
```diff
     }
 
+    // Handle accuracy for fp16
+    TheTest & test_div_fp16()
+    {
+#if CV_SIMD_FP16
+        Data<R> dataA, dataB;
+        dataB.reverse();
+        R a = dataA, b = dataB;
+
+        Data<R> resC = v_div(a, b);
```

Review comment:
Okay, added to everywhere needed.
**File:** modules/core/include/opencv2/core/hal/intrin_neon.hpp
**Change Type:** modified
**Context:** PR #25196: core: add universal intrinsics for fp16

**Code Changes:**
```diff
@@ -61,6 +61,11 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
 #else
 #define CV_SIMD128_64F 0
 #endif
+#if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
+    #define CV_SIMD128_FP16 1
+#else
+    #define CV_SIMD128_FP16 0
+#endif
 
```

Review comment:
``` #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) && __ARM_FEATURE_FP16_VECTOR_ARITHMETIC #define CV_SIMD128_FP16 1 #else #define CV_SIMD128_FP16 0 #endif ```
**File:** modules/imgproc/src/emd_new.cpp
**Change Type:** added
**Context:** PR #25469: imgproc: refactor EMD to reduce C-API usage - - added more tests for EMD - refactored to remove CvArr - used BufferArea for memory allocati...
**Review Line:** 6

**Code Changes:**
```diff
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+/*
+    Partially based on Yossi Rubner code:
+    =========================================================================
+    emd.c
+
+    Last update: 3/14/98
+
```

Review comment:
Is it new code? What is the original license?
**File:** modules/imgproc/src/emd_new.cpp
**Change Type:** added
**Context:** PR #25469: imgproc: refactor EMD to reduce C-API usage - - added more tests for EMD - refactored to remove CvArr - used BufferArea for memory allocati...
**Review Line:** 6

**Code Changes:**
```diff
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html
+
+/*
+    Partially based on Yossi Rubner code:
+    =========================================================================
+    emd.c
+
+    Last update: 3/14/98
+
```

Review comment:
No, all code and license are from old `emd.cpp` https://github.com/opencv/opencv/blob/4.x/modules/imgproc/src/emd.cpp#L42-L58 **UPD:** I've found original code, no license there: http://robotics.stanford.edu/~rubner/emd/default.htm
**File:** modules/imgproc/test/test_emd.cpp
**Change Type:** modified
**Context:** PR #25469: imgproc: refactor EMD to reduce C-API usage - - added more tests for EMD - refactored to remove CvArr - used BufferArea for memory allocati...

**Code Changes:**
```diff
@@ -1,93 +1,250 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
```

Review comment:
It'll be dedicated test with parameter.
**File:** modules/imgproc/test/test_emd.cpp
**Change Type:** modified
**Context:** PR #25469: imgproc: refactor EMD to reduce C-API usage - - added more tests for EMD - refactored to remove CvArr - used BufferArea for memory allocati...

**Code Changes:**
```diff
@@ -1,93 +1,250 @@
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-//  By downloading, copying, installing or using the software you agree to this license.
-//  If you do not agree to this license, do not download, install,
-//  copy or use the software.
-//
-//
```

Review comment:
I decided to extract this block to separate _invalid_ test. It seem to be too small to be in a separate parametrized test. `SCOPED_TRACE` would help with debugging test failures.
**File:** modules/dnn/test/test_misc.cpp
**Change Type:** modified
**Context:** PR #25463: Change opencv_face_detector related tests and samples from caffe to onnx
**Review Line:** 251

**Code Changes:**
```diff
     EXPECT_FALSE(net.empty());
-    net = readNet(findDataFile("dnn/opencv_face_detector.caffemodel", false),
-                  findDataFile("dnn/opencv_face_detector.prototxt"));
-    EXPECT_FALSE(net.empty());
     net = readNet(findDataFile("dnn/tiny-yolo-voc.cfg"),
                   findDataFile("dnn/tiny-yolo-voc.weights", false));
     EXPECT_FALSE(net.empty());
```

Review comment:
The new model is already covered by test in modules/objdetect/test/test_face.cpp. It does not make sense to infer it twice. The original model was not there and was covered by test to ensure the sample works well.
**File:** modules/dnn/test/test_misc.cpp
**Change Type:** modified
**Context:** PR #25463: Change opencv_face_detector related tests and samples from caffe to onnx
**Review Line:** 251

**Code Changes:**
```diff
     EXPECT_FALSE(net.empty());
-    net = readNet(findDataFile("dnn/opencv_face_detector.caffemodel", false),
-                  findDataFile("dnn/opencv_face_detector.prototxt"));
-    EXPECT_FALSE(net.empty());
     net = readNet(findDataFile("dnn/tiny-yolo-voc.cfg"),
                   findDataFile("dnn/tiny-yolo-voc.weights", false));
     EXPECT_FALSE(net.empty());
```

Review comment:
OK, I will just remove this test.
**File:** modules/dnn/misc/python/test/test_dnn.py
**Change Type:** modified
**Context:** PR #25463: Change opencv_face_detector related tests and samples from caffe to onnx

**Code Changes:**
```diff
@@ -286,41 +286,42 @@ def test_textdetection_model(self):
 
 
     def test_face_detection(self):
-        proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt')
-        model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=False)
-        if proto is None or model is None:
-            raise unittest.SkipTest("Missing DNN test files (dnn/opencv_face_detector.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.")
-
+        model = self.find_dnn_file('dnn/onnx/models/yunet-202303.onnx', required=False)
```

Review comment:
`modules/dnn/misc/python/test/test_dnn.py:105: def find_dnn_file(self, filename, required=True)` Please use `required` option for it. OpenCV CI uses `OPENCV_DNN_TEST_REQUIRE_TESTDATA=1` to not hide test failures. `OPENCV_TEST_DATA_PATH` is also set correctly, so the test should be executed on CI without issues.
**File:** modules/dnn/misc/python/test/test_dnn.py
**Change Type:** modified
**Context:** PR #25463: Change opencv_face_detector related tests and samples from caffe to onnx

**Code Changes:**
```diff
@@ -286,41 +286,42 @@ def test_textdetection_model(self):
 
 
     def test_face_detection(self):
-        proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt')
-        model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=False)
-        if proto is None or model is None:
-            raise unittest.SkipTest("Missing DNN test files (dnn/opencv_face_detector.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.")
-
+        model = self.find_dnn_file('dnn/onnx/models/yunet-202303.onnx', required=False)
```

Review comment:
Score/NMS thresholds are different from ones from `modules/dnn/misc/face_detector_accuracy.py`.
**File:** modules/dnn/misc/python/test/test_dnn.py
**Change Type:** modified
**Context:** PR #25463: Change opencv_face_detector related tests and samples from caffe to onnx

**Code Changes:**
```diff
@@ -286,41 +286,42 @@ def test_textdetection_model(self):
 
 
     def test_face_detection(self):
-        proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt')
-        model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=False)
-        if proto is None or model is None:
-            raise unittest.SkipTest("Missing DNN test files (dnn/opencv_face_detector.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.")
-
+        model = self.find_dnn_file('dnn/onnx/models/yunet-202303.onnx', required=False)
```

Review comment:
You are right. The threshold here is the same as opencv_zoo. I should change it to match the accuracy test. It's the best number for accuracy test.
**File:** modules/dnn/misc/python/test/test_dnn.py
**Change Type:** modified
**Context:** PR #25463: Change opencv_face_detector related tests and samples from caffe to onnx

**Code Changes:**
```diff
@@ -286,41 +286,42 @@ def test_textdetection_model(self):
 
 
     def test_face_detection(self):
-        proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt')
-        model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=False)
-        if proto is None or model is None:
-            raise unittest.SkipTest("Missing DNN test files (dnn/opencv_face_detector.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.")
-
+        model = self.find_dnn_file('dnn/onnx/models/yunet-202303.onnx', required=False)
```

Review comment:
So if there are the best configurations, why not use them everywhere? Or do you want to match some existing test?
**File:** modules/dnn/misc/python/test/test_dnn.py
**Change Type:** modified
**Context:** PR #25463: Change opencv_face_detector related tests and samples from caffe to onnx

**Code Changes:**
```diff
@@ -286,41 +286,42 @@ def test_textdetection_model(self):
 
 
     def test_face_detection(self):
-        proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt')
-        model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=False)
-        if proto is None or model is None:
-            raise unittest.SkipTest("Missing DNN test files (dnn/opencv_face_detector.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.")
-
+        model = self.find_dnn_file('dnn/onnx/models/yunet-202303.onnx', required=False)
```

Review comment:
Sure, I will change it later. The number is from YuNet developers, and it will get the best score on the dataset. OpenCV Zoo uses it for accuracy test as well. https://github.com/opencv/opencv_zoo/blob/ec5b2c8af6b3505b28b7721f7d18528ac22afa2b/tools/eval/eval.py#L60-L66
**File:** modules/dnn/misc/python/test/test_dnn.py
**Change Type:** modified
**Context:** PR #25463: Change opencv_face_detector related tests and samples from caffe to onnx

**Code Changes:**
```diff
@@ -286,41 +286,42 @@ def test_textdetection_model(self):
 
 
     def test_face_detection(self):
-        proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt')
-        model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=False)
-        if proto is None or model is None:
-            raise unittest.SkipTest("Missing DNN test files (dnn/opencv_face_detector.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.")
-
+        model = self.find_dnn_file('dnn/onnx/models/yunet-202303.onnx', required=False)
```

Review comment:
if branch with exception is not needed. `find_dnn_file` uses `find_file` internally. The last one already implements the same logic: https://github.com/opencv/opencv/blob/bbe86e6deaea2ad80b14983a4abf68dabf85ec95/modules/python/test/tests_common.py#L30
**File:** modules/dnn/misc/python/test/test_dnn.py
**Change Type:** modified
**Context:** PR #25463: Change opencv_face_detector related tests and samples from caffe to onnx

**Code Changes:**
```diff
@@ -286,41 +286,42 @@ def test_textdetection_model(self):
 
 
     def test_face_detection(self):
-        proto = self.find_dnn_file('dnn/opencv_face_detector.prototxt')
-        model = self.find_dnn_file('dnn/opencv_face_detector.caffemodel', required=False)
-        if proto is None or model is None:
-            raise unittest.SkipTest("Missing DNN test files (dnn/opencv_face_detector.{prototxt/caffemodel}). Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.")
-
+        model = self.find_dnn_file('dnn/onnx/models/yunet-202303.onnx', required=False)
```

Review comment:
The options are implemented for previous model and not related to the new one.
**File:** modules/dnn/misc/python/test/test_dnn.py
**Change Type:** modified
**Context:** PR #25463: Change opencv_face_detector related tests and samples from caffe to onnx
**Review Line:** 300

**Code Changes:**
```diff
+               [1, 119.57139, 48.482178, 30.600697, 40.485996, 0.906021],
+               [1, 259.0921, 229.30713, 31.088186, 39.74022, 0.90490955],
+               [1, 405.69778, 87.28158, 33.393406, 42.96226, 0.8996978]]
 
         print('\n')
         for backend, target in self.dnnBackendsAndTargets:
             printParams(backend, target)
 
-            net = cv.dnn.readNet(proto, model)
-            net.setPreferableBackend(backend)
-            net.setPreferableTarget(target)
```

Review comment:
backend and target is not set in the loop. All iterations use default back-end. FaceDetectorYN has backend and target options in factory method. I propose to recreate the object on each iteration with properly set backend parameters.
**File:** modules/dnn/misc/python/test/test_dnn.py
**Change Type:** modified
**Context:** PR #25463: Change opencv_face_detector related tests and samples from caffe to onnx
**Review Line:** 300

**Code Changes:**
```diff
+               [1, 119.57139, 48.482178, 30.600697, 40.485996, 0.906021],
+               [1, 259.0921, 229.30713, 31.088186, 39.74022, 0.90490955],
+               [1, 405.69778, 87.28158, 33.393406, 42.96226, 0.8996978]]
 
         print('\n')
         for backend, target in self.dnnBackendsAndTargets:
             printParams(backend, target)
 
-            net = cv.dnn.readNet(proto, model)
-            net.setPreferableBackend(backend)
-            net.setPreferableTarget(target)
```

Review comment:
Yes. FaceDetectorYN doesn't export some methods like setBackend and setTarget. I will make it create a new object for each BackendAndTargets
**File:** modules/core/src/minmax.cpp
**Change Type:** modified
**Context:** PR #25553: Fix HAL interface for hal_ni_minMaxIdx

**Code Changes:**
```diff
@@ -1510,9 +1510,19 @@ 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, src.rows, src.depth(), minVal, maxVal,
-                 minIdx, maxIdx, mask.data);
```

Review comment:
since you have a comprehensive CV_Assert() above, there is no need in extra branch. Pass mask.data in both cases, pass `minIdx ? minIdx : &_minIdx`, `maxIdx ? maxIdx : &_maxIdx` in both cases, pass `src.cols*cn` in both cases.
**File:** modules/core/src/minmax.cpp
**Change Type:** modified
**Context:** PR #25553: Fix HAL interface for hal_ni_minMaxIdx

**Code Changes:**
```diff
@@ -1510,9 +1510,19 @@ 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, src.rows, src.depth(), minVal, maxVal,
-                 minIdx, maxIdx, mask.data);
```

Review comment:
use `src.total()*cn` and everything else as in `dims <= 2` case.
**File:** modules/core/src/minmax.cpp
**Change Type:** modified
**Context:** PR #25553: Fix HAL interface for hal_ni_minMaxIdx
**Review Line:** 1515

**Code Changes:**
```diff
 
     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, src.rows, src.depth(), minVal, maxVal,
-                 minIdx, maxIdx, mask.data);
+    {
+        CALL_HAL(minMaxIdx, cv_hal_minMaxIdx, src.data, src.step, src.cols*cn, src.rows, src.depth(),
```

Review comment:
1. This seems like a bug because as documented "When minIdx is not NULL, it must have at least 2 elements" 2. Passing a non-null pointer means the HAL implementation can't optimise for minIdx and maxIdx being null. I suggest instead passing minIdx and maxIdx directly to cv_hal_minMaxIdx at line 1519. We already know from the assert above that they must be null if cn>1.