nareshmlx/opencv-pr huggingface dataset:
**File:** modules/imgproc/src/stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc

**Code Changes:**
```diff
@@ -0,0 +1,1261 @@
+// 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.
+
+/*
+StackBlur - a fast almost Gaussian Blur
+Theory: http://underdestruction.com/2004/02/25/stackblur-2004
+The code has been borrowed from (https://github.com/flozz/StackBlur)
+and adapted for OpenCV by Zihao Mu.
```

Review comment:
Not sure if we really need SIMD for `cn == 4` only. I believe we can left generic C++ code here for initial iteration.
**File:** modules/imgproc/src/stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc

**Code Changes:**
```diff
@@ -0,0 +1,1261 @@
+// 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.
+
+/*
+StackBlur - a fast almost Gaussian Blur
+Theory: http://underdestruction.com/2004/02/25/stackblur-2004
+The code has been borrowed from (https://github.com/flozz/StackBlur)
+and adapted for OpenCV by Zihao Mu.
```

Review comment:
SIMD loops are wrote through `<=` condition in OpenCV: ```.diff -col < widthImg - 2*vlen + 1 +col <= widthImg - 2 * vlen ```
**File:** modules/imgproc/src/stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc

**Code Changes:**
```diff
@@ -0,0 +1,1261 @@
+// 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.
+
+/*
+StackBlur - a fast almost Gaussian Blur
+Theory: http://underdestruction.com/2004/02/25/stackblur-2004
+The code has been borrowed from (https://github.com/flozz/StackBlur)
+and adapted for OpenCV by Zihao Mu.
```

Review comment:
`CV_CheckDepthEQ(_src.depth(), CV_8U, "");`
**File:** modules/imgproc/src/stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc

**Code Changes:**
```diff
@@ -0,0 +1,1261 @@
+// 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.
+
+/*
+StackBlur - a fast almost Gaussian Blur
+Theory: http://underdestruction.com/2004/02/25/stackblur-2004
+The code has been borrowed from (https://github.com/flozz/StackBlur)
+and adapted for OpenCV by Zihao Mu.
```

Review comment:
> std::min(getNumThreads(), getNumberOfCPUs()) `getNumThreads()` is enough
**File:** modules/imgproc/test/test_stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc

**Code Changes:**
```diff
@@ -0,0 +1,313 @@
+// 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.
+
+/*
+StackBlur - a fast almost Gaussian Blur
+Theory: http://underdestruction.com/2004/02/25/stackblur-2004
+The code has been borrowed from (https://github.com/flozz/StackBlur).
+
```

Review comment:
BTW, Can we compare with traditional `blur()` on some image?
**File:** modules/imgproc/test/test_stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc

**Code Changes:**
```diff
@@ -0,0 +1,313 @@
+// 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.
+
+/*
+StackBlur - a fast almost Gaussian Blur
+Theory: http://underdestruction.com/2004/02/25/stackblur-2004
+The code has been borrowed from (https://github.com/flozz/StackBlur).
+
```

Review comment:
It makes sense to make the test parameterized and check only one combination at a time. The same regression and stackedBlur against GaussianBlur. It should be dedicated set of parameterized tests.
**File:** modules/imgproc/test/test_stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc

**Code Changes:**
```diff
@@ -0,0 +1,313 @@
+// 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.
+
+/*
+StackBlur - a fast almost Gaussian Blur
+Theory: http://underdestruction.com/2004/02/25/stackblur-2004
+The code has been borrowed from (https://github.com/flozz/StackBlur).
+
```

Review comment:
dtypeVec is not used in test.
**File:** modules/imgproc/test/test_stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc

**Code Changes:**
```diff
@@ -0,0 +1,313 @@
+// 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.
+
+/*
+StackBlur - a fast almost Gaussian Blur
+Theory: http://underdestruction.com/2004/02/25/stackblur-2004
+The code has been borrowed from (https://github.com/flozz/StackBlur).
+
```

