nareshmlx/opencv-pr huggingface dataset:
**File:** modules/dnn/src/layers/gather_layer.cpp
**Change Type:** modified
**Context:** PR #22993: dnn: fix gather layer implementation - - support FP16 data fixup #21738 Fixes failed tests: ``` [ FAILED ] Test_ONNX_layers.Gather/1, where...
**Review Line:** 82

**Code Changes:**
```diff
+        CV_CheckTypeEQ(inp.type(), out.type(), "");
+        CV_CheckTypeEQ(indices32S.type(), CV_32SC1, "");
+
         const int axis = normalize_axis(m_axis, shape(inp));
 
+        // FIXIT: why should we work with non-normalized input? it should be handled in importer or layers's output generator
+        const int axis_size = (int)inp.size[axis];
+        for (size_t j = 0 ; j < indices_total; ++j)
+        {
+            int& idx = indices32S.at<int>(j);
+            idx = normalize_axis(idx, axis_size);  // validate and normalize indices
```

Review comment:
It was originally normalized on the go: ```cpp for (size_t i = 0; i < outer_dims; ++i) { // ... for (size_t j = 0 ; j < indices.total(); ++j) { const size_t index = (static_cast<int>(idx[j]) + inp.size[axis]) % inp.size[axis]; // .. } } ``` I think in onnx importer we should load what it is without any extra operation on constant input & attributes. Operations like normalization should be done in the layer constructor or somewhere. We need the original information when it comes to build operators for other backend, like CANN and TIM-VX, who have operator primitives aligned with ONNX, TF ...
**File:** modules/dnn/src/layers/gather_layer.cpp
**Change Type:** modified
**Context:** PR #22993: dnn: fix gather layer implementation - - support FP16 data fixup #21738 Fixes failed tests: ``` [ FAILED ] Test_ONNX_layers.Gather/1, where...
**Review Line:** 82

**Code Changes:**
```diff
+        CV_CheckTypeEQ(inp.type(), out.type(), "");
+        CV_CheckTypeEQ(indices32S.type(), CV_32SC1, "");
+
         const int axis = normalize_axis(m_axis, shape(inp));
 
+        // FIXIT: why should we work with non-normalized input? it should be handled in importer or layers's output generator
+        const int axis_size = (int)inp.size[axis];
+        for (size_t j = 0 ; j < indices_total; ++j)
+        {
+            int& idx = indices32S.at<int>(j);
+            idx = normalize_axis(idx, axis_size);  // validate and normalize indices
```

Review comment:
"On the go" normalization is not efficient as performs it multiple times (especially through division). There is change to perform normalization once (per forward() call) before the main loop.
**File:** modules/dnn/src/layers/gather_layer.cpp
**Change Type:** modified
**Context:** PR #22993: dnn: fix gather layer implementation - - support FP16 data fixup #21738 Fixes failed tests: ``` [ FAILED ] Test_ONNX_layers.Gather/1, where...
**Review Line:** 82

**Code Changes:**
```diff
+        CV_CheckTypeEQ(inp.type(), out.type(), "");
+        CV_CheckTypeEQ(indices32S.type(), CV_32SC1, "");
+
         const int axis = normalize_axis(m_axis, shape(inp));
 
+        // FIXIT: why should we work with non-normalized input? it should be handled in importer or layers's output generator
+        const int axis_size = (int)inp.size[axis];
+        for (size_t j = 0 ; j < indices_total; ++j)
+        {
+            int& idx = indices32S.at<int>(j);
+            idx = normalize_axis(idx, axis_size);  // validate and normalize indices
```

Review comment:
It was done because the elements of index tensor can be negative per spec and non-constant at the same time. We cannot perform normalization ahead of time since we don't have the data.
**File:** modules/core/src/parallel_impl.cpp
**Change Type:** modified
**Context:** PR #22966: Fix slower CV_PAUSE on SkyLake and above.
**Review Line:** 62

