nareshmlx/opencv-pr huggingface dataset:
**File:** modules/gapi/misc/python/test/test_gapi_imgproc.py
**Change Type:** added
**Context:** PR #18762: [G-API] Wrap GArray

**Code Changes:**
```diff
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+
+import numpy as np
+import cv2 as cv
+import os
+
+from tests_common import NewOpenCVTests
+
+
```

Review comment:
> for pkg in pkgs Consider providing clear messages about failures: add information about used "pkg".
**File:** modules/gapi/src/api/gcomputation.cpp
**Change Type:** modified
**Context:** PR #18762: [G-API] Wrap GArray
**Review Line:** 206

**Code Changes:**
```diff
             }
+            case cv::GShape::GARRAY:
+            {
+                switch (info.kind)
+                {
+                    case cv::detail::OpaqueKind::CV_POINT2F:
+                        run_args.emplace_back(cv::detail::VectorRef{std::vector<cv::Point2f>{}});
+                        outs.emplace_back(cv::util::get<cv::detail::VectorRef>(run_args.back()));
+                        break;
+                    default:
+                        util::throw_error(std::logic_error("Unsupported kind for GArray"));
```

Review comment:
I'm going to use `HostCtor` to avoid switch here in next PR
**File:** modules/gapi/src/api/gcomputation.cpp
**Change Type:** modified
**Context:** PR #18762: [G-API] Wrap GArray
**Review Line:** 206

**Code Changes:**
```diff
             }
+            case cv::GShape::GARRAY:
+            {
+                switch (info.kind)
+                {
+                    case cv::detail::OpaqueKind::CV_POINT2F:
+                        run_args.emplace_back(cv::detail::VectorRef{std::vector<cv::Point2f>{}});
+                        outs.emplace_back(cv::util::get<cv::detail::VectorRef>(run_args.back()));
+                        break;
+                    default:
+                        util::throw_error(std::logic_error("Unsupported kind for GArray"));
```

Review comment:
It has been already implemented in PR: https://github.com/opencv/opencv/pull/18900
**File:** modules/gapi/test/gapi_graph_meta_tests.cpp
**Change Type:** modified
**Context:** PR #18904: G-API: Adding skip for GraphMeta tests

**Code Changes:**
```diff
@@ -99,7 +99,12 @@ TEST(GraphMeta, Streaming_AccessInput) {
     cv::GComputation graph(cv::GIn(in), cv::GOut(out1, out2));
 
     auto ccomp = graph.compileStreaming();
-    ccomp.setSource<cv::gapi::wip::GCaptureSource>(findDataFile("cv/video/768x576.avi", false));
+    const auto path = findDataFile("cv/video/768x576.avi");
+    try {
+        ccomp.setSource<cv::gapi::wip::GCaptureSource>(path);
+    } catch(...) {
+        throw SkipTestException("Video file can not be opened");
```

Review comment:
> false Why is `false` here? This file is part of `opencv_extra` and its searching must be mandatory.
**File:** modules/gapi/test/gapi_graph_meta_tests.cpp
**Change Type:** modified
**Context:** PR #18904: G-API: Adding skip for GraphMeta tests

**Code Changes:**
```diff
@@ -99,7 +99,12 @@ TEST(GraphMeta, Streaming_AccessInput) {
     cv::GComputation graph(cv::GIn(in), cv::GOut(out1, out2));
 
     auto ccomp = graph.compileStreaming();
-    ccomp.setSource<cv::gapi::wip::GCaptureSource>(findDataFile("cv/video/768x576.avi", false));
+    const auto path = findDataFile("cv/video/768x576.avi");
+    try {
+        ccomp.setSource<cv::gapi::wip::GCaptureSource>(path);
+    } catch(...) {
+        throw SkipTestException("Video file can not be opened");
```

Review comment:
It is author's idea. But without `false` tests are failed on local pc. With `false` are skipped.
**File:** modules/gapi/test/gapi_graph_meta_tests.cpp
**Change Type:** modified
**Context:** PR #18904: G-API: Adding skip for GraphMeta tests

**Code Changes:**
```diff
@@ -99,7 +99,12 @@ TEST(GraphMeta, Streaming_AccessInput) {
     cv::GComputation graph(cv::GIn(in), cv::GOut(out1, out2));
 
     auto ccomp = graph.compileStreaming();
-    ccomp.setSource<cv::gapi::wip::GCaptureSource>(findDataFile("cv/video/768x576.avi", false));
+    const auto path = findDataFile("cv/video/768x576.avi");
+    try {
+        ccomp.setSource<cv::gapi::wip::GCaptureSource>(path);
+    } catch(...) {
+        throw SkipTestException("Video file can not be opened");
```