Review comment:
The function supports non-square kernels. I propose to cover the case too. It's easy to do.
**File:** modules/imgproc/test/test_stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc

**Code Changes:**
```diff
@@ -0,0 +1,313 @@
+// 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.
+
+/*
+StackBlur - a fast almost Gaussian Blur
+Theory: http://underdestruction.com/2004/02/25/stackblur-2004
+The code has been borrowed from (https://github.com/flozz/StackBlur).
+
```

Review comment:
Why do you need so large alignment?
**File:** modules/imgproc/test/test_stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc

**Code Changes:**
```diff
@@ -0,0 +1,313 @@
+// 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.
+
+/*
+StackBlur - a fast almost Gaussian Blur
+Theory: http://underdestruction.com/2004/02/25/stackblur-2004
+The code has been borrowed from (https://github.com/flozz/StackBlur).
+
```

Review comment:
It makes sense to allocate dedicated buffers for each array. Performance is not so important here, but dedicated allocation allows to capture out-of-range access with valgrind, ASAN and other tools.
**File:** modules/imgproc/perf/perf_blur.cpp
**Change Type:** modified
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 271

**Code Changes:**
```diff
+    double eps = 1e-3;
+
+    eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : eps;
+
+    Mat src(size, type);
+    Mat dst(size, type);
+
+    declare.in(src, WARMUP_RNG).out(dst);
+
+    TEST_CYCLE() stackBlur(src, dst, Size(3,3));
+
```

Review comment:
The input is not initialized. It will trigger ASAN/Valgrind issues.
**File:** modules/imgproc/perf/perf_blur.cpp
**Change Type:** modified
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 293

**Code Changes:**
```diff
+    int type = get<1>(GetParam());
+    double eps = 1e-3;
+
+    eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : eps;
+
+    Mat src(size, type);
+    Mat dst(size, type);
+
+    declare.in(src, WARMUP_RNG).out(dst);
+
+    TEST_CYCLE() stackBlur(src, dst, Size(101,101));
```

Review comment:
The same here too.
**File:** modules/imgproc/perf/perf_blur.cpp
**Change Type:** modified
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 271

**Code Changes:**
```diff
+    double eps = 1e-3;
+
+    eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : eps;
+
+    Mat src(size, type);
+    Mat dst(size, type);
+
+    declare.in(src, WARMUP_RNG).out(dst);
+
+    TEST_CYCLE() stackBlur(src, dst, Size(3,3));
+
```

Review comment:
Random content for input should be enough. Most probably the same code snippets exist in OpenCV. I propose to add deterministic tests.
**File:** modules/imgproc/perf/perf_blur.cpp
**Change Type:** modified
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 271

**Code Changes:**
```diff
+    double eps = 1e-3;
+
+    eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : eps;
+
+    Mat src(size, type);
+    Mat dst(size, type);
+
+    declare.in(src, WARMUP_RNG).out(dst);
+
+    TEST_CYCLE() stackBlur(src, dst, Size(3,3));
+
```

Review comment:
Just a moment, I need to re-check one idea.
**File:** modules/imgproc/perf/perf_blur.cpp
**Change Type:** modified
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 271

**Code Changes:**
```diff
+    double eps = 1e-3;
+
+    eps = CV_MAT_DEPTH(type) <= CV_32S ? 1 : eps;
+
+    Mat src(size, type);
+    Mat dst(size, type);
+
+    declare.in(src, WARMUP_RNG).out(dst);
+
+    TEST_CYCLE() stackBlur(src, dst, Size(3,3));
+
```

Review comment:
`declare.in(src, WARMUP_RNG)` already does randomization. My fault. Please ignore the comment.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 1633