**Code Changes:**
```diff
 #     define _mm_pause cv_non_sse_mm_pause
 #   endif
-#   define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { _mm_pause(); } } while (0)
+// 5 * v is meants for backward compatibility: with pre-Skylake CPUs, _mm_pause took 4 or 5 cycles.
+// With post-Skylake CPUs, _mm_pause takes 140 cycles.
+#   define CV_PAUSE(v) do { const uint64_t __delay = 5 * v; uint64_t __init = __rdtsc(); do { _mm_pause(); } while ((__rdtsc() - __init) < __delay); } while (0)
 # elif defined __GNUC__ && defined __aarch64__
 #   define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("yield" ::: "memory"); } } while (0)
 # elif defined __GNUC__ && defined __arm__
```

Review comment:
We could indeed use _mm_pause once, that would save some cycles (I thought RDTSC was 18 cycles) BUT that would not be compatible with older CPUs where ```_mm_pause``` is only 4/5 cycles. Do we have a way to check for SkyLake and above CPUs ? I'll gladly make a patch for that.
**File:** modules/core/src/parallel_impl.cpp
**Change Type:** modified
**Context:** PR #22966: Fix slower CV_PAUSE on SkyLake and above.
**Review Line:** 62

**Code Changes:**
```diff
 #     define _mm_pause cv_non_sse_mm_pause
 #   endif
-#   define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { _mm_pause(); } } while (0)
+// 5 * v is meants for backward compatibility: with pre-Skylake CPUs, _mm_pause took 4 or 5 cycles.
+// With post-Skylake CPUs, _mm_pause takes 140 cycles.
+#   define CV_PAUSE(v) do { const uint64_t __delay = 5 * v; uint64_t __init = __rdtsc(); do { _mm_pause(); } while ((__rdtsc() - __init) < __delay); } while (0)
 # elif defined __GNUC__ && defined __aarch64__
 #   define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("yield" ::: "memory"); } } while (0)
 # elif defined __GNUC__ && defined __arm__
```

Review comment:
Skylake is here for 7+ years: https://en.wikipedia.org/wiki/Skylake_(microarchitecture) There is `OPENCV_THREAD_POOL_ACTIVE_WAIT_PAUSE_LIMIT` runtime parameter which could control total number of `pause` operations for fine tuning.
**File:** modules/core/src/parallel_impl.cpp
**Change Type:** modified
**Context:** PR #22966: Fix slower CV_PAUSE on SkyLake and above.
**Review Line:** 62

**Code Changes:**
```diff
 #     define _mm_pause cv_non_sse_mm_pause
 #   endif
-#   define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { _mm_pause(); } } while (0)
+// 5 * v is meants for backward compatibility: with pre-Skylake CPUs, _mm_pause took 4 or 5 cycles.
+// With post-Skylake CPUs, _mm_pause takes 140 cycles.
+#   define CV_PAUSE(v) do { const uint64_t __delay = 5 * v; uint64_t __init = __rdtsc(); do { _mm_pause(); } while ((__rdtsc() - __init) < __delay); } while (0)
 # elif defined __GNUC__ && defined __aarch64__
 #   define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("yield" ::: "memory"); } } while (0)
 # elif defined __GNUC__ && defined __arm__
```

Review comment:
Indeed, so what do you suggest: that I make a new pull request that only does one ```_mm_pause``` where defined ? And for older CPUs, ```OPENCV_THREAD_POOL_ACTIVE_WAIT_PAUSE_LIMIT``` should be used ? I am totally fine with that.
**File:** modules/core/src/parallel_impl.cpp
**Change Type:** modified
**Context:** PR #22966: Fix slower CV_PAUSE on SkyLake and above.
**Review Line:** 62