Review comment:
> failed on local pc `OPENCV_TEST_DATA_PATH` must be properly configured. See Wiki pages how to use OpenCV tests. `false` must be used only for optional test data on external data shares. Otherwise, related test data can be removed / moved / renamed in opencv_extra. And these tests would just skip.
**File:** modules/gapi/test/gapi_graph_meta_tests.cpp
**Change Type:** modified
**Context:** PR #18904: G-API: Adding skip for GraphMeta tests

**Code Changes:**
```diff
@@ -99,7 +99,12 @@ TEST(GraphMeta, Streaming_AccessInput) {
     cv::GComputation graph(cv::GIn(in), cv::GOut(out1, out2));
 
     auto ccomp = graph.compileStreaming();
-    ccomp.setSource<cv::gapi::wip::GCaptureSource>(findDataFile("cv/video/768x576.avi", false));
+    const auto path = findDataFile("cv/video/768x576.avi");
+    try {
+        ccomp.setSource<cv::gapi::wip::GCaptureSource>(path);
+    } catch(...) {
+        throw SkipTestException("Video file can not be opened");
```

Review comment:
Ok. Removed `false` from `findDataFile`.
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #18285: cuda4dnn: enable fusion tests, update thresholds, fix eltwise fusion regression
**Review Line:** 2697

**Code Changes:**
```diff
+                            break;
                     }
 #endif
 
-                    if (pinsToKeep.count(lpNext) != 0)
+                    if (IS_DNN_OPENCL_TARGET(preferableTarget) && pinsToKeep.count(lpNext) != 0)
                         break;
                     if (nextData->inputBlobsId.size() != 2)
                         break;
 
-                    if (!nextData->params.has("operation") || toLowerCase(nextData->params.get<String>("operation")) == "sum")
```

Review comment:
This change fixes a regression (affects master only -- 3.4 is fine) from #18554 (that landed in master through merge PR #18556). The CUDA backend can optionally fuse an activation before eltwise (for YOLO like networks) and also optionally fuse an activation after eltwise (for ResNet like networks). Hence, this check is wrong for CUDA backend. This check prevents valid fusions and causes the fusion tests to fail (Yay! The tests are doing their job!). It's correct for OpenCL since it always fuses an activation after eltwise. However, this check is redundant on master. The fusion logic downstream will actually do the same check. But this check will help break the fusion process early. So I have added a target check to ensure that it's only used in OpenCL targets.
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #18285: cuda4dnn: enable fusion tests, update thresholds, fix eltwise fusion regression
**Review Line:** 2702

**Code Changes:**
```diff
                         break;
                     if (nextData->inputBlobsId.size() != 2)
                         break;
 
-                    if (!nextData->params.has("operation") || toLowerCase(nextData->params.get<String>("operation")) == "sum")
+                    if (IS_DNN_OPENCL_TARGET(preferableTarget))
                     {
-                        if (nextData->params.has("coeff"))
+                        if (!nextData->params.has("operation") || toLowerCase(nextData->params.get<String>("operation")) == "sum")
                         {
-                            DictValue paramCoeff = nextData->params.get("coeff");
```

Review comment:
I have added an OpenCL target check to prevent eltwise operation and coeffs checks running in other targets. These checks are strictly not required for the CUDA backend as it has its own checks that appear prior to these checks. This OpenCL checks would still be redo the checks in a different way (although redundant) but it causes coupling of the two backends. I just thought decoupling OpenCL and CUDA checks might prevent future surprises (they already have different fusion capabilities). I am not sure if this change is really required. It seems to be messing up git diff because of the indentation added across the whole block.
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #18285: cuda4dnn: enable fusion tests, update thresholds, fix eltwise fusion regression
**Review Line:** 225

**Code Changes:**
```diff
     testONNXModels("two_deconvolution", npy, 0, 0, false, false);
     testONNXModels("deconvolution_group", npy, 0, 0, false, false);
     testONNXModels("deconvolution_output_shape", npy, 0, 0, false, false);
-    testONNXModels("deconv_adjpad_2d", npy, 0, 0, false, false);
+    if (target != DNN_TARGET_CUDA_FP16) // bug
+        testONNXModels("deconv_adjpad_2d", npy, 0, 0, false, false);
 }
 
 TEST_P(Test_ONNX_layers, Deconvolution3D)
@@ -675,6 +676,8 @@ TEST_P(Test_ONNX_layers, LinearWithConstant)
 #if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2020040000)
```