**Code Changes:**
```diff
+depending on if they are on the right or on the left side of the stack.
+Described here: http://underdestruction.com/2004/02/25/stackblur-2004.
+Stack Blur Algorithm by Mario Klingemann <mario@quasimondo.com>
+@param src input image. The number of channels can be arbitrary, but the depth should be one of
+CV_8U, CV_16U, CV_16S or CV_32F.
+@param dst output image of the same size and type as src.
+@param ksize stack-blurring kernel size. The ksize.width and ksize.height can differ but they both must be
+positive and odd.
+*/
+CV_EXPORTS_W void stackBlur(InputArray src, OutputArray dst, Size ksize);
+
```

Review comment:
> the same size Which is border handling method used?
**File:** modules/imgproc/src/stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 1259

**Code Changes:**
```diff
+        if (ksize.height != 1)
+            parallel_for_(Range(0, widthElem), ParallelStackBlurColumn<float, float>(dst, dst, radiusH), numOfThreads);
+    }
+    else
+        CV_Error_( CV_StsNotImplemented,
+                   ("Unsupported input format in StackBlur, the supported formats are: CV_8U, CV_16U, CV_16S and CV_32F."));
+}
+} //namespace
```

Review comment:
`CV_Error_` use cv::format internally. It is not needed here, so common `CV_Error` should be used instead.
**File:** modules/imgproc/test/test_stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 128

**Code Changes:**
```diff
+                sumIn[ci] += *(srcNew + ci);
+                sum[ci] += sumIn[ci];
+            }
+
+            int sp1 = sp + 1;
+            sp1 &= -(sp1 < stackLenW);
+
+            for(int ci = 0; ci < CN; ci++)
+            {
+                T tmp = stack[sp1*CN + ci];
+                sumOut[ci] += tmp;
```

Review comment:
It is a test code. So we don't need any kind of "optimization" obfuscation here.
**File:** modules/imgproc/src/stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 1149

**Code Changes:**
```diff
+        {
+            stackStart = sp + kernelSize - radius;
+            if (stackStart >= kernelSize) stackStart -= kernelSize;
+
+            int sp1 = sp + 1;
+            sp1 &= -(sp1 < kernelSize);
+
+            if (yp < hm)
+            {
+                yp++;
+                srcPtr += widthElem;
```

Review comment:
Are you sure that compilers optimize this properly?
**File:** modules/imgproc/src/stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 1258

**Code Changes:**
```diff
+            parallel_for_(Range(0, src.rows), ParallelStackBlurRow<float, float>(src, dst, radiusW), numOfThreads);
+        if (ksize.height != 1)
+            parallel_for_(Range(0, widthElem), ParallelStackBlurColumn<float, float>(dst, dst, radiusH), numOfThreads);
+    }
+    else
+        CV_Error_( CV_StsNotImplemented,
+                   ("Unsupported input format in StackBlur, the supported formats are: CV_8U, CV_16U, CV_16S and CV_32F."));
+}
+} //namespace
```

Review comment:
> `CV_StsNotImplemented` We should not use enums from C API anymore.
**File:** modules/imgproc/src/stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 1179

**Code Changes:**
```diff
+                sumIn[k] -= stack[sp1 * widthLen + k];
+            }
+
+            dstPtr += widthElem;
+            ++sp;
+            if (sp >= kernelSize) sp = 0;
+        }
+    }
+
+private:
+    const Mat &src;
```

Review comment:
`if` and its `body` should be placed on separate lines. This is necessary for correct "code coverage" reports.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 1624

**Code Changes:**
```diff
@@ -1620,6 +1620,22 @@ CV_EXPORTS_W void blur( InputArray src, OutputArray dst,
                         Size ksize, Point anchor = Point(-1,-1),
                         int borderType = BORDER_DEFAULT );
 
+/** @brief Blurs an image using the StackBlur.
+The function applies and StackBlur to an image.
+StackBlur can generate similar results as Gaussian blur, and the time does not increase as the kernel size increases.
+It creates a kind of moving stack of colors whilst scanning through the image. Thereby it just has to add one new block of color to the right side
+of the stack and remove the leftmost color. The remaining colors on the topmost layer of the stack are either added on or reduced by one,
+depending on if they are on the right or on the left side of the stack.
+Described here: http://underdestruction.com/2004/02/25/stackblur-2004.
```

Review comment:
Will be fixed at new patch.
**File:** modules/imgproc/src/stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 1149

**Code Changes:**
```diff
+        {
+            stackStart = sp + kernelSize - radius;
+            if (stackStart >= kernelSize) stackStart -= kernelSize;
+
+            int sp1 = sp + 1;
+            sp1 &= -(sp1 < kernelSize);
+
+            if (yp < hm)
+            {
+                yp++;
+                srcPtr += widthElem;
```

Review comment:
The no optimized code is following: ``` int sp1 = sp + 1; if (sp1 >= kernelSize) sp1 = 0; ```
**File:** modules/imgproc/src/stackblur.cpp
**Change Type:** added
**Context:** PR #20379: Add StackBlur for imgproc
**Review Line:** 1149

**Code Changes:**
```diff
+        {
+            stackStart = sp + kernelSize - radius;
+            if (stackStart >= kernelSize) stackStart -= kernelSize;
+
+            int sp1 = sp + 1;
+            sp1 &= -(sp1 < kernelSize);
+
+            if (yp < hm)
+            {
+                yp++;
+                srcPtr += widthElem;
```

Review comment:
Yes, and we should not obfuscate code for compilers. More operations may block optimizations (because we can't pass assumptions into optimization transformations). See here: https://godbolt.org/z/G3jdx5v8a
**File:** cmake/android/android_gradle_projects.cmake
**Change Type:** modified
**Context:** PR #22684: android: update build scripts - Force using of the same CMake & NDK version during the build. ``` force_builders_only=Android armeabi-v7a,A...
**Review Line:** 89

**Code Changes:**
```diff
 
+# force reusing of the same CMake version
+if(NOT OPENCV_SKIP_ANDROID_FORCE_CMAKE)
+  if(NOT DEFINED _CMAKE_INSTALL_DIR)
+    get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
+    get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
+  endif()
+  ocv_update_file("${ANDROID_BUILD_BASE_DIR}/local.properties" "cmake.dir=${_CMAKE_INSTALL_DIR}")
+endif()
+
 file(WRITE "${ANDROID_BUILD_BASE_DIR}/settings.gradle" "
```

Review comment:
It overrides variable value in the previous line.
**File:** samples/android/build.gradle.in
**Change Type:** modified
**Context:** PR #22684: android: update build scripts - Force using of the same CMake & NDK version during the build. ``` force_builders_only=Android armeabi-v7a,A...
**Review Line:** 97

**Code Changes:**
```diff
         }
 
+        // Android Gradle Plugin (AGP) 3.5+ is required
+        // https://github.com/android/ndk-samples/wiki/Configure-NDK-Path
+        def isNdkVersionSupported = project.android.metaClass.getProperties().find { it.name == 'ndkVersion' } != null
+        if ((false || opencv_strict_build_configuration) && isNdkVersionSupported) {
+            gradle.println("Override ndkVersion for the project ${project.name}")
+            project.android {
+                ndkVersion '@ANDROID_NDK_REVISION@'
+            }
+        }
```

Review comment:
why do you need false here?
**File:** cmake/android/android_gradle_projects.cmake
**Change Type:** modified
**Context:** PR #22684: android: update build scripts - Force using of the same CMake & NDK version during the build. ``` force_builders_only=Android armeabi-v7a,A...
**Review Line:** 89

**Code Changes:**
```diff
 
+# force reusing of the same CMake version
+if(NOT OPENCV_SKIP_ANDROID_FORCE_CMAKE)
+  if(NOT DEFINED _CMAKE_INSTALL_DIR)
+    get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
+    get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
+  endif()
+  ocv_update_file("${ANDROID_BUILD_BASE_DIR}/local.properties" "cmake.dir=${_CMAKE_INSTALL_DIR}")
+endif()
+
 file(WRITE "${ANDROID_BUILD_BASE_DIR}/settings.gradle" "
```

Review comment:
Yes. It is intended as we need `../../` location.
**File:** samples/android/build.gradle.in
**Change Type:** modified
**Context:** PR #22684: android: update build scripts - Force using of the same CMake & NDK version during the build. ``` force_builders_only=Android armeabi-v7a,A...
**Review Line:** 97

**Code Changes:**
```diff
         }
 
+        // Android Gradle Plugin (AGP) 3.5+ is required
+        // https://github.com/android/ndk-samples/wiki/Configure-NDK-Path
+        def isNdkVersionSupported = project.android.metaClass.getProperties().find { it.name == 'ndkVersion' } != null
+        if ((false || opencv_strict_build_configuration) && isNdkVersionSupported) {
+            gradle.println("Override ndkVersion for the project ${project.name}")
+            project.android {
+                ndkVersion '@ANDROID_NDK_REVISION@'
+            }
+        }
```

Review comment:
This option may be useful on the user side (this is a part of OpenCV Android SDK), but it is not enabled by default (to keep Android "defaults" - which depends on versions of user's Android environment). To manually enable this option just switch `false->true`.
**File:** modules/videoio/src/cap_ffmpeg_impl.hpp
**Change Type:** modified
**Context:** PR #22689: libav for jetson tk1 does not provide libavutil/display.h

**Code Changes:**
```diff
@@ -82,7 +82,11 @@ extern "C" {
 
 #include <libavutil/mathematics.h>
 #include <libavutil/opt.h>
+// https://github.com/FFmpeg/FFmpeg/blame/d79c240196f43b93bd204363f1facc270029f113/doc/APIchanges#L1689-L1695
+#if LIBAVUTIL_BUILD >= (LIBAVUTIL_VERSION_MICRO >= 100 \
+    ? CALC_FFMPEG_VERSION(52, 85, 100) : CALC_FFMPEG_VERSION(53, 15, 0))
 #include <libavutil/display.h>
+#endif
 
```

Review comment:
Updated versions in the guard macro.
**File:** modules/dnn/src/layers/fast_convolution/fast_convolution.cpp
**Change Type:** modified
**Context:** PR #22667: DNN: bug fixed in Winograd
**Review Line:** 73

**Code Changes:**
```diff
@@ -61,7 +70,7 @@ Ptr<FastConv2d> initFastConv2d(
         int ksize = Hk*Wk;
 
         // this code aims to let memory fit with vector size.
-        int padded_ksize = ((ksize + FAST_VEC_NLANES-1) / FAST_VEC_NLANES) * FAST_VEC_NLANES;
+        int padded_ksize = ((ksize + VEC_NLANES-1) / VEC_NLANES) * VEC_NLANES;
         int nweights = C*padded_ksize;
         conv->weightsBuf.reserve(nweights + VEC_ALIGN);
         conv->weightsBufPtr = alignPtr(conv->weightsBuf.data(), VEC_ALIGN);
@@ -265,7 +274,8 @@ void runFastConv2d(InputArray _input, OutputArray _output, const Ptr<FastConv2d>
     else if (conv->conv_type == _FX_CONV_TYPE_WINOGRAD3X3 && inputShape[2] >= 12 && inputShape[3] >= 12) // winograd
```

Review comment:
> `((ksize + VEC_NLANES-1) / VEC_NLANES) * VEC_NLANES` FYI, `alignSize(ksize, VEC_NLANES)` for 2**n or `roundUp(ksize, VEC_NLANES)` for others
**File:** modules/3d/src/rgbd/odometry.cpp
**Change Type:** modified
**Context:** PR #22598: OdometryFrame made RAII and UMat-based

**Code Changes:**
```diff
@@ -12,18 +12,16 @@ namespace cv
 
 class Odometry::Impl
 {
-private:
-
 public:
     Impl() {};
     virtual ~Impl() {};
-    virtual OdometryFrame createOdometryFrame() const = 0;
```

Review comment:
`CV_UNUSED`
**File:** modules/3d/include/opencv2/3d/odometry_frame.hpp
**Change Type:** modified
**Context:** PR #22598: OdometryFrame made RAII and UMat-based
**Review Line:** 33

**Code Changes:**
```diff
 {
 public:
-    OdometryFrame();
-    OdometryFrame(OdometryFrameStoreType matType);
+    //TODO: add to docs: check image channels, if 3 or 4 then do cvtColor(BGR(A)2GRAY)
+    OdometryFrame(InputArray image = noArray(), InputArray depth = noArray(), InputArray mask = noArray(), InputArray normals = noArray());
     ~OdometryFrame() {};
-    void setImage(InputArray  image);
+
     void getImage(OutputArray image) const;
     void getGrayImage(OutputArray image) const;
```

Review comment:
OdometryFrameStoreType is not relevant any more and could be removed, right?
**File:** modules/3d/src/rgbd/odometry_frame_impl.cpp
**Change Type:** modified
**Context:** PR #22598: OdometryFrame made RAII and UMat-based

**Code Changes:**
```diff
@@ -11,257 +11,90 @@
 namespace cv
 {
 
-class OdometryFrame::Impl
+OdometryFrame::OdometryFrame(InputArray image, InputArray depth, InputArray mask, InputArray normals)
 {
-public:
-    Impl() {}
-    virtual ~Impl() {}
```

Review comment:
`OdometryFramePyramidType` is not necessary here at all.
**File:** modules/3d/src/rgbd/odometry_functions.cpp
**Change Type:** modified
**Context:** PR #22598: OdometryFrame made RAII and UMat-based

**Code Changes:**
```diff
@@ -14,639 +14,477 @@
 namespace cv
 {
 
-static const int normalWinSize = 5;
-static const RgbdNormals::RgbdNormalsMethod normalMethod = RgbdNormals::RGBD_NORMALS_METHOD_FALS;
-
-enum
+static void randomSubsetOfMask(InputOutputArray _mask, float part)
 {
```

Review comment:
looks like `TMat ` is redundant here. `minMaxLoc` handles both data types. You just need to add UMat branch to `findMask` at least with download to cpu.
**File:** modules/3d/src/rgbd/odometry_functions.cpp
**Change Type:** modified
**Context:** PR #22598: OdometryFrame made RAII and UMat-based

**Code Changes:**
```diff
@@ -14,639 +14,477 @@
 namespace cv
 {
 
-static const int normalWinSize = 5;
-static const RgbdNormals::RgbdNormalsMethod normalMethod = RgbdNormals::RGBD_NORMALS_METHOD_FALS;
-
-enum
+static void randomSubsetOfMask(InputOutputArray _mask, float part)
 {
```

Review comment:
Why not just `const size_t`? Need some comment on magic value.
**File:** modules/3d/src/rgbd/odometry_functions.cpp
**Change Type:** modified
**Context:** PR #22598: OdometryFrame made RAII and UMat-based
**Review Line:** 122

**Code Changes:**
```diff
-    frame.getMask(mask);
-    if (mask.empty() && frame.getPyramidLevels(OdometryFramePyramidType::PYR_MASK) > 0)
+static void buildPyramidCameraMatrix(const Matx33f& cameraMatrix, int levels, std::vector<Matx33f>& pyramidCameraMatrix)
+{
+    pyramidCameraMatrix.resize(levels);
+
+    for (int i = 0; i < levels; i++)
     {
-        TMat pyr0;
-        frame.getPyramidAt(pyr0, OdometryFramePyramidType::PYR_MASK, 0);
-        frame.setMask(pyr0);
```

Review comment:
The function `setPyramids` is not used any more and could be removed as soon as `getPyramids`