**Code Changes:**
```diff
 #     define _mm_pause cv_non_sse_mm_pause
 #   endif
-#   define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { _mm_pause(); } } while (0)
+// 5 * v is meants for backward compatibility: with pre-Skylake CPUs, _mm_pause took 4 or 5 cycles.
+// With post-Skylake CPUs, _mm_pause takes 140 cycles.
+#   define CV_PAUSE(v) do { const uint64_t __delay = 5 * v; uint64_t __init = __rdtsc(); do { _mm_pause(); } while ((__rdtsc() - __init) < __delay); } while (0)
 # elif defined __GNUC__ && defined __aarch64__
 #   define CV_PAUSE(v) do { for (int __delay = (v); __delay > 0; --__delay) { asm volatile("yield" ::: "memory"); } } while (0)
 # elif defined __GNUC__ && defined __arm__
```

Review comment:
Done in https://github.com/opencv/opencv/pull/22988
**File:** samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Processor.java
**Change Type:** modified
**Context:** PR #22754: C-API cleanup for OpenCV 5.x (imgproc, highgui) - C-API will be removed completely. This PR covers _imgproc_ and _highgui_ (**in progress**...

**Code Changes:**
```diff
@@ -64,7 +64,7 @@ public synchronized void prepareGameSize(int width, int height) {
         }
 
         for (int i = 0; i < GRID_AREA; i++) {
-            Size s = Imgproc.getTextSize(Integer.toString(i + 1), 3/* CV_FONT_HERSHEY_COMPLEX */, 1, 2, null);
+            Size s = Imgproc.getTextSize(Integer.toString(i + 1), Imgproc.FONT_HERSHEY_COMPLEX, 1, 2, null);
             mTextHeights[i] = (int) s.height;
             mTextWidths[i] = (int) s.width;
         }
@@ -100,7 +100,7 @@ public synchronized Mat puzzleFrame(Mat inputPicture) {
```

Review comment:
Size s = Imgproc.getTextSize(Integer.toString(i + 1), Imgproc.FONT_HERSHEY_COMPLEX, 1, 2, null);
**File:** samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Processor.java
**Change Type:** modified
**Context:** PR #22754: C-API cleanup for OpenCV 5.x (imgproc, highgui) - C-API will be removed completely. This PR covers _imgproc_ and _highgui_ (**in progress**...

**Code Changes:**
```diff
@@ -64,7 +64,7 @@ public synchronized void prepareGameSize(int width, int height) {
         }
 
         for (int i = 0; i < GRID_AREA; i++) {
-            Size s = Imgproc.getTextSize(Integer.toString(i + 1), 3/* CV_FONT_HERSHEY_COMPLEX */, 1, 2, null);
+            Size s = Imgproc.getTextSize(Integer.toString(i + 1), Imgproc.FONT_HERSHEY_COMPLEX, 1, 2, null);
             mTextHeights[i] = (int) s.height;
             mTextWidths[i] = (int) s.width;
         }
@@ -100,7 +100,7 @@ public synchronized Mat puzzleFrame(Mat inputPicture) {
```

Review comment:
(rows / GRID_SIZE + mTextHeights[idx]) / 2), Imgproc.FONT_HERSHEY_COMPLEX, 1, new Scalar(255, 0, 0, 255), 2);
**File:** modules/imgproc/test/test_color.cpp
**Change Type:** modified
**Context:** PR #22754: C-API cleanup for OpenCV 5.x (imgproc, highgui) - C-API will be removed completely. This PR covers _imgproc_ and _highgui_ (**in progress**...
**Review Line:** 164

**Code Changes:**
```diff
 
-    if(!test_cpp)
-        cvCvtColor( inplace ? out0 : test_array[INPUT][0], out0, fwd_code );
-    else
-        cv::cvtColor( cv::cvarrToMat(inplace ? out0 : test_array[INPUT][0]), _out0, fwd_code, _out0.channels());
+    cv::cvtColor( cv::cvarrToMat(inplace ? out0 : test_array[INPUT][0]), _out0, fwd_code, _out0.channels());
 
     if( inplace )
     {
         cvCopy( out0, test_array[OUTPUT][1] );
         out0 = test_array[OUTPUT][1];
```

Review comment:
`cvarrToMat` is legacy call. 5.x API should not provide `cvArr` type.
**File:** modules/imgproc/test/test_color.cpp
**Change Type:** modified
**Context:** PR #22754: C-API cleanup for OpenCV 5.x (imgproc, highgui) - C-API will be removed completely. This PR covers _imgproc_ and _highgui_ (**in progress**...
**Review Line:** 1071