Review comment:
This test case has five tests. Only the last test fails for CUDA FP16 target. I haven't skipped since the other tests are still useful but not skipping might make it harder to track (and enable it in the future after the bug is fixed). Maybe it would be a good idea to split this tests into multiple tests (or at least split the one that is failing into its own test).
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #18845: Fix for index error for Reduce Mean

**Code Changes:**
```diff
@@ -494,14 +494,17 @@ void ONNXImporter::handleNode(const opencv_onnx::NodeProto& node_proto_)
                 MatShape inpShape = outShapes[node_proto.input(0)];
                 DictValue axes = layerParams.get("axes");
                 bool keepdims = layerParams.get<int>("keepdims");
-                MatShape targetShape = inpShape;
+                MatShape targetShape;
+                std::vector<bool> shouldDelete(inpShape.size(), false);
                 for (int i = 0; i < axes.size(); i++) {
                     int axis = clamp(axes.get<int>(i), inpShape.size());
-                    if (keepdims) {
```

Review comment:
This solution is slightly incorrect, it doesn't work with **keepdims**. I think it's better to try something like: ``` MatShape targetShape; std::vector<bool> shouldDelete(inpShape.size(), false); for (int i = 0; i < axes.size(); i++) { int axis = clamp(axes.get<int>(i), inpShape.size()); shouldDelete[axis] = true; } for (int axis = 0; axis < inpShape.size(); ++axis){ if (!shouldDelete[axis]) targetShape.push_back(inpShape[axis]); else if (keepdims) targetShape.push_back(1); } ```
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #18845: Fix for index error for Reduce Mean

**Code Changes:**
```diff
@@ -494,14 +494,17 @@ void ONNXImporter::handleNode(const opencv_onnx::NodeProto& node_proto_)
                 MatShape inpShape = outShapes[node_proto.input(0)];
                 DictValue axes = layerParams.get("axes");
                 bool keepdims = layerParams.get<int>("keepdims");
-                MatShape targetShape = inpShape;
+                MatShape targetShape;
+                std::vector<bool> shouldDelete(inpShape.size(), false);
                 for (int i = 0; i < axes.size(); i++) {
                     int axis = clamp(axes.get<int>(i), inpShape.size());
-                    if (keepdims) {
```

Review comment:
This way it doesn't brake the tests
**File:** modules/gapi/src/backends/cpu/gcpuvideo.cpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -80,12 +80,40 @@ GAPI_OCV_KERNEL(GCPUCalcOptFlowLKForPyr, cv::gapi::video::GCalcOptFlowLKForPyr)
     }
 };
 
+GAPI_OCV_KERNEL_ST(GCPUBackgroundSubtractor,
+                   cv::gapi::video::GBackgroundSubtractor,
+                   cv::BackgroundSubtractor)
+{
+    static void setup(const cv::GMatDesc&, const cv::gapi::video::BackgroundSubtractorParams& bsParams,
+                      std::shared_ptr<cv::BackgroundSubtractor>& state,
```

Review comment:
> double learningRate Lost this parameter too.
**File:** modules/gapi/src/backends/cpu/gcpuvideo.cpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -80,12 +80,40 @@ GAPI_OCV_KERNEL(GCPUCalcOptFlowLKForPyr, cv::gapi::video::GCalcOptFlowLKForPyr)
     }
 };
 
+GAPI_OCV_KERNEL_ST(GCPUBackgroundSubtractor,
+                   cv::gapi::video::GBackgroundSubtractor,
+                   cv::BackgroundSubtractor)
+{
+    static void setup(const cv::GMatDesc&, const cv::gapi::video::BackgroundSubtractorParams& bsParams,
+                      std::shared_ptr<cv::BackgroundSubtractor>& state,
```

Review comment:
Suggest to refactor like that: https://github.com/opencv/opencv/blob/f83166dd9f04ffb288e3532af4002f1901750ee3/modules/gapi/include/opencv2/gapi/imgproc.hpp#L57
**File:** modules/gapi/src/backends/cpu/gcpuvideo.cpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -80,12 +80,40 @@ GAPI_OCV_KERNEL(GCPUCalcOptFlowLKForPyr, cv::gapi::video::GCalcOptFlowLKForPyr)
     }
 };
 
