nareshmlx/opencv-pr huggingface dataset:
**File:** modules/dnn/src/layers/cpu_kernels/fast_gemm_kernels.default.hpp
**Change Type:** modified
**Context:** PR #24694: dnn: refactor ONNX MatMul with fastGemm
**Review Line:** 403

**Code Changes:**
```diff
+    int m_tiles = (M + MC - 1) / MC;
+    int n_tiles = (N + NC - 1) / NC;
+    int total_tiles = m_tiles * n_tiles;
+
+    auto fn = [&](const Range &r) {
+        char* packed_a = (char*)(use_stackbuff ? alloca(buff_size) : malloc(buff_size));
+        const char *packed_b = packed_B;
+        int start = r.start;
+        int end = r.end;
+
+        for (int tile_idx = start; tile_idx < end; tile_idx++) {
```

Review comment:
The same idea for AutoBuffer.
**File:** modules/dnn/src/cuda4dnn/csl/cublas.hpp
**Change Type:** modified
**Context:** PR #24694: dnn: refactor ONNX MatMul with fastGemm
**Review Line:** 452

**Code Changes:**
```diff
+
+        CUDA4DNN_CHECK_CUBLAS(cublasHgemmBatched(handle.get(), opa, opb, iM, iN, iK, &alpha, dev_A_slices, ilda, dev_B_slices, ildb, &beta, dev_C_slices, ildc, batch_count));
+
+        cudaFree(dev_A_slices);
+        cudaFree(dev_B_slices);
+        cudaFree(dev_C_slices);
+    }
+
+    template <> inline
+    void gemmBatched<float>(const Handle &handle,
+                           bool trans_a, bool trans_b,
```