**Code Changes:**
```diff
@@ -1077,7 +1068,7 @@ double CV_ColorLabTest::get_success_error_level( int /*test_case_idx*/, int i, i
 {
     int depth = test_mat[i][j].depth();
     // j == 0 is for forward code, j == 1 is for inverse code
-    return (depth ==  CV_8U) ? (srgb ? 32 : 8) :
+    return (depth ==  CV_8U) ? (srgb ? 37 : 8) :
            //(depth == CV_16U) ? 32 : // 16u is disabled
            srgb ? ((j == 0) ? 0.4 : 0.0055) : 1e-3;
 }
@@ -1256,7 +1247,7 @@ double CV_ColorLuvTest::get_success_error_level( int /*test_case_idx*/, int i, i
 {
```

Review comment:
Why is it changed?
**File:** modules/imgproc/test/test_color.cpp
**Change Type:** modified
**Context:** PR #22754: C-API cleanup for OpenCV 5.x (imgproc, highgui) - C-API will be removed completely. This PR covers _imgproc_ and _highgui_ (**in progress**...
**Review Line:** 1250

**Code Changes:**
```diff
@@ -1256,7 +1247,7 @@ double CV_ColorLuvTest::get_success_error_level( int /*test_case_idx*/, int i, i
 {
     int depth = test_mat[i][j].depth();
     // j == 0 is for forward code, j == 1 is for inverse code
-    return (depth ==  CV_8U) ? (srgb ? 36 : 8) :
+    return (depth ==  CV_8U) ? (srgb ? 37 : 8) :
            //(depth == CV_16U) ? 32 : // 16u is disabled
            5e-2;
 }
@@ -1730,13 +1721,8 @@ double CV_ColorBayerTest::get_success_error_level( int /*test_case_idx*/, int /*
 
```

Review comment:
The same question.
**File:** modules/imgproc/test/test_color.cpp
**Change Type:** modified
**Context:** PR #22754: C-API cleanup for OpenCV 5.x (imgproc, highgui) - C-API will be removed completely. This PR covers _imgproc_ and _highgui_ (**in progress**...
**Review Line:** 164

**Code Changes:**
```diff
 
-    if(!test_cpp)
-        cvCvtColor( inplace ? out0 : test_array[INPUT][0], out0, fwd_code );
-    else
-        cv::cvtColor( cv::cvarrToMat(inplace ? out0 : test_array[INPUT][0]), _out0, fwd_code, _out0.channels());
+    cv::cvtColor( cv::cvarrToMat(inplace ? out0 : test_array[INPUT][0]), _out0, fwd_code, _out0.channels());
 
     if( inplace )
     {
         cvCopy( out0, test_array[OUTPUT][1] );
         out0 = test_array[OUTPUT][1];
```

Review comment:
This will be revisited later, during _core_ module cleanup. I'm afraid it would be too hard to remove `cvarrToMat` completely as it is being used extensively in many places (~400 calls), e.g. _videoio_ backends. All these parts would need to be rewritten from `IplImage` to `cv::Mat`. As the first step we can "hide" part of C-API from the user (move to private headers).
**File:** modules/imgproc/test/test_color.cpp
**Change Type:** modified
**Context:** PR #22754: C-API cleanup for OpenCV 5.x (imgproc, highgui) - C-API will be removed completely. This PR covers _imgproc_ and _highgui_ (**in progress**...
**Review Line:** 1071

**Code Changes:**
```diff
@@ -1077,7 +1068,7 @@ double CV_ColorLabTest::get_success_error_level( int /*test_case_idx*/, int i, i
 {
     int depth = test_mat[i][j].depth();
     // j == 0 is for forward code, j == 1 is for inverse code
-    return (depth ==  CV_8U) ? (srgb ? 32 : 8) :
+    return (depth ==  CV_8U) ? (srgb ? 37 : 8) :
            //(depth == CV_16U) ? 32 : // 16u is disabled
            srgb ? ((j == 0) ? 0.4 : 0.0055) : 1e-3;
 }
@@ -1256,7 +1247,7 @@ double CV_ColorLuvTest::get_success_error_level( int /*test_case_idx*/, int i, i
 {
```

Review comment:
I came to conclusion that these thresholds have been chosen experimentally and after changing RNG seeds some tests can fail. We've observed the same problem with these tests in another PR: https://github.com/opencv/opencv/pull/16189#discussion_r996149383 I specifically moved this fix to separate commit, so it can be backported to 4.x later.
**File:** modules/calib/src/calibinit.cpp
**Change Type:** modified
**Context:** PR #22754: C-API cleanup for OpenCV 5.x (imgproc, highgui) - C-API will be removed completely. This PR covers _imgproc_ and _highgui_ (**in progress**...

**Code Changes:**
```diff
@@ -102,8 +102,6 @@ namespace cv {
 
 #define MAX_CONTOUR_APPROX  7
 
-#define USE_CV_FINDCONTOURS  // switch between findContours() and legacy C API
-#ifdef USE_CV_FINDCONTOURS
 struct QuadCountour {
     Point pt[4];
     int parent_contour;
@@ -114,13 +112,6 @@ struct QuadCountour {
```

Review comment:
maybe deleting `Mat binarized_img = thresh_img_new;` and `detector.generateQuads(thresh_img_new, flags);` will be better
**File:** modules/video/test/test_camshift.cpp
**Change Type:** modified
**Context:** PR #22754: C-API cleanup for OpenCV 5.x (imgproc, highgui) - C-API will be removed completely. This PR covers _imgproc_ and _highgui_ (**in progress**...

**Code Changes:**
```diff
@@ -274,7 +274,7 @@ int CV_CamShiftTest::validate_test_results( int /*test_case_idx*/ )
         cvIsNaN(box.center.y) || cvIsInf(box.center.y) ||
         cvIsNaN(box.angle) || cvIsInf(box.angle) || box.angle < -180 || box.angle > 180 )
     {
-        ts->printf( cvtest::TS::LOG, "Invalid CvBox2D or CvConnectedComp was returned by cvCamShift\n" );
+        ts->printf( cvtest::TS::LOG, "Invalid RotatedRect was returned by CamShift\n" );
         code = cvtest::TS::FAIL_INVALID_OUTPUT;
         goto _exit_;
     }
@@ -317,19 +317,6 @@ int CV_CamShiftTest::validate_test_results( int /*test_case_idx*/ )
```

Review comment:
Box2D -> RotatedRect
**File:** doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown
**Change Type:** modified
**Context:** PR #22754: C-API cleanup for OpenCV 5.x (imgproc, highgui) - C-API will be removed completely. This PR covers _imgproc_ and _highgui_ (**in progress**...

**Code Changes:**
```diff
@@ -204,9 +204,9 @@ receives three arguments:
 
     We can choose any of three shapes for our kernel:
 
-    -   Rectangular box: CV_SHAPE_RECT
-    -   Cross: CV_SHAPE_CROSS
-    -   Ellipse: CV_SHAPE_ELLIPSE
+    -   Rectangular box: Imgproc.SHAPE_RECT
+    -   Cross: Imgproc.SHAPE_CROSS
+    -   Ellipse: Imgproc.SHAPE_ELLIPSE
```

Review comment:
_(it is in Java tab)_ Rectangular box: Imgproc.SHAPE_RECT Cross: Imgproc.SHAPE_CROSS Ellipse: Imgproc.SHAPE_ELLIPSE
**File:** modules/dnn/perf/perf_net.cpp
**Change Type:** modified
**Context:** PR #22840: DNN: reduce the memory used in convolution layer