+GAPI_OCV_KERNEL_ST(GCPUBackgroundSubtractor,
+                   cv::gapi::video::GBackgroundSubtractor,
+                   cv::BackgroundSubtractor)
+{
+    static void setup(const cv::GMatDesc&, const cv::gapi::video::BackgroundSubtractorParams& bsParams,
+                      std::shared_ptr<cv::BackgroundSubtractor>& state,
```

Review comment:
Can be useful to add comments about which namespaces are closed `// namespace cv`
**File:** modules/gapi/test/common/gapi_video_tests_inl.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -8,6 +8,7 @@
 #define OPENCV_GAPI_VIDEO_TESTS_INL_HPP
 
 #include "gapi_video_tests.hpp"
+#include <opencv2/gapi/streaming/cap.hpp>
 
 namespace opencv_test
 {
@@ -88,6 +89,49 @@ TEST_P(BuildPyr_CalcOptFlow_PipelineTest, AccuracyTest)
     compareOutputsOptFlow(outOCV, outGAPI);
```

Review comment:
Please, use cv::gapi::BackgroundSubtractorMOG2() instead
**File:** modules/gapi/test/common/gapi_video_tests_common.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -321,6 +321,35 @@ inline GComputation runOCVnGAPIOptFlowPipeline(TestFunctional& testInst,
     return c;
 }
 
+inline void testBackgroundSubtractorStreaming(cv::GStreamingCompiled& gapiBackSub,
+                                              const cv::Ptr<cv::BackgroundSubtractor>& pOCVBackSub,
+                                              const int diffPercent, const int tolerance,
+                                              const double lRate, const std::size_t testNumFrames)
+{
+    cv::Mat frame, gapiForeground, ocvForeground;
```

Review comment:
Would you mind to use a reference for namespace here? `cv::createBackgroundSubtractorMOG2`
**File:** modules/gapi/test/common/gapi_video_tests_common.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -321,6 +321,35 @@ inline GComputation runOCVnGAPIOptFlowPipeline(TestFunctional& testInst,
     return c;
 }
 
+inline void testBackgroundSubtractorStreaming(cv::GStreamingCompiled& gapiBackSub,
+                                              const cv::Ptr<cv::BackgroundSubtractor>& pOCVBackSub,
+                                              const int diffPercent, const int tolerance,
+                                              const double lRate, const std::size_t testNumFrames)
+{
+    cv::Mat frame, gapiForeground, ocvForeground;
```

Review comment:
Just on a single line?
**File:** modules/gapi/test/common/gapi_video_tests_inl.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -8,6 +8,7 @@
 #define OPENCV_GAPI_VIDEO_TESTS_INL_HPP
 
 #include "gapi_video_tests.hpp"
+#include <opencv2/gapi/streaming/cap.hpp>
 
 namespace opencv_test
 {
@@ -88,6 +89,49 @@ TEST_P(BuildPyr_CalcOptFlow_PipelineTest, AccuracyTest)
     compareOutputsOptFlow(outOCV, outGAPI);
```

Review comment:
I think this way is preferable to pass the kernel package. Is it necessary to manually pass `GCPUBackgroundSubtractorMOG2` to `GComputation`?
**File:** modules/gapi/test/common/gapi_video_tests_inl.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -8,6 +8,7 @@
 #define OPENCV_GAPI_VIDEO_TESTS_INL_HPP
 
 #include "gapi_video_tests.hpp"
+#include <opencv2/gapi/streaming/cap.hpp>
 
 namespace opencv_test
 {
@@ -88,6 +89,49 @@ TEST_P(BuildPyr_CalcOptFlow_PipelineTest, AccuracyTest)
     compareOutputsOptFlow(outOCV, outGAPI);
```

Review comment:
Is difference worse because of greater resolution of the file? Just interesting :)
**File:** modules/gapi/include/opencv2/gapi/video.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...
**Review Line:** 243

**Code Changes:**
```diff
 
+/** @brief Gaussian Mixture-based or K-nearest neighbours-based Background/Foreground Segmentation Algorithm.
+The operation generates a foreground mask.
+
+@return Output image is foreground mask, i.e. 8-bit unsigned 1-channel (binary) matrix @ref CV_8UC1.
+
+@note Functional textual ID is "org.opencv.video.BackgroundSubtractor"
+
+@param src input image: Floating point frame is used without scaling and should be in range [0,255].
+@param bsParams Set of initialization parameters for Background Subtractor kernel.
+*/
```

Review comment:
It may be great to describe how this stateful kernel works - that it preserves initialized `cv::createBackgroundSubtractorMOG2` object - and give details on where to put initializing parameters for the Subtractor. I mean, that we pass them via `compile_args`
**File:** modules/gapi/include/opencv2/gapi/video.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -62,6 +62,73 @@ G_TYPED_KERNEL(GCalcOptFlowLKForPyr,
         return std::make_tuple(empty_array_desc(), empty_array_desc(), empty_array_desc());
     }
 };
+
+enum BackgroundSubtractorType
+{
+    TYPE_BS_MOG2,
+    TYPE_BS_KNN
+};
```

Review comment:
`learningRate` parameter description missing
**File:** modules/gapi/test/common/gapi_video_tests_common.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -321,6 +321,35 @@ inline GComputation runOCVnGAPIOptFlowPipeline(TestFunctional& testInst,
     return c;
 }
 
+inline void testBackgroundSubtractorStreaming(cv::GStreamingCompiled& gapiBackSub,
+                                              const cv::Ptr<cv::BackgroundSubtractor>& pOCVBackSub,
+                                              const int diffPercent, const int tolerance,
+                                              const double lRate, const std::size_t testNumFrames)
+{
+    cv::Mat frame, gapiForeground, ocvForeground;
```

Review comment:
Can't it be done by function like `cv::sum`?
**File:** modules/gapi/test/common/gapi_video_tests_common.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -321,6 +321,35 @@ inline GComputation runOCVnGAPIOptFlowPipeline(TestFunctional& testInst,
     return c;
 }
 
+inline void testBackgroundSubtractorStreaming(cv::GStreamingCompiled& gapiBackSub,
+                                              const cv::Ptr<cv::BackgroundSubtractor>& pOCVBackSub,
+                                              const int diffPercent, const int tolerance,
+                                              const double lRate, const std::size_t testNumFrames)
+{
+    cv::Mat frame, gapiForeground, ocvForeground;
```

Review comment:
You can consider using `cv::norm` to compare two Mats as well And also you can try one of comparison functions implemented in `gapi_tests_common.hpp`
**File:** modules/gapi/include/opencv2/gapi/video.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -62,6 +62,73 @@ G_TYPED_KERNEL(GCalcOptFlowLKForPyr,
         return std::make_tuple(empty_array_desc(), empty_array_desc(), empty_array_desc());
     }
 };
+
+enum BackgroundSubtractorType
+{
+    TYPE_BS_MOG2,
+    TYPE_BS_KNN
+};
```

Review comment:
`bool` -> `double`
**File:** modules/gapi/test/common/gapi_video_tests_inl.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -8,6 +8,7 @@
 #define OPENCV_GAPI_VIDEO_TESTS_INL_HPP
 
 #include "gapi_video_tests.hpp"
+#include <opencv2/gapi/streaming/cap.hpp>
 
 namespace opencv_test
 {
@@ -88,6 +89,49 @@ TEST_P(BuildPyr_CalcOptFlow_PipelineTest, AccuracyTest)
     compareOutputsOptFlow(outOCV, outGAPI);
```

Review comment:
Difference between GAPI and OCV results should be smaller than 5%. Here nothing is said about the file resolution.
**File:** modules/gapi/test/common/gapi_video_tests_common.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -321,6 +321,35 @@ inline GComputation runOCVnGAPIOptFlowPipeline(TestFunctional& testInst,
     return c;
 }
 
+inline void testBackgroundSubtractorStreaming(cv::GStreamingCompiled& gapiBackSub,
+                                              const cv::Ptr<cv::BackgroundSubtractor>& pOCVBackSub,
+                                              const int diffPercent, const int tolerance,
+                                              const double lRate, const std::size_t testNumFrames)
+{
+    cv::Mat frame, gapiForeground, ocvForeground;
```

Review comment:
The snippet isn't my. I only moved it.
**File:** modules/gapi/include/opencv2/gapi/video.hpp
**Change Type:** modified
**Context:** PR #18674: GAPI: New BackgroundSubtractor stateful kernel - New BackgroundSubtractor kernel represents 2 types of operation such as: - Background Subt...

**Code Changes:**
```diff
@@ -62,6 +62,73 @@ G_TYPED_KERNEL(GCalcOptFlowLKForPyr,
         return std::make_tuple(empty_array_desc(), empty_array_desc(), empty_array_desc());
     }
 };
+
+enum BackgroundSubtractorType
+{
+    TYPE_BS_MOG2,
+    TYPE_BS_KNN
+};
```

Review comment:
I'll think about it.