Review comment:
Optional optimization with streams is possible. E.g. create stream, use cudaMemcopyAsync and [cublasSetStream()](https://docs.nvidia.com/cuda/cublas/index.html#cublassetstream). It reduces amount of CPU-GPU syncs.
**File:** modules/dnn/src/cuda4dnn/csl/cublas.hpp
**Change Type:** modified
**Context:** PR #24694: dnn: refactor ONNX MatMul with fastGemm
**Review Line:** 503

**Code Changes:**
```diff
+        // cuBLAS is column-major
+        CUDA4DNN_CHECK_CUBLAS(cublasSgemmBatched(handle.get(), opa, opb, iM, iN, iK, &alpha, dev_A_slices, ilda, dev_B_slices, ildb, &beta, dev_C_slices, ildc, batch_count));
+
+        cudaFree(dev_A_slices);
+        cudaFree(dev_B_slices);
+        cudaFree(dev_C_slices);
+    }
+
 }}}}} /* namespace cv::dnn::cuda4dnn::csl::cublas */
 
 #endif /* OPENCV_DNN_SRC_CUDA4DNN_CSL_CUBLAS_HPP */
```

Review comment:
The same optional recommendation here.
**File:** modules/dnn/src/cuda4dnn/csl/cublas.hpp
**Change Type:** modified
**Context:** PR #24694: dnn: refactor ONNX MatMul with fastGemm
**Review Line:** 452

**Code Changes:**
```diff
+
+        CUDA4DNN_CHECK_CUBLAS(cublasHgemmBatched(handle.get(), opa, opb, iM, iN, iK, &alpha, dev_A_slices, ilda, dev_B_slices, ildb, &beta, dev_C_slices, ildc, batch_count));
+
+        cudaFree(dev_A_slices);
+        cudaFree(dev_B_slices);
+        cudaFree(dev_C_slices);
+    }
+
+    template <> inline
+    void gemmBatched<float>(const Handle &handle,
+                           bool trans_a, bool trans_b,
```

Review comment:
Do we have examples demonstrating how to use these two APIs?
**File:** modules/dnn/src/cuda4dnn/csl/cublas.hpp
**Change Type:** modified
**Context:** PR #24694: dnn: refactor ONNX MatMul with fastGemm
**Review Line:** 452

**Code Changes:**
```diff
+
+        CUDA4DNN_CHECK_CUBLAS(cublasHgemmBatched(handle.get(), opa, opb, iM, iN, iK, &alpha, dev_A_slices, ilda, dev_B_slices, ildb, &beta, dev_C_slices, ildc, batch_count));
+
+        cudaFree(dev_A_slices);
+        cudaFree(dev_B_slices);
+        cudaFree(dev_C_slices);
+    }
+
+    template <> inline
+    void gemmBatched<float>(const Handle &handle,
+                           bool trans_a, bool trans_b,
```

Review comment:
By the way, `Linux-RISC-V-Clang` seems to have trouble starting jobs.
**File:** modules/dnn/src/layers/cpu_kernels/fast_gemm_kernels.default.hpp
**Change Type:** modified
**Context:** PR #24694: dnn: refactor ONNX MatMul with fastGemm
**Review Line:** 329

**Code Changes:**
```diff
+    int m_tiles = (M + MC - 1) / MC;
+    int n_tiles = (N + NC - 1) / NC;
+    int total_tiles = m_tiles * n_tiles;
+
+    auto fn = [&](const Range &r) {
+        char* packed_a = (char*)(use_stackbuff ? alloca(buff_size) : malloc(buff_size));
+        char* packed_b = packed_a + KC * MC * esz;
+        int start = r.start;
+        int end = r.end;
+
+        for (int tile_idx = start; tile_idx < end; tile_idx++) {
```

Review comment:
> If a temporary buffer is usually small (a few K's of memory) `AutoBuffer` says something like this. A typical `buff_size` would be ``` FAST_GEMM_F32_PACKED_STRIDE_K * (FAST_GEMM_F32_MC + FAST_GEMM_F32_NC) * 4 / 1024 = 64 * (144 + 72) * 4 / 1024 = 54 KB ``` Is `54 KB` still considered to be a few KBs?
**File:** modules/dnn/src/dnn_utils.cpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -17,9 +17,9 @@ Image2BlobParams::Image2BlobParams():scalefactor(Scalar::all(1.0)), size(Size())
 {}
 
 Image2BlobParams::Image2BlobParams(const Scalar& scalefactor_, const Size& size_, const Scalar& mean_, bool swapRB_,
-                         int ddepth_, DataLayout datalayout_, ImagePaddingMode mode_, Scalar borderValue_):
-        scalefactor(scalefactor_), size(size_), mean(mean_), swapRB(swapRB_), ddepth(ddepth_),
-        datalayout(datalayout_), paddingmode(mode_), borderValue(borderValue_)
+    int ddepth_, DataLayout datalayout_, ImagePaddingMode mode_, Scalar borderValue_):
+    scalefactor(scalefactor_), size(size_), mean(mean_), swapRB(swapRB_), ddepth(ddepth_),
+    datalayout(datalayout_), paddingmode(mode_), borderValue(borderValue_)
```

Review comment:
Remove extra spaces.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
Method signature is different with it's name. I read this as "blob" or "blob's rectangle" as input and "image" as output (because of `ToImage`). But it returns not an image but another Rect.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
So blob or image?
**File:** modules/dnn/src/dnn_utils.cpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -17,9 +17,9 @@ Image2BlobParams::Image2BlobParams():scalefactor(Scalar::all(1.0)), size(Size())
 {}
 
 Image2BlobParams::Image2BlobParams(const Scalar& scalefactor_, const Size& size_, const Scalar& mean_, bool swapRB_,
-                         int ddepth_, DataLayout datalayout_, ImagePaddingMode mode_, Scalar borderValue_):
-        scalefactor(scalefactor_), size(size_), mean(mean_), swapRB(swapRB_), ddepth(ddepth_),
-        datalayout(datalayout_), paddingmode(mode_), borderValue(borderValue_)
+    int ddepth_, DataLayout datalayout_, ImagePaddingMode mode_, Scalar borderValue_):
+    scalefactor(scalefactor_), size(size_), mean(mean_), swapRB(swapRB_), ddepth(ddepth_),
+    datalayout(datalayout_), paddingmode(mode_), borderValue(borderValue_)
```

Review comment:
Seems like image is not needed at all but only it's Size
**File:** modules/dnn/src/dnn_utils.cpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -17,9 +17,9 @@ Image2BlobParams::Image2BlobParams():scalefactor(Scalar::all(1.0)), size(Size())
 {}
 
 Image2BlobParams::Image2BlobParams(const Scalar& scalefactor_, const Size& size_, const Scalar& mean_, bool swapRB_,
-                         int ddepth_, DataLayout datalayout_, ImagePaddingMode mode_, Scalar borderValue_):
-        scalefactor(scalefactor_), size(size_), mean(mean_), swapRB(swapRB_), ddepth(ddepth_),
-        datalayout(datalayout_), paddingmode(mode_), borderValue(borderValue_)
+    int ddepth_, DataLayout datalayout_, ImagePaddingMode mode_, Scalar borderValue_):
+    scalefactor(scalefactor_), size(size_), mean(mean_), swapRB(swapRB_), ddepth(ddepth_),
+    datalayout(datalayout_), paddingmode(mode_), borderValue(borderValue_)
```

Review comment:
Instead of accessing to `Mat` you can use [sizend](https://docs.opencv.org/5.x/d4/d32/classcv_1_1__InputArray.html#a7cb4cadf3108dc232e05e3ae5550e912) for a direct access to the shape
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
My preference is something like `locateImage` or `locateImageFromBlob` (or `locateBlobFromImage` depends on what is a final Rect). Similar to [locateROI](https://docs.opencv.org/5.x/d3/d63/classcv_1_1Mat.html#a40b5b3371a9c2a4b2b8ce0c8068d7c96)
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
when blob is build from image for object model inference result (rect) are in blob coordinates. for example here https://github.com/opencv/opencv_zoo/blob/main/models/object_detection_yolox/demo.py#L56 Method name could be blobRectToImageRect or locateRectFromBlob
**File:** modules/dnn/src/dnn_utils.cpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -17,9 +17,9 @@ Image2BlobParams::Image2BlobParams():scalefactor(Scalar::all(1.0)), size(Size())
 {}
 
 Image2BlobParams::Image2BlobParams(const Scalar& scalefactor_, const Size& size_, const Scalar& mean_, bool swapRB_,
-                         int ddepth_, DataLayout datalayout_, ImagePaddingMode mode_, Scalar borderValue_):
-        scalefactor(scalefactor_), size(size_), mean(mean_), swapRB(swapRB_), ddepth(ddepth_),
-        datalayout(datalayout_), paddingmode(mode_), borderValue(borderValue_)
+    int ddepth_, DataLayout datalayout_, ImagePaddingMode mode_, Scalar borderValue_):
+    scalefactor(scalefactor_), size(size_), mean(mean_), swapRB(swapRB_), ddepth(ddepth_),
+    datalayout(datalayout_), paddingmode(mode_), borderValue(borderValue_)
```

Review comment:
Agree my idea was : user gives same parameter than in blobFromImage called but it can be changed
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
Is a double precision a good choice for image coordinates? I understand that resize adds a scale factor but in terms of the final application for the result (drawing bounding box, crop sub-image) conversion to integers is an extra step for user.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
It makes sense. May be it would help users too if Image2BlobParams using constant as PARAMS_YOLOX, PARAMS_SAM, PARAMS.. for opencv model example. It would be nice to add interpolation attrinute in Image2BlobParams (after [PR](https://github.com/opencv/opencv/pull/24569)
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
There was an attempt with samples by https://github.com/opencv/opencv/blob/4.x/samples/dnn/models.yml
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
Just to be sure everything is OK. Can you please add a simple binding test to https://github.com/opencv/opencv/blob/4.x/modules/dnn/misc/python/test/test_dnn.py ? Without accuracy check, just call the method and check output dtype (integer output for the integer input, double for doubles)
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
`const std::vector<Rect>& rBlob`?
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
As here `const Size&` is used, let's have const ref where it's possible (for `Rect` as well).
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
rebase? How can I do It?
**File:** modules/dnn/src/dnn_utils.cpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -17,9 +17,9 @@ Image2BlobParams::Image2BlobParams():scalefactor(Scalar::all(1.0)), size(Size())
 {}
 
 Image2BlobParams::Image2BlobParams(const Scalar& scalefactor_, const Size& size_, const Scalar& mean_, bool swapRB_,
-                         int ddepth_, DataLayout datalayout_, ImagePaddingMode mode_, Scalar borderValue_):
-        scalefactor(scalefactor_), size(size_), mean(mean_), swapRB(swapRB_), ddepth(ddepth_),
-        datalayout(datalayout_), paddingmode(mode_), borderValue(borderValue_)
+    int ddepth_, DataLayout datalayout_, ImagePaddingMode mode_, Scalar borderValue_):
+    scalefactor(scalefactor_), size(size_), mean(mean_), swapRB(swapRB_), ddepth(ddepth_),
+    datalayout(datalayout_), paddingmode(mode_), borderValue(borderValue_)
```

Review comment:
Should be const reference here and everywhere.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
If the problem in the `crop`, shall we add a new filed `bool crop` to `Image2BlobParams` instead?
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
crop is paddingmode in Image2BlobParams https://github.com/opencv/opencv/blob/4.x/modules/dnn/src/dnn_utils.cpp#L108-L109
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
> this is still actual. Do we want these two methods to be outside of the `Image2BlobParams`? Actually you can get a blob using [blobFromImage](https://docs.opencv.org/4.x/d6/d0f/group__dnn.html#ga98113a886b1d1fe0b38a8eef39ffaaa0) or [blobFromImageWithParams](https://docs.opencv.org/4.x/d6/d0f/group__dnn.html#gadc12e5f4a801fd3c1d802f4c8c5d311c) Then I use same idea to get rect without param or with param
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #24539: Add blobrecttoimage

**Code Changes:**
```diff
@@ -1222,6 +1222,20 @@ CV__DNN_INLINE_NS_BEGIN
         CV_PROP_RW DataLayout datalayout; //!< Order of output dimensions. Choose DNN_LAYOUT_NCHW or DNN_LAYOUT_NHWC.
         CV_PROP_RW ImagePaddingMode paddingmode;   //!< Image padding mode. @see ImagePaddingMode.
         CV_PROP_RW Scalar borderValue;   //!< Value used in padding mode for padding.
+
+        /** @brief Get rectangle coordinates in original image system from rectangle in blob coordinates.
+         *  @param rBlob rect in blob coordinates.
+         *  @param size original input image size.
+         *  @returns rectangle in original image coordinates.
+         */
```

Review comment:
I see. If there is no objections, I'd like recommend to keep only ones at params