nareshmlx/opencv-pr huggingface dataset:
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #19035: dnn: add another color to Net::Impl::dump()

**Code Changes:**
```diff
@@ -4461,7 +4461,7 @@ string Net::Impl::dump()
             prevNode = itBackend->second;
         }
     }
-    string colors[] = {"#ffffb3", "#fccde5", "#8dd3c7", "#bebada", "#80b1d3", "#fdb462", "#ff4848", "#b35151"};
+    std::vector<string> colors = {"#ffffb3", "#fccde5", "#8dd3c7", "#bebada", "#80b1d3", "#fdb462", "#ff4848", "#b35151", "#b266ff"};
     string backend;
     switch (prefBackend)
     {
@@ -4613,6 +4613,7 @@ string Net::Impl::dump()
```

Review comment:
It's done time to time, but not for each PR.
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #19035: dnn: add another color to Net::Impl::dump()

**Code Changes:**
```diff
@@ -4461,7 +4461,7 @@ string Net::Impl::dump()
             prevNode = itBackend->second;
         }
     }
-    string colors[] = {"#ffffb3", "#fccde5", "#8dd3c7", "#bebada", "#80b1d3", "#fdb462", "#ff4848", "#b35151"};
+    std::vector<string> colors = {"#ffffb3", "#fccde5", "#8dd3c7", "#bebada", "#80b1d3", "#fdb462", "#ff4848", "#b35151", "#b266ff"};
     string backend;
     switch (prefBackend)
     {
@@ -4613,6 +4613,7 @@ string Net::Impl::dump()
```

Review comment:
The check is good idea!
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #19035: dnn: add another color to Net::Impl::dump()

**Code Changes:**
```diff
@@ -4461,7 +4461,7 @@ string Net::Impl::dump()
             prevNode = itBackend->second;
         }
     }
-    string colors[] = {"#ffffb3", "#fccde5", "#8dd3c7", "#bebada", "#80b1d3", "#fdb462", "#ff4848", "#b35151"};
+    std::vector<string> colors = {"#ffffb3", "#fccde5", "#8dd3c7", "#bebada", "#80b1d3", "#fdb462", "#ff4848", "#b35151", "#b266ff"};
     string backend;
     switch (prefBackend)
     {
@@ -4613,6 +4613,7 @@ string Net::Impl::dump()
```

Review comment:
so i'll add it ...
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #19035: dnn: add another color to Net::Impl::dump()
**Review Line:** 4616

**Code Changes:**
```diff
     {
@@ -4613,6 +4613,7 @@ string Net::Impl::dump()
             case DNN_TARGET_CUDA_FP16: out << "CUDA_FP16"; colorId = 6; break;
             // don't use default:
         }
+        CV_Assert(colorId < colors.size());
         out << "\\n";  // align center
         out << ((clusterIds.size() == 1)? "\" " : " }\" ");
         out << "fillcolor=\"" << colors[colorId] << "\" ";
```

Review comment:
BTW, this check can help in runtime only. (no problem detection if there is no tests for this code)
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #19035: dnn: add another color to Net::Impl::dump()
**Review Line:** 4616

**Code Changes:**
```diff
     {
@@ -4613,6 +4613,7 @@ string Net::Impl::dump()
             case DNN_TARGET_CUDA_FP16: out << "CUDA_FP16"; colorId = 6; break;
             // don't use default:
         }
+        CV_Assert(colorId < colors.size());
         out << "\\n";  // align center
         out << ((clusterIds.size() == 1)? "\" " : " }\" ");
         out << "fillcolor=\"" << colors[colorId] << "\" ";
```

Review comment:
yes, i'd also rather favour something, that throws a compile time error instead. unfortunately, all i could come up with is this: enum X {A,B,C,D,MAX_X}; std::array<string,MAX_X> {"A","B","C","D","E"}; (works if there are excessive strings, but stays silent if there are not enough)
**File:** modules/dnn/src/dnn.cpp
**Change Type:** modified
**Context:** PR #19035: dnn: add another color to Net::Impl::dump()
**Review Line:** 4616

**Code Changes:**
```diff
     {
@@ -4613,6 +4613,7 @@ string Net::Impl::dump()
             case DNN_TARGET_CUDA_FP16: out << "CUDA_FP16"; colorId = 6; break;
             // don't use default:
         }
+        CV_Assert(colorId < colors.size());
         out << "\\n";  // align center
         out << ((clusterIds.size() == 1)? "\" " : " }\" ");
         out << "fillcolor=\"" << colors[colorId] << "\" ";
```

Review comment:
If you want to add "MAX" value into enum then please use this approach to hide that from documentation: https://github.com/opencv/opencv/blob/4.5.0/modules/calib3d/include/opencv2/calib3d.hpp#L474-L476
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** modified
**Context:** PR #18911: Add adding and subtraction operations between a number and a quaternion;
**Review Line:** 863

**Code Changes:**
```diff
@@ -859,6 +859,7 @@ class Quat
      *
      * @sa toRotMat3x3
      */
+
     Matx<_Tp, 4, 4> toRotMat4x4(QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT) const;
 
     /**
@@ -1073,42 +1074,362 @@ class Quat
                             const Quat<_Tp> &q2, const Quat<_Tp> &q3,
                             const _Tp t, QuatAssumeType assumeUnit=QUAT_ASSUME_NOT_UNIT);
```

Review comment:
this empty line is not necessary
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** modified
**Context:** PR #18911: Add adding and subtraction operations between a number and a quaternion;

**Code Changes:**
```diff
@@ -277,17 +277,18 @@ class Quat
      * For example
      * ```
      * Quatd q(1,2,3,4);
-     * power(q, 2);
+     * power(q, 2.0);
      *
      * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
      * double angle = CV_PI;
      * Vec3d axis{0, 0, 1};
```

Review comment:
> oppssite typo
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** modified
**Context:** PR #18911: Add adding and subtraction operations between a number and a quaternion;

**Code Changes:**
```diff
@@ -277,17 +277,18 @@ class Quat
      * For example
      * ```
      * Quatd q(1,2,3,4);
-     * power(q, 2);
+     * power(q, 2.0);
      *
      * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
      * double angle = CV_PI;
      * Vec3d axis{0, 0, 1};
```

Review comment:
> `_Tp&` Perhaps we don't need reference for scalars here (and other places)
**File:** modules/core/include/opencv2/core/quaternion.inl.hpp
**Change Type:** modified
**Context:** PR #18911: Add adding and subtraction operations between a number and a quaternion;

**Code Changes:**
```diff
@@ -148,6 +148,30 @@ inline Quat<T> Quat<T>::operator+(const Quat<T> &q1) const
     return Quat<T>(w + q1.w, x + q1.x, y + q1.y, z + q1.z);
 }
 
+template <typename T>
+inline Quat<T> operator+(const T a, const Quat<T>& q)
+{
+    return Quat<T>(q.w + a, q.x, q.y, q.z);
+}
+
```

Review comment:
please keep single empty "new line"
**File:** modules/core/include/opencv2/core/quaternion.hpp
**Change Type:** modified
**Context:** PR #18911: Add adding and subtraction operations between a number and a quaternion;

**Code Changes:**
```diff
@@ -277,17 +277,18 @@ class Quat
      * For example
      * ```
      * Quatd q(1,2,3,4);
-     * power(q, 2);
+     * power(q, 2.0);
      *
      * QuatAssumeType assumeUnit = QUAT_ASSUME_UNIT;
      * double angle = CV_PI;
      * Vec3d axis{0, 0, 1};
```

Review comment:
`,<space>`
**File:** modules/core/include/opencv2/core/quaternion.inl.hpp
**Change Type:** modified
**Context:** PR #18911: Add adding and subtraction operations between a number and a quaternion;

**Code Changes:**
```diff
@@ -148,6 +148,30 @@ inline Quat<T> Quat<T>::operator+(const Quat<T> &q1) const
     return Quat<T>(w + q1.w, x + q1.x, y + q1.y, z + q1.z);
 }
 
+template <typename T>
+inline Quat<T> operator+(const T a, const Quat<T>& q)
+{
+    return Quat<T>(q.w + a, q.x, q.y, q.z);
+}
+
```

Review comment:
Do you mean to create a new empty line at the end？
**File:** modules/core/include/opencv2/core/quaternion.inl.hpp
**Change Type:** modified
**Context:** PR #18911: Add adding and subtraction operations between a number and a quaternion;

**Code Changes:**
```diff
@@ -148,6 +148,30 @@ inline Quat<T> Quat<T>::operator+(const Quat<T> &q1) const
     return Quat<T>(w + q1.w, x + q1.x, y + q1.y, z + q1.z);
 }
 
+template <typename T>
+inline Quat<T> operator+(const T a, const Quat<T>& q)
+{
+    return Quat<T>(q.w + a, q.x, q.y, q.z);
+}
+
```

Review comment:
Yes, files should have with single "new line" symbol in the end (resolved)
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter

**Code Changes:**
```diff
@@ -73,22 +73,63 @@ Param test_data[] = {
 
 INSTANTIATE_TEST_CASE_P(videoio, videoio_gstreamer, testing::ValuesIn(test_data));
 
-TEST(Videoio_GStreamer, unsupported_pipeline)
+TEST(videoio_gstreamer, unsupported_pipeline)
 {
-    VideoCaptureAPIs apiPref = CAP_GSTREAMER;
-    if (!isBackendAvailable(apiPref, cv::videoio_registry::getStreamBackends()))
-        throw SkipTestException(cv::String("Backend is not available/disabled: ") + cv::videoio_registry::getBackendName(apiPref));
```

Review comment:
Please use `theRNG();` as random generator to get reproducible results.
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter

**Code Changes:**
```diff
@@ -73,22 +73,63 @@ Param test_data[] = {
 
 INSTANTIATE_TEST_CASE_P(videoio, videoio_gstreamer, testing::ValuesIn(test_data));
 
-TEST(Videoio_GStreamer, unsupported_pipeline)
+TEST(videoio_gstreamer, unsupported_pipeline)
 {
-    VideoCaptureAPIs apiPref = CAP_GSTREAMER;
-    if (!isBackendAvailable(apiPref, cv::videoio_registry::getStreamBackends()))
-        throw SkipTestException(cv::String("Backend is not available/disabled: ") + cv::videoio_registry::getBackendName(apiPref));
```

Review comment:
`Mat::zeros()` call is ambiguous as you fill the mat with random values.
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter
**Review Line:** 125

**Code Changes:**
```diff
+
+    // read noise frame back in
+    Mat written_frame(frame_size, CV_16U);
+    std::ifstream fs(temp_file, std::ios::in | std::ios::binary);
+    fs.read((char*)written_frame.ptr(0), frame_size.width * frame_size.height * 2);
+    ASSERT_TRUE(fs);
+    fs.close();
+
+    // compare to make sure it's identical
+    EXPECT_EQ(0, cv::norm(frame, written_frame, NORM_INF));
+
```

Review comment:
I think it should be before read call.
**File:** modules/videoio/src/backend_plugin.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter

**Code Changes:**
```diff
@@ -205,10 +205,15 @@ class PluginBackend: public IBackend
         FN_opencv_videoio_plugin_init_t fn_init = reinterpret_cast<FN_opencv_videoio_plugin_init_t>(lib_->getSymbol(init_name));
         if (fn_init)
         {
-            plugin_api_ = fn_init(ABI_VERSION, API_VERSION, NULL);
+            for (int supported_api_version = API_VERSION; supported_api_version >= 0; supported_api_version--)
+            {
+                plugin_api_ = fn_init(ABI_VERSION, supported_api_version, NULL);
+                if (plugin_api_)
+                    break;
```

Review comment:
I propose to extract this code as method of `VideoWriterParameters` class. E.g. return std::vector and pass it's content to C code as plain C array with size. We can potentially optimized the class behavior without plugins code modification.
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter

**Code Changes:**
```diff
@@ -73,22 +73,63 @@ Param test_data[] = {
 
 INSTANTIATE_TEST_CASE_P(videoio, videoio_gstreamer, testing::ValuesIn(test_data));
 
-TEST(Videoio_GStreamer, unsupported_pipeline)
+TEST(videoio_gstreamer, unsupported_pipeline)
 {
-    VideoCaptureAPIs apiPref = CAP_GSTREAMER;
-    if (!isBackendAvailable(apiPref, cv::videoio_registry::getStreamBackends()))
-        throw SkipTestException(cv::String("Backend is not available/disabled: ") + cv::videoio_registry::getBackendName(apiPref));
```

Review comment:
`cv::randu()` uses `cv::theRNG()` internally, so code is fine here.
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter

**Code Changes:**
```diff
@@ -73,22 +73,63 @@ Param test_data[] = {
 
 INSTANTIATE_TEST_CASE_P(videoio, videoio_gstreamer, testing::ValuesIn(test_data));
 
-TEST(Videoio_GStreamer, unsupported_pipeline)
+TEST(videoio_gstreamer, unsupported_pipeline)
 {
-    VideoCaptureAPIs apiPref = CAP_GSTREAMER;
-    if (!isBackendAvailable(apiPref, cv::videoio_registry::getStreamBackends()))
-        throw SkipTestException(cv::String("Backend is not available/disabled: ") + cv::videoio_registry::getBackendName(apiPref));
```

Review comment:
> `Mat::zeros()` call is ambiguous as you fill the mat with random values. Not correct. > **zeros** fill with zeros values.
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter

**Code Changes:**
```diff
@@ -73,22 +73,63 @@ Param test_data[] = {
 
 INSTANTIATE_TEST_CASE_P(videoio, videoio_gstreamer, testing::ValuesIn(test_data));
 
-TEST(Videoio_GStreamer, unsupported_pipeline)
+TEST(videoio_gstreamer, unsupported_pipeline)
 {
-    VideoCaptureAPIs apiPref = CAP_GSTREAMER;
-    if (!isBackendAvailable(apiPref, cv::videoio_registry::getStreamBackends()))
-        throw SkipTestException(cv::String("Backend is not available/disabled: ") + cv::videoio_registry::getBackendName(apiPref));
```

Review comment:
I'm not sure why the numbers have to be reproducible, as I'm simply comparing what I've generated to what I read back in. If this change request still stands, would I do it like this? ``` cv::theRNG().state = 123456; cv::randu(frame, 0, 65535); ```
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter
**Review Line:** 125

**Code Changes:**
```diff
+
+    // read noise frame back in
+    Mat written_frame(frame_size, CV_16U);
+    std::ifstream fs(temp_file, std::ios::in | std::ios::binary);
+    fs.read((char*)written_frame.ptr(0), frame_size.width * frame_size.height * 2);
+    ASSERT_TRUE(fs);
+    fs.close();
+
+    // compare to make sure it's identical
+    EXPECT_EQ(0, cv::norm(frame, written_frame, NORM_INF));
+
```

Review comment:
I believe this assertion ensures that `.read()` call is successful (it is really necessary).
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter

**Code Changes:**
```diff
@@ -73,22 +73,63 @@ Param test_data[] = {
 
 INSTANTIATE_TEST_CASE_P(videoio, videoio_gstreamer, testing::ValuesIn(test_data));
 
-TEST(Videoio_GStreamer, unsupported_pipeline)
+TEST(videoio_gstreamer, unsupported_pipeline)
 {
-    VideoCaptureAPIs apiPref = CAP_GSTREAMER;
-    if (!isBackendAvailable(apiPref, cv::videoio_registry::getStreamBackends()))
-        throw SkipTestException(cv::String("Backend is not available/disabled: ") + cv::videoio_registry::getBackendName(apiPref));
```

Review comment:
Please use this for "identity" checks: ``` EXPECT_EQ(0, cv::norm(frame, written_frame, NORM_INF)); ```
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter

**Code Changes:**
```diff
@@ -73,22 +73,63 @@ Param test_data[] = {
 
 INSTANTIATE_TEST_CASE_P(videoio, videoio_gstreamer, testing::ValuesIn(test_data));
 
-TEST(Videoio_GStreamer, unsupported_pipeline)
+TEST(videoio_gstreamer, unsupported_pipeline)
 {
-    VideoCaptureAPIs apiPref = CAP_GSTREAMER;
-    if (!isBackendAvailable(apiPref, cv::videoio_registry::getStreamBackends()))
-        throw SkipTestException(cv::String("Backend is not available/disabled: ") + cv::videoio_registry::getBackendName(apiPref));
```

Review comment:
Ambiguous isn't the right word to use, but since all the values get overwritten immediately, it is unnecessary to initialize to zero, even if it is a very fast operation. I've changed this to simply `Mat(frame_size, CV_16U)`
**File:** modules/videoio/src/backend_plugin.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter

**Code Changes:**
```diff
@@ -205,10 +205,15 @@ class PluginBackend: public IBackend
         FN_opencv_videoio_plugin_init_t fn_init = reinterpret_cast<FN_opencv_videoio_plugin_init_t>(lib_->getSymbol(init_name));
         if (fn_init)
         {
-            plugin_api_ = fn_init(ABI_VERSION, API_VERSION, NULL);
+            for (int supported_api_version = API_VERSION; supported_api_version >= 0; supported_api_version--)
+            {
+                plugin_api_ = fn_init(ABI_VERSION, supported_api_version, NULL);
+                if (plugin_api_)
+                    break;
```

Review comment:
Ok I added `getIntVector()`.
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter

**Code Changes:**
```diff
@@ -73,22 +73,63 @@ Param test_data[] = {
 
 INSTANTIATE_TEST_CASE_P(videoio, videoio_gstreamer, testing::ValuesIn(test_data));
 
-TEST(Videoio_GStreamer, unsupported_pipeline)
+TEST(videoio_gstreamer, unsupported_pipeline)
 {
-    VideoCaptureAPIs apiPref = CAP_GSTREAMER;
-    if (!isBackendAvailable(apiPref, cv::videoio_registry::getStreamBackends()))
-        throw SkipTestException(cv::String("Backend is not available/disabled: ") + cv::videoio_registry::getBackendName(apiPref));
```

Review comment:
Sorry for my English, ambiguous is not the right word. I mean redundant.
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter
**Review Line:** 125

**Code Changes:**
```diff
+
+    // read noise frame back in
+    Mat written_frame(frame_size, CV_16U);
+    std::ifstream fs(temp_file, std::ios::in | std::ios::binary);
+    fs.read((char*)written_frame.ptr(0), frame_size.width * frame_size.height * 2);
+    ASSERT_TRUE(fs);
+    fs.close();
+
+    // compare to make sure it's identical
+    EXPECT_EQ(0, cv::norm(frame, written_frame, NORM_INF));
+
```

Review comment:
I did some tests, I could put an assertion both before and after `.read()`, however the second assertion will catch the same issue that the first assertion would, that is if a file is missing or can't be opened. I left this as is for now.
**File:** modules/videoio/test/test_gstreamer.cpp
**Change Type:** modified
**Context:** PR #18535: Add CV_16UC1/GRAY16_LE support to GStreamer backend for VideoWriter

**Code Changes:**
```diff
@@ -73,22 +73,63 @@ Param test_data[] = {
 
 INSTANTIATE_TEST_CASE_P(videoio, videoio_gstreamer, testing::ValuesIn(test_data));
 
-TEST(Videoio_GStreamer, unsupported_pipeline)
+TEST(videoio_gstreamer, unsupported_pipeline)
 {
-    VideoCaptureAPIs apiPref = CAP_GSTREAMER;
-    if (!isBackendAvailable(apiPref, cv::videoio_registry::getStreamBackends()))
-        throw SkipTestException(cv::String("Backend is not available/disabled: ") + cv::videoio_registry::getBackendName(apiPref));
```

Review comment:
Not needed. `theRNG()` initial state is initialized by OpenCV test framework (using the same value) before calling of each test case body. BTW, initial `theRNG()` state is configurable through command-line (however this mode is not used widely). Test data should not rely on its value.
**File:** modules/videoio/test/test_camera.cpp
**Change Type:** modified
**Context:** PR #18966: Add live timestamps to MSMF Video API

**Code Changes:**
```diff
@@ -11,21 +11,51 @@
 
 namespace opencv_test { namespace {
 
-static void test_readFrames(/*const*/ VideoCapture& capture, const int N = 100, Mat* lastFrame = NULL)
+static void test_readFrames(/*const*/ VideoCapture& capture, const int N = 100, Mat* lastFrame = NULL, bool testTimestamps = true)
 {
     Mat frame;
     int64 time0 = cv::getTickCount();
+    int64 sysTimePrev = time0;
```

Review comment:
I prpose to check returned FPS value if it's not zero before division.
**File:** samples/cpp/tutorial_code/videoio/orbbec_astra/orbbec_astra.cpp
**Change Type:** modified
**Context:** PR #18971: Improve tutorial on using Orbbec Astra cameras

**Code Changes:**
```diff
@@ -69,7 +69,6 @@ int main()
     //! [Read streams]
     // Create two lists to store frames
     std::list<Frame> depthFrames, colorFrames;
-    std::mutex depthFramesMtx, colorFramesMtx;
     const std::size_t maxFrames = 64;
 
     // Synchronization objects
@@ -90,16 +89,14 @@ int main()
                 Frame f;
```

Review comment:
The thread does not do useful work and is not mentioned in tutorial code. I think that frames sync and UI render in main is enough for tutorial.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp
**Change Type:** modified
**Context:** PR #18891: Add option for NMS for boxes with different labels

**Code Changes:**
```diff
@@ -1296,6 +1296,23 @@ CV__DNN_INLINE_NS_BEGIN
           */
          CV_WRAP DetectionModel(const Net& network);
 
+         CV_DEPRECATED_EXTERNAL  // avoid using in C++ code (need to fix bindings first)
+         DetectionModel();
+
+         /**
+          * @brief nmsAcrossClasses defaults to false,
+          * such that when non max suppression is used during the detect() function, it will do so per-class.
```

Review comment:
Please choose better naming which describes behavior. In example, `nmsAcrossClasses` with default value false.
**File:** modules/dnn/src/model.cpp
**Change Type:** modified
**Context:** PR #18891: Add option for NMS for boxes with different labels

**Code Changes:**
```diff
@@ -320,34 +320,78 @@ void SegmentationModel::segment(InputArray frame, OutputArray mask)
     }
 }
 
-void disableRegionNMS(Net& net)
+class DetectionModel_Impl : public Model::Impl
 {
-    for (String& name : net.getUnconnectedOutLayersNames())
+public:
+    virtual ~DetectionModel_Impl() {}
```

Review comment:
Keep origin code style - open a block in a new line
**File:** modules/dnn/test/test_model.cpp
**Change Type:** modified
**Context:** PR #18891: Add option for NMS for boxes with different labels
**Review Line:** 221

**Code Changes:**
```diff
+    bool swapRB = true;
+    bool crop = false;
+    bool nmsAcrossClasses = true;
+
+    double confThreshold = 0.24;
+    double nmsThreshold = (target == DNN_TARGET_MYRIAD) ? 0.15: 0.15;
+    double scoreDiff = 8e-5, iouDiff = 1e-5;
+    if (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD || target == DNN_TARGET_CUDA_FP16)
+    {
+        scoreDiff = 1e-2;
+        iouDiff = 1.6e-2;
```

Review comment:
Test seems very synthetic - actual overlap is not very high and may confuse. Can you try with other images from opencv_extra?
**File:** modules/dnn/src/model.cpp
**Change Type:** modified
**Context:** PR #18891: Add option for NMS for boxes with different labels

**Code Changes:**
```diff
@@ -320,34 +320,78 @@ void SegmentationModel::segment(InputArray frame, OutputArray mask)
     }
 }
 
-void disableRegionNMS(Net& net)
+class DetectionModel_Impl : public Model::Impl
 {
-    for (String& name : net.getUnconnectedOutLayersNames())
+public:
+    virtual ~DetectionModel_Impl() {}
```

Review comment:
Can you check the updated commit please?