nareshmlx/opencv-pr huggingface dataset:
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -3647,14 +3647,43 @@ CV_EXPORTS_W void HuMoments( const Moments& m, OutputArray hu );
 
 //! type of the template matching operation
 enum TemplateMatchModes {
-    TM_SQDIFF        = 0, //!< \f[R(x,y)= \sum _{x',y'} (T(x',y')-I(x+x',y+y'))^2\f]
-    TM_SQDIFF_NORMED = 1, //!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y')-I(x+x',y+y'))^2}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
-    TM_CCORR         = 2, //!< \f[R(x,y)= \sum _{x',y'} (T(x',y')  \cdot I(x+x',y+y'))\f]
-    TM_CCORR_NORMED  = 3, //!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
-    TM_CCOEFF        = 4, //!< \f[R(x,y)= \sum _{x',y'} (T'(x',y')  \cdot I'(x+x',y+y'))\f]
-                          //!< where
```

Review comment:
> the mask values are divided by 255 This is very strange approach and it is not used in OpenCV. Lets use something like this in case of 8U mask (if you really want to support floating-point mask values as "weights"): ``` // single channel mask Mat mask01(mask.size(), CV_32FC1, Scalar::all(0)); mask01.setTo(Scalar::all(1), mask != 0); // or the same but can be faster Mat mask01_tmp; threshold(mask, mask01_tmp, 0/*threshold*/, 1.0/*maxVal*/, THRESH_BINARY); Mat mask01; mask01_tmp.convertTo(mask01, CV_32F); ```
**File:** modules/imgproc/src/templmatch.cpp
**Change Type:** modified
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...
**Review Line:** 853

**Code Changes:**
```diff
+        // CCorr(I, M)
+        crossCorr(img, mask, img_mask_corr, Point(0, 0), 0, 0);
+
+        // CCorr(I', T') = CCorr(I, T'*M) - sum(T'*M)/sum(M)*CCorr(I, M)
+        // It does not matter what to use Mat/MatExpr, it should be evaluated to perform assign subtraction
+        Mat temp_res = img_mask_corr.mul(sum(templx_mask).div(mask_sum));
+        if (img.channels() == 1)
         {
-            result = Scalar::all(1);
-            return;
+            result -= temp_res;
```

Review comment:
I believe there is some bug in `MatExpr`, need to prepare simple reproducer for tests with similar code.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -3647,14 +3647,43 @@ CV_EXPORTS_W void HuMoments( const Moments& m, OutputArray hu );
 
 //! type of the template matching operation
 enum TemplateMatchModes {
-    TM_SQDIFF        = 0, //!< \f[R(x,y)= \sum _{x',y'} (T(x',y')-I(x+x',y+y'))^2\f]
-    TM_SQDIFF_NORMED = 1, //!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y')-I(x+x',y+y'))^2}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
-    TM_CCORR         = 2, //!< \f[R(x,y)= \sum _{x',y'} (T(x',y')  \cdot I(x+x',y+y'))\f]
-    TM_CCORR_NORMED  = 3, //!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
-    TM_CCOEFF        = 4, //!< \f[R(x,y)= \sum _{x',y'} (T'(x',y')  \cdot I'(x+x',y+y'))\f]
-                          //!< where
```

Review comment:
For me it's very handy to just pass on the alpha channel of an image (which may be 8U) as mask, and therefore it makes sense to support the same type as the template, and also to divide by 255 for 8U (which makes no difference for the normalized modes). Interpreting 8U as binary mask and others not does not seem like a good idea to me either. Also, looking at the implementation of `matchTemplate()` in its current form, I saw that all matrices (img, templ and mask) were divided by 255 in case of 8U. Should we keep that approach? Edit: No, that does not really make sense as it differs from `matchTemplate()` without mask. I also think a weight-mask instead of a simple binary mask adds much more flexibility (also some of this PR would not be neccessary as the implementation would be simpler). We could of course not call it "mask" but "weights" or "weight_mask" or something like that. Any suggestions?
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -3647,14 +3647,43 @@ CV_EXPORTS_W void HuMoments( const Moments& m, OutputArray hu );
 
 //! type of the template matching operation
 enum TemplateMatchModes {
-    TM_SQDIFF        = 0, //!< \f[R(x,y)= \sum _{x',y'} (T(x',y')-I(x+x',y+y'))^2\f]
-    TM_SQDIFF_NORMED = 1, //!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y')-I(x+x',y+y'))^2}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
-    TM_CCORR         = 2, //!< \f[R(x,y)= \sum _{x',y'} (T(x',y')  \cdot I(x+x',y+y'))\f]
-    TM_CCORR_NORMED  = 3, //!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
-    TM_CCOEFF        = 4, //!< \f[R(x,y)= \sum _{x',y'} (T'(x',y')  \cdot I'(x+x',y+y'))\f]
-                          //!< where
```

Review comment:
I would suggest to split these behaviors by storage type: - regular binary mask: CV_8U (values are 0 or 255). We should support that due OpenCV comparison functions. - "weights" mask: CV_32F (assumed range 0..1) P.S. Binary mask is converted to "weights" internally.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...

**Code Changes:**
```diff
@@ -3647,14 +3647,43 @@ CV_EXPORTS_W void HuMoments( const Moments& m, OutputArray hu );
 
 //! type of the template matching operation
 enum TemplateMatchModes {
-    TM_SQDIFF        = 0, //!< \f[R(x,y)= \sum _{x',y'} (T(x',y')-I(x+x',y+y'))^2\f]
-    TM_SQDIFF_NORMED = 1, //!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y')-I(x+x',y+y'))^2}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
-    TM_CCORR         = 2, //!< \f[R(x,y)= \sum _{x',y'} (T(x',y')  \cdot I(x+x',y+y'))\f]
-    TM_CCORR_NORMED  = 3, //!< \f[R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}\f]
-    TM_CCOEFF        = 4, //!< \f[R(x,y)= \sum _{x',y'} (T'(x',y')  \cdot I'(x+x',y+y'))\f]
-                          //!< where
```

Review comment:
Ok, I'll adapt the code, test and doc. I'm not really happy with it (behavior dependent on type) but I get your argument with compatibility with other 8U masks.
**File:** modules/imgproc/src/templmatch.cpp
**Change Type:** modified
**Context:** PR #15214: Imgproc: templmatch: Add support for mask for all methods - resolves #6919 resolves #14076 ### Current situation There are multiple request...
**Review Line:** 853

**Code Changes:**
```diff
+        // CCorr(I, M)
+        crossCorr(img, mask, img_mask_corr, Point(0, 0), 0, 0);
+
+        // CCorr(I', T') = CCorr(I, T'*M) - sum(T'*M)/sum(M)*CCorr(I, M)
+        // It does not matter what to use Mat/MatExpr, it should be evaluated to perform assign subtraction
+        Mat temp_res = img_mask_corr.mul(sum(templx_mask).div(mask_sum));
+        if (img.channels() == 1)
         {
-            result = Scalar::all(1);
-            return;
+            result -= temp_res;
```

Review comment:
Should probably be a separate issue. I'm did obviously not resolve this, so you may resolve this conversation yourself :)
**File:** modules/imgproc/src/connectedcomponents.cpp
**Change Type:** modified
**Context:** PR #18314: Fix signed integer overflow in connected components

**Code Changes:**
```diff
@@ -145,14 +145,21 @@ namespace cv{
         void finish(){
             for (int l = 0; l < statsv.rows; ++l){
                 int *row =& statsv.at<int>(l, 0);
-                row[CC_STAT_WIDTH] = row[CC_STAT_WIDTH] - row[CC_STAT_LEFT] + 1;
-                row[CC_STAT_HEIGHT] = row[CC_STAT_HEIGHT] - row[CC_STAT_TOP] + 1;
-
-                Point2ui64& integral = integrals[l];
-                double *centroid = &centroidsv.at<double>(l, 0);
                 double area = ((unsigned*)row)[CC_STAT_AREA];
```

Review comment:
> nanf("") Please use `quite_NaN()` instead.
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #18316: Fix loading of ONNX models with Resize operation with Opset 11 for newer versions of Pytorch

**Code Changes:**
```diff
@@ -1557,7 +1557,9 @@ void ONNXImporter::populateNet(Net dstNet)
             Mat shapes = getBlob(node_proto, constBlobs, node_proto.input_size() - 1);
             CV_CheckEQ(shapes.size[0], 4, "");
             CV_CheckEQ(shapes.size[1], 1, "");
-            CV_CheckTypeEQ(shapes.depth(), CV_32S, "");
+            CV_CheckDepth(shapes.depth(), shapes.depth() == CV_32S || shapes.depth() == CV_32F, "");
+            if (shapes.depth() == CV_32F)
+                shapes.convertTo(shapes, CV_32S);
             int height = shapes.at<int>(2);
             int width  = shapes.at<int>(3);
```

Review comment:
```.diff -CV_Check +CV_CheckDepth ``` for better diagnostic messages.
**File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.
**Review Line:** 7

**Code Changes:**
```diff
     Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
 
-    Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
+    CRNN Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
     How to convert from pb to onnx:
     Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
 
+    More converted onnx text recognition models can be downloaded directly here:
+    Download link: https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing
+    And these models taken from here:https://github.com/clovaai/deep-text-recognition-benchmark
+
```

Review comment:
Don't remove existing usage - make sample work with both models.
**File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.
**Review Line:** 7

**Code Changes:**
```diff
     Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
 
-    Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
+    CRNN Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
     How to convert from pb to onnx:
     Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
 
+    More converted onnx text recognition models can be downloaded directly here:
+    Download link: https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing
+    And these models taken from here:https://github.com/clovaai/deep-text-recognition-benchmark
+
```

Review comment:
The two text recognition preprocessing is different. Regarding the CRNN in https://github.com/meijieru/crnn.pytorch, I have provided a pre-trained model in my Google Drive. They have the same structure, but different pre-processing. In this case, how should I modify it?
**File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.
**Review Line:** 7

**Code Changes:**
```diff
     Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
 
-    Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
+    CRNN Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
     How to convert from pb to onnx:
     Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
 
+    More converted onnx text recognition models can be downloaded directly here:
+    Download link: https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing
+    And these models taken from here:https://github.com/clovaai/deep-text-recognition-benchmark
+
```

Review comment:
So, what's the difference between models? In terms of accuracy/efficiency?
**File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.
**Review Line:** 7

**Code Changes:**
```diff
     Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
 
-    Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
+    CRNN Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
     How to convert from pb to onnx:
     Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
 
+    More converted onnx text recognition models can be downloaded directly here:
+    Download link: https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing
+    And these models taken from here:https://github.com/clovaai/deep-text-recognition-benchmark
+
```

Review comment:
Because the model structure is the same, the efficiency is the same. About the accuracy, since more data for training, my pre-trained model can achieve 89.2% in IC13 dataset, while the original one is 86.7%.
**File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.
**Review Line:** 7

**Code Changes:**
```diff
     Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
 
-    Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
+    CRNN Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
     How to convert from pb to onnx:
     Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
 
+    More converted onnx text recognition models can be downloaded directly here:
+    Download link: https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing
+    And these models taken from here:https://github.com/clovaai/deep-text-recognition-benchmark
+
```

Review comment:
so they seems equal that means sample should support both of them. Try to manage it automatically or by flags.
**File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.
**Review Line:** 7

**Code Changes:**
```diff
     Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
 
-    Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
+    CRNN Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
     How to convert from pb to onnx:
     Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
 
+    More converted onnx text recognition models can be downloaded directly here:
+    Download link: https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing
+    And these models taken from here:https://github.com/clovaai/deep-text-recognition-benchmark
+
```

Review comment:
Sorry for replying so late, I have added a flag to allow the sample to use both models at the same time. In addition, the OCR model based on DenseNet+CTC and DenseNet+BiLSTM+CTC has been added https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing.
**File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.

**Code Changes:**
```diff
@@ -2,12 +2,16 @@
     Text detection model: https://github.com/argman/EAST
     Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
 
-    Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
+    CRNN Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
     How to convert from pb to onnx:
     Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
 
+    More converted onnx text recognition models can be downloaded directly here:
```

Review comment:
The previous font is too big.
**File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.

**Code Changes:**
```diff
@@ -2,12 +2,16 @@
     Text detection model: https://github.com/argman/EAST
     Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
 
-    Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
+    CRNN Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
     How to convert from pb to onnx:
     Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
 
+    More converted onnx text recognition models can be downloaded directly here:
```

Review comment:
first case: [0, 255] -> [0, 1] -> [-0.5, 0.5] -> [0, 1] second: [0, 255] -> [-127.5, 127.5] -> [0, 1] They are equal
**File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.
**Review Line:** 11

**Code Changes:**
```diff
     How to convert from pb to onnx:
     Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
 
+    More converted onnx text recognition models can be downloaded directly here:
+    Download link: https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing
+    And these models taken from here:https://github.com/clovaai/deep-text-recognition-benchmark
+
     import torch
-    import models.crnn as crnn
+    from models.crnn import CRNN
 
```

Review comment:
Model works with the same sample without any changes?
**File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.
**Review Line:** 11

**Code Changes:**
```diff
     How to convert from pb to onnx:
     Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
 
+    More converted onnx text recognition models can be downloaded directly here:
+    Download link: https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing
+    And these models taken from here:https://github.com/clovaai/deep-text-recognition-benchmark
+
     import torch
-    import models.crnn as crnn
+    from models.crnn import CRNN
 
```

Review comment:
Yes, these two methods are fully compatible.
**File:** samples/dnn/text_detection.py
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.
**Review Line:** 16

**Code Changes:**
```diff
+
     import torch
-    import models.crnn as CRNN
+    from models.crnn import CRNN
+
     model = CRNN(32, 1, 37, 256)
     model.load_state_dict(torch.load('crnn.pth'))
     dummy_input = torch.randn(1, 1, 32, 100)
@@ -23,7 +30,8 @@
 parser = argparse.ArgumentParser(
     description="Use this script to run TensorFlow implementation (https://github.com/argman/EAST) of "
```

Review comment:
`import models.crnn as CRNN` or `model = crnn(32, 1, 37, 256)`
**File:** samples/dnn/text_detection.py
**Change Type:** modified
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.

**Code Changes:**
```diff
@@ -1,11 +1,18 @@
 '''
     Text detection model: https://github.com/argman/EAST
     Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
-    Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
+
+    CRNN Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
     How to convert from pb to onnx:
     Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
+
```

Review comment:
Can you please try to run this export script? It seems to me that should be ```python from models.crnn import CRNN model = CRNN(32, 1, 37, 256) ``` see https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
**File:** doc/tutorials/dnn/dnn_OCR/dnn_OCR.markdown
**Change Type:** added
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.

**Code Changes:**
```diff
@@ -0,0 +1,46 @@
+# How to run custom OCR model {#tutorial_dnn_OCR}
+
+@prev_tutorial{tutorial_dnn_custom_layers}
+
+## Introduction
+
+In this tutorial, we first introduce how to obtain the custom OCR model, then how to transform your own OCR models so that they can be run correctly by the opencv_dnn module. and finally we will provide some pre-trained models.
+
+## Train your own OCR model
```

Review comment:
we/me confusion. Please rephrase to `on i5-8300 CPU`
**File:** doc/tutorials/dnn/dnn_OCR/dnn_OCR.markdown
**Change Type:** added
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.

**Code Changes:**
```diff
@@ -0,0 +1,46 @@
+# How to run custom OCR model {#tutorial_dnn_OCR}
+
+@prev_tutorial{tutorial_dnn_custom_layers}
+
+## Introduction
+
+In this tutorial, we first introduce how to obtain the custom OCR model, then how to transform your own OCR models so that they can be run correctly by the opencv_dnn module. and finally we will provide some pre-trained models.
+
+## Train your own OCR model
```

Review comment:
Why GPU is mentioned?
**File:** doc/tutorials/dnn/dnn_OCR/dnn_OCR.markdown
**Change Type:** added
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.

**Code Changes:**
```diff
@@ -0,0 +1,46 @@
+# How to run custom OCR model {#tutorial_dnn_OCR}
+
+@prev_tutorial{tutorial_dnn_custom_layers}
+
+## Introduction
+
+In this tutorial, we first introduce how to obtain the custom OCR model, then how to transform your own OCR models so that they can be run correctly by the opencv_dnn module. and finally we will provide some pre-trained models.
+
+## Train your own OCR model
```

Review comment:
Please choose one format. I believe that 2 digits precision is enough `aa.bb`
**File:** doc/tutorials/dnn/dnn_OCR/dnn_OCR.markdown
**Change Type:** added
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.
**Review Line:** 22

**Code Changes:**
```diff
+#### Execute in webcam
+The Python version example code can be found at [here](https://github.com/opencv/opencv/blob/master/samples/dnn/text_detection.py).
+
+Example:
+@code{.bash}
+$ text_detection -m=[path_to_text_detect_model] -ocr=[path_to_text_recognition_model]
+@endcode
+
+## Pre-trained ONNX models are provided
+
+Some pre-trained models can be found at https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing.
```

Review comment:
Provide reference to sample source code
**File:** doc/tutorials/dnn/dnn_OCR/dnn_OCR.markdown
**Change Type:** added
**Context:** PR #17675: [GSoC] Add digit and text recognition samples.

**Code Changes:**
```diff
@@ -0,0 +1,46 @@
+# How to run custom OCR model {#tutorial_dnn_OCR}
+
+@prev_tutorial{tutorial_dnn_custom_layers}
+
+## Introduction
+
+In this tutorial, we first introduce how to obtain the custom OCR model, then how to transform your own OCR models so that they can be run correctly by the opencv_dnn module. and finally we will provide some pre-trained models.
+
+## Train your own OCR model
```

Review comment:
[transform_to_onnx.py](https://github.com/zihaomu/deep-text-recognition-benchmark/blob/master/transform_to_onnx.py)? ``` [transform_to_onnx.py](https://github.com/zihaomu/deep-text-recognition-benchmark/blob/master/transform_to_onnx.py) ```