**Code Changes:**
```diff
@@ -198,6 +198,7 @@ PERF_TEST_P_(DNNTestNetwork, Inception_v2_SSD_TensorFlow)
 
 PERF_TEST_P_(DNNTestNetwork, YOLOv3)
 {
+    applyTestTag(CV_TEST_TAG_MEMORY_2GB);
     if (backend == DNN_BACKEND_HALIDE)
         throw SkipTestException("");
 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2020040000)  // nGraph compilation failure
@@ -220,6 +221,7 @@ PERF_TEST_P_(DNNTestNetwork, YOLOv3)
 
```

Review comment:
> `CV_TEST_TAG_VERYLONG` Why do we need to add this to resolve out of memory issue?
**File:** modules/imgproc/test/test_filter.cpp
**Change Type:** modified
**Context:** PR #22937: Integer underflow fix for morphologyEx in Carotene (arm).

**Code Changes:**
```diff
@@ -2366,5 +2366,18 @@ TEST(Imgproc_GaussianBlur, regression_11303)
     EXPECT_LE(cv::norm(src, dst, NORM_L2), 1e-3);
 }
 
+TEST(Imgproc, morphologyEx_small_input_22893)
+{
+    char input_data[] = {1, 2, 3, 4};
+    char gold_data[] = {2, 3, 4, 4};
+    cv::Mat img(1, 4, CV_8UC1, input_data);
+    cv::Mat gold(1, 4, CV_8UC1, gold_data);
```

Review comment:
`ASSERT_EQ(0, cvtest::norm(result, gold, NORM_INF));`
**File:** cmake/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #22675: Update OpenCVDetectCUDA.cmake

**Code Changes:**
```diff
@@ -342,6 +342,8 @@ if(CUDA_FOUND)
     set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --use_fast_math)
   endif()
 
+  OCV_OPTION(CUDA_ENABLE_DELAYLOAD "Enable delayed loading of CUDA DLLs" OFF VISIBLE_IF MSVC AND (CMAKE_GENERATOR MATCHES "Visual Studio"))
+
   mark_as_advanced(CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD CUDA_SDK_ROOT_DIR)
 
   macro(ocv_cuda_filter_options)
@@ -537,4 +539,15 @@ if(HAVE_CUDA)
```

Review comment:
`OCV_OPTION` has `VISIBLE_IF` argument for conditions. I propose to replace the "if" with option with single line: ``` OCV_OPTION(CUDA_ENABLE_DELAYLOAD "Enable delayed loading of CUDA DLLs" OFF VISIBLE_IF MSVC AND (CMAKE_GENERATOR MATCHES "Visual Studio")) ```
**File:** cmake/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #22675: Update OpenCVDetectCUDA.cmake

**Code Changes:**
```diff
@@ -342,6 +342,8 @@ if(CUDA_FOUND)
     set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --use_fast_math)
   endif()
 
+  OCV_OPTION(CUDA_ENABLE_DELAYLOAD "Enable delayed loading of CUDA DLLs" OFF VISIBLE_IF MSVC AND (CMAKE_GENERATOR MATCHES "Visual Studio"))
+
   mark_as_advanced(CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD CUDA_SDK_ROOT_DIR)
 
   macro(ocv_cuda_filter_options)
@@ -537,4 +539,15 @@ if(HAVE_CUDA)
```

Review comment:
Yes of course, it's more readable and cleaner. Maybe it's worth think about defaulting to on? Just though about this option as it does not really change anything if the DLLs are there but avoids runtime errors if they are missing but still unused.
**File:** cmake/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #22675: Update OpenCVDetectCUDA.cmake

**Code Changes:**
```diff
@@ -342,6 +342,8 @@ if(CUDA_FOUND)
     set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --use_fast_math)
   endif()
 
+  OCV_OPTION(CUDA_ENABLE_DELAYLOAD "Enable delayed loading of CUDA DLLs" OFF VISIBLE_IF MSVC AND (CMAKE_GENERATOR MATCHES "Visual Studio"))
+
   mark_as_advanced(CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD CUDA_SDK_ROOT_DIR)
 
   macro(ocv_cuda_filter_options)
@@ -537,4 +539,15 @@ if(HAVE_CUDA)
```

Review comment:
I prefer to have it optional. It may affect libraries loading order for guys why use other CUDA-based libraries like TensorRT, CuDNN, python code with CUDA.
**File:** cmake/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #22675: Update OpenCVDetectCUDA.cmake

**Code Changes:**
```diff
@@ -342,6 +342,8 @@ if(CUDA_FOUND)
     set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --use_fast_math)
   endif()
 
+  OCV_OPTION(CUDA_ENABLE_DELAYLOAD "Enable delayed loading of CUDA DLLs" OFF VISIBLE_IF MSVC AND (CMAKE_GENERATOR MATCHES "Visual Studio"))
+
   mark_as_advanced(CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD CUDA_SDK_ROOT_DIR)
 
   macro(ocv_cuda_filter_options)
@@ -537,4 +539,15 @@ if(HAVE_CUDA)
```

Review comment:
Alright, just committed your proposal. So the PR can be merged now?
**File:** modules/objdetect/src/qrcode.cpp
**Change Type:** modified
**Context:** PR #22891: Use QR code alignment markers

**Code Changes:**
```diff
@@ -23,6 +23,7 @@
 namespace cv
 {
 using std::vector;
+using std::pair;
 
 static bool checkQRInputImage(InputArray img, Mat& gray)
 {
@@ -948,16 +949,21 @@ vector<Point2f> QRDetect::getQuadrilateral(vector<Point2f> angle_list)
     return result_angle_list;
```

Review comment:
`getHomography` is better.
**File:** modules/objdetect/src/qrcode.cpp
**Change Type:** modified
**Context:** PR #22891: Use QR code alignment markers

**Code Changes:**
```diff
@@ -23,6 +23,7 @@
 namespace cv
 {
 using std::vector;
+using std::pair;
 
 static bool checkQRInputImage(InputArray img, Mat& gray)
 {
@@ -948,16 +949,21 @@ vector<Point2f> QRDetect::getQuadrilateral(vector<Point2f> angle_list)
     return result_angle_list;
```

Review comment:
It could be just `vector<Point2f> perspective_points = {....}` without push_back.
**File:** modules/objdetect/src/qrcode.cpp
**Change Type:** modified
**Context:** PR #22891: Use QR code alignment markers

**Code Changes:**
```diff
@@ -23,6 +23,7 @@
 namespace cv
 {
 using std::vector;
+using std::pair;
 
 static bool checkQRInputImage(InputArray img, Mat& gray)
 {
@@ -948,16 +949,21 @@ vector<Point2f> QRDetect::getQuadrilateral(vector<Point2f> angle_list)
     return result_angle_list;
```

Review comment:
`resizedAlignmentMarker` has size 5x5 and the same content as `Mat(5, 5, CV_8UC1, alignmentMarker)`. resizedAlignmentMarker will be re-allocated during resize call or `alignmentMarker` will be corrupted during resize. Looks like some bug.
**File:** modules/objdetect/src/qrcode.cpp
**Change Type:** modified
**Context:** PR #22891: Use QR code alignment markers

**Code Changes:**
```diff
@@ -23,6 +23,7 @@
 namespace cv
 {
 using std::vector;
+using std::pair;
 
 static bool checkQRInputImage(InputArray img, Mat& gray)
 {
@@ -948,16 +949,21 @@ vector<Point2f> QRDetect::getQuadrilateral(vector<Point2f> angle_list)
     return result_angle_list;
```

Review comment:
No need to allocate the matrix. `matchTemplate` will do size calculation and override all values.
**File:** modules/objdetect/src/qrcode.cpp
**Change Type:** modified
**Context:** PR #22891: Use QR code alignment markers

**Code Changes:**
```diff
@@ -23,6 +23,7 @@
 namespace cv
 {
 using std::vector;
+using std::pair;
 
 static bool checkQRInputImage(InputArray img, Mat& gray)
 {
@@ -948,16 +949,21 @@ vector<Point2f> QRDetect::getQuadrilateral(vector<Point2f> angle_list)
     return result_angle_list;
```

Review comment:
` = ` is not needed.