nareshmlx/opencv-pr huggingface dataset:
**File:** modules/dnn/misc/python/test/test_dnn.py
**Change Type:** modified
**Context:** PR #25810: python: attempts to fix 3d mat parsing problem for dnn
**Review Line:** 461

**Code Changes:**
```diff
@@ -455,10 +455,6 @@ def test_input_3d(self):
                                     "Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.")
 
         input = np.load(input_file)
-        # we have to expand the shape of input tensor because Python bindings cut 3D tensors to 2D
-        # it should be fixed in future. see : https://github.com/opencv/opencv/issues/19091
-        # please remove `expand_dims` after that
-        input = np.expand_dims(input, axis=3)
         gold_output = np.load(output_file)
 
         for backend, target in self.dnnBackendsAndTargets:
@@ -469,10 +465,63 @@ def test_input_3d(self):
             net.setPreferableBackend(backend)
             net.setPreferableTarget(target)
 
```

Review comment:
`setInput` has been tested in this one. It was previously hacked to make it passed. --- I also added `CV_ND` macro for `setParam`. Does it need to be tested? This API is not tested any where though.
**File:** CMakeLists.txt
**Change Type:** modified
**Context:** PR #25858: Enable KleidiCV for Android aarch64 by default.

**Code Changes:**
```diff
@@ -261,7 +261,7 @@ OCV_OPTION(WITH_CAP_IOS "Enable iOS video capture" ON
   VERIFY HAVE_CAP_IOS)
 OCV_OPTION(WITH_CAROTENE "Use NVidia carotene acceleration library for ARM platform" (NOT CV_DISABLE_OPTIMIZATION)
   VISIBLE_IF (ARM OR AARCH64) AND NOT IOS AND NOT XROS)
-OCV_OPTION(WITH_KLEIDICV "Use KleidiCV library for ARM platforms" OFF
+OCV_OPTION(WITH_KLEIDICV "Use KleidiCV library for ARM platforms" (ANDROID AND AARCH64 AND NOT CV_DISABLE_OPTIMIZATION)
   VISIBLE_IF (AARCH64 AND (ANDROID OR UNIX AND NOT IOS AND NOT XROS)))
 OCV_OPTION(WITH_NDSRVP "Use Andes RVP extension" (NOT CV_DISABLE_OPTIMIZATION)
   VISIBLE_IF RISCV)
```

Review comment:
`NOT CV_DISABLE_OPTIMIZATION`
**File:** samples/dnn/segmentation.cpp
**Change Type:** modified
**Context:** PR #25756: [BUG FIX] Segmentation sample u2netp model results

**Code Changes:**
```diff
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
     // Open file with classes names.
     if (parser.has("classes"))
     {
-        string file = parser.get<String>("classes");
+        string file = findFile(parser.get<String>("classes"));
         ifstream ifs(file.c_str());
         if (!ifs.is_open())
             CV_Error(Error::StsError, "File " + file + " not found");
@@ -92,7 +92,7 @@ int main(int argc, char **argv)
```

Review comment:
Why do you remove the solution with overlays? It looks better, IMHO.
**File:** samples/dnn/models.yml
**Change Type:** modified
**Context:** PR #25756: [BUG FIX] Segmentation sample u2netp model results
**Review Line:** 263

**Code Changes:**
```diff
@@ -261,4 +261,4 @@ u2netp:
   width: 320
   height: 320
   rgb: true
-  sample: "segmentation"
\ No newline at end of file
+  sample: "segmentation"
```

Review comment:
It's incorrect change. I checked the rembg/bg.py sample in the model release and the model expects RGB input, but not BGR.
**File:** samples/dnn/models.yml
**Change Type:** modified
**Context:** PR #25756: [BUG FIX] Segmentation sample u2netp model results

**Code Changes:**
```diff
@@ -261,4 +261,4 @@ u2netp:
   width: 320
   height: 320
   rgb: true
-  sample: "segmentation"
\ No newline at end of file
+  sample: "segmentation"
```

Review comment:
The change looks suspicious. OpenCV subtracts mean and then divides by scale. Input image has 0..255 range.
**File:** samples/dnn/segmentation.cpp
**Change Type:** modified
**Context:** PR #25756: [BUG FIX] Segmentation sample u2netp model results

**Code Changes:**
```diff
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
     // Open file with classes names.
     if (parser.has("classes"))
     {
-        string file = parser.get<String>("classes");
+        string file = findFile(parser.get<String>("classes"));
         ifstream ifs(file.c_str());
         if (!ifs.is_open())
             CV_Error(Error::StsError, "File " + file + " not found");
@@ -92,7 +92,7 @@ int main(int argc, char **argv)
```

Review comment:
split is not needed here. You can create single channel Mat with zeros and then use it several times for merge, e.g.: ``` Mat all_zeros = Mat::zeros(frame.size(), CV_8UC1); vector<Mat> channels = {all_zeros, all_zeros, mask}; merge(channels, foreground_overlay); ```
**File:** samples/cpp/videocapture_depth.cpp
**Change Type:** added
**Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap...

**Code Changes:**
```diff
@@ -0,0 +1,174 @@
+#include "opencv2/videoio.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/imgproc.hpp"
+
+#include <iostream>
+
+using namespace cv;
+
+static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f)
```

Review comment:
I propose to rename to OpenNI-Orbbec. Current name is not obvious.
**File:** samples/cpp/videocapture_depth.cpp
**Change Type:** added
**Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap...

**Code Changes:**
```diff
@@ -0,0 +1,174 @@
+#include "opencv2/videoio.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/imgproc.hpp"
+
+#include <iostream>
+
+using namespace cv;
+
+static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f)
```

Review comment:
`-h` / `--help` is not handled.
**File:** samples/cpp/videocapture_depth.cpp
**Change Type:** added
**Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap...

**Code Changes:**
```diff
@@ -0,0 +1,174 @@
+#include "opencv2/videoio.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/imgproc.hpp"
+
+#include <iostream>
+
+using namespace cv;
+
+static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f)
```

Review comment:
Invalid pixel values are unpredictable here, because `validColorDisparityMap` is not initialized. I propose not create `validColorDisparityMap`, but call setTo with mask for for `colorDisparityMap` to mark invalid pixels with black.
**File:** samples/cpp/videocapture_depth.cpp
**Change Type:** added
**Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap...

**Code Changes:**
```diff
@@ -0,0 +1,174 @@
+#include "opencv2/videoio.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/imgproc.hpp"
+
+#include <iostream>
+
+using namespace cv;
+
+static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f)
```

Review comment:
rgb = Mat::zeros(gray.size(), CV_8UC3);
**File:** samples/cpp/videocapture_depth.cpp
**Change Type:** added
**Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap...

**Code Changes:**
```diff
@@ -0,0 +1,174 @@
+#include "opencv2/videoio.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/imgproc.hpp"
+
+#include <iostream>
+
+using namespace cv;
+
+static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f)
```

Review comment:
0 -> nullptr
**File:** samples/cpp/videocapture_depth.cpp
**Change Type:** added
**Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap...

**Code Changes:**
```diff
@@ -0,0 +1,174 @@
+#include "opencv2/videoio.hpp"
+#include "opencv2/highgui.hpp"
+#include "opencv2/imgproc.hpp"
+
+#include <iostream>
+
+using namespace cv;
+
+static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f)
```

Review comment:
It depends on camera optics and may be different. I propose to add it to command line parameters with default value and promote as function parameter here.
**File:** modules/dnn/src/layers/slice_layer.cpp
**Change Type:** modified
**Context:** PR #25861: Support for `Unflatten` operation requred by `Attention` layer - 4.x

**Code Changes:**
```diff
@@ -69,10 +69,12 @@ Range normalizeRange(const Range& input_range, int n)
 {
     Range range = input_range;
 
-    range.start = std::min(std::max(range.start, -n), n - 1);
-    if (range.start < 0)
-    {
-        range.start += n;
+    if (range.start != n){
+        range.start = std::min(std::max(range.start, -n), n - 1);
```

Review comment:
`range.start != n`
**File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #25861: Support for `Unflatten` operation requred by `Attention` layer - 4.x

**Code Changes:**
```diff
@@ -3034,6 +3034,13 @@ TEST_P(Test_ONNX_layers, Attention) {
 TEST_P(Test_ONNX_layers, AttentionSingleHead) {
     testONNXModels("attention_single_head");
 }
+TEST_P(Test_ONNX_layers, PyTorchAttentionSingleHead){
+    testONNXModels("pytorch_attention_single_head");
+}
+
+TEST_P(Test_ONNX_layers, PyTorchUnflatten){
+    testONNXModels("unflatten");
```

Review comment:
`Torch` and `PyTorch` is different. I propose to name it `PyTorchXXX`.
**File:** modules/imgcodecs/src/grfmt_jpeg.cpp
**Change Type:** modified
**Context:** PR #25809: imgcodecs: Add rgb flag for imread and imdecode
**Review Line:** 530

**Code Changes:**
```diff
+                        {
+                            if( cinfo->out_color_components == 3 )
+                                icvCvt_RGB2BGR_8u_C3R( buffer[0], 0, data, 0, Size(m_width,1) );
+                            else
+                                icvCvt_CMYK2BGR_8u_C4C3R( buffer[0], 0, data, 0, Size(m_width,1) );
+                        }
                     }
                     else
                     {
```

Review comment:
If and else branch are the same.
**File:** modules/imgcodecs/test/test_precomp.hpp
**Change Type:** modified
**Context:** PR #25809: imgcodecs: Add rgb flag for imread and imdecode

**Code Changes:**
```diff
@@ -51,6 +51,11 @@ void PrintTo(const ImreadModes& val, std::ostream* os)
         v &= ~IMREAD_IGNORE_ORIENTATION;
         *os << "IMREAD_IGNORE_ORIENTATION" << (v == 0 ? "" : " | ");
     }
+    if ((v & IMREAD_COLOR_RGB) != 0)
+    {
+        v &= ~IMREAD_COLOR_RGB;
+        *os << "IMREAD_COLOR_RGB" << (v == 0 ? "" : " | ");
+    }
     switch (v)
```

Review comment:
Assert is redundant here
**File:** modules/imgcodecs/test/test_tiff.cpp
**Change Type:** modified
**Context:** PR #25809: imgcodecs: Add rgb flag for imread and imdecode
**Review Line:** 1087

**Code Changes:**
```diff
     const string root = cvtest::TS::ptr()->get_data_path();
@@ -1066,6 +1084,7 @@ const int all_modes[] =
     IMREAD_UNCHANGED,
     IMREAD_GRAYSCALE,
     IMREAD_COLOR,
+    IMREAD_COLOR_RGB,
     IMREAD_ANYDEPTH,
     IMREAD_ANYCOLOR
 };
```

Review comment:
Tiff tests for RGB are weak. There is no test with pixels check against well known ground truth. The test compares tiff with tiff with the same flags.
**File:** modules/imgcodecs/test/test_png.cpp
**Change Type:** modified
**Context:** PR #25809: imgcodecs: Add rgb flag for imread and imdecode
**Review Line:** 93

**Code Changes:**
```diff
+    ASSERT_TRUE(img.channels() == 3);
+
+    // pixel is red in RGB
+    EXPECT_EQ(img.at<Vec3b>(0, 0), Vec3b(255, 0, 0));
+    EXPECT_EQ(img.at<Vec3b>(0, 1), Vec3b(255, 0, 0));
+
     // Fourth Test : Read PNG without alpha, imread flag 1
     img = imread(root + "readwrite/color_palette_no_alpha.png", IMREAD_COLOR);
     ASSERT_FALSE(img.empty());
@@ -91,6 +99,14 @@ TEST(Imgcodecs_Png, read_color_palette_with_alpha)
     // pixel is red in BGR
```

Review comment:
I propose to add test with RGBA output.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #25809: imgcodecs: Add rgb flag for imread and imdecode
**Review Line:** 83

**Code Changes:**
```diff
        IMREAD_REDUCED_COLOR_4      = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4.
        IMREAD_REDUCED_GRAYSCALE_8  = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8.
        IMREAD_REDUCED_COLOR_8      = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8.
-       IMREAD_IGNORE_ORIENTATION   = 128 //!< If set, do not rotate the image according to EXIF's orientation flag.
+       IMREAD_IGNORE_ORIENTATION   = 128, //!< If set, do not rotate the image according to EXIF's orientation flag.
+       IMREAD_COLOR_RGB            = 256, //!< If set, always convert image to the 3 channel RGB color image.
      };
 
 //! Imwrite flags
@@ -268,7 +270,7 @@ Currently, the following file formats are supported:
 @param filename Name of file to be loaded.
```

Review comment:
I propose to introduce `IMREAD_COLOR_BGR` as synonym for `IMREAD_COLOR`, or better `IMREAD_COLOR_BGR` is default and `IMREAD_COLOR` as synonym.
**File:** doc/tutorials/app/orbbec_astra_openni.markdown
**Change Type:** renamed
**Context:** PR #25813: Update the tutorial of using Orbbec Astra cameras

**Code Changes:**
```diff
@@ -1,4 +1,4 @@
-Using Orbbec Astra 3D cameras {#tutorial_orbbec_astra}
+Using Orbbec Astra 3D cameras {#tutorial_orbbec_astra_openni}
 ======================================================
 
 @tableofcontents
@@ -9,7 +9,7 @@ Using Orbbec Astra 3D cameras {#tutorial_orbbec_astra}
 
 ### Introduction
 
```

Review comment:
I propose to rewrite the part and point, that latest version of SDK does not work with modern Linux/ Latest known good version is published on the Orbbec forum ....
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #23613: dnn: refactor reduce

**Code Changes:**
```diff
@@ -1176,165 +1176,49 @@ void ONNXImporter::parseGlobalPool(LayerParams &layerParams, const opencv_onnx::
     addLayer(layerParams, node_proto);
 }
 
-void ONNXImporter::parseReduce(LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto_)
-{
-    opencv_onnx::NodeProto node_proto = node_proto_;
-    const std::string& layer_type = node_proto.op_type();
-    const std::string output_name = node_proto.output(0);
-    int depth = layerParams.get<int>("depth", CV_32F);
```

Review comment:
unnecessary whitespace changes which brokes indentation.
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #23613: dnn: refactor reduce

**Code Changes:**
```diff
@@ -1176,165 +1176,49 @@ void ONNXImporter::parseGlobalPool(LayerParams &layerParams, const opencv_onnx::
     addLayer(layerParams, node_proto);
 }
 
-void ONNXImporter::parseReduce(LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto_)
-{
-    opencv_onnx::NodeProto node_proto = node_proto_;
-    const std::string& layer_type = node_proto.op_type();
-    const std::string output_name = node_proto.output(0);
-    int depth = layerParams.get<int>("depth", CV_32F);
```

Review comment:
Already included by "opencv2/core/base.hpp" (available almost anywhere from the box). Please tune your IDE separately.
**File:** modules/dnn/src/onnx/onnx_graph_simplifier.cpp
**Change Type:** modified
**Context:** PR #23296: Fix identifying initializers in ONNX graph simplification

**Code Changes:**
```diff
@@ -82,7 +82,8 @@ class ONNXGraphWrapper : public ImportGraphWrapper
         for (int i = 0; i < numInitializers; ++i)
             if (net.initializer(i).name() == node_input_name)
                 return i;
-        CV_Error(Error::StsParseError, "Initializer with name " + node_input_name + " not found");
+        // CV_Error(Error::StsParseError, "Initializer with name " + node_input_name + " not found");
+        return -1;
     }
 
     Mat getMatFromInitializer(int idx)
```

Review comment:
why don't we use fabs() here? it's not a part of your patch, but this place looks strange
**File:** modules/dnn/src/onnx/onnx_graph_simplifier.cpp
**Change Type:** modified
**Context:** PR #23296: Fix identifying initializers in ONNX graph simplification

**Code Changes:**
```diff
@@ -82,7 +82,8 @@ class ONNXGraphWrapper : public ImportGraphWrapper
         for (int i = 0; i < numInitializers; ++i)
             if (net.initializer(i).name() == node_input_name)
                 return i;
-        CV_Error(Error::StsParseError, "Initializer with name " + node_input_name + " not found");
+        // CV_Error(Error::StsParseError, "Initializer with name " + node_input_name + " not found");
+        return -1;
     }
 
     Mat getMatFromInitializer(int idx)
```

Review comment:
Sure. It is fixed with the use of fabs().
**File:** modules/dnn/test/test_int.cpp
**Change Type:** modified
**Context:** PR #25755: Added more types support to dnn layers

**Code Changes:**
```diff
@@ -12,7 +12,13 @@ namespace opencv_test { namespace {
 
 int64_t getValueAt(const Mat &m, const int *indices)
 {
-    if (m.type() == CV_32S)
+    if (m.type() == CV_Bool)
+        return m.at<bool>(indices);
+    else if (m.type() == CV_8U)
+        return m.at<uint8_t>(indices);
+    else if (m.type() == CV_8S)
```

Review comment:
It's bad idea. OpenCV TS does not control seed for std::rand. You'll get different sequence subset of tests is requested by user, or test order is changed by some reason. cv::RNG::fill may be used for all branches: https://docs.opencv.org/5.x/d1/dd6/classcv_1_1RNG.html#ad26f2b09d9868cf108e84c9814aa682d
**File:** modules/dnn/src/op_cann.cpp
**Change Type:** added
**Context:** PR #22634: dnn: add the CANN backend

**Code Changes:**
```diff
@@ -0,0 +1,329 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+#include "op_cann.hpp"
+
+#include <mutex>
+#include <map>
```

Review comment:
There is a potential issue of reset the same device multiple times when we load multiple models into the deivce. Resetting a device multiple times will not trigger unexpected exit but will leave error messages in the log of CANN runtime. Possible solution: force using `device_id=0` and call `aclrtResetDevice` in `CannClient::finalize()`;
**File:** modules/dnn/CMakeLists.txt
**Change Type:** modified
**Context:** PR #22634: dnn: add the CANN backend

**Code Changes:**
```diff
@@ -31,6 +31,10 @@ if(HAVE_TIMVX)
   ocv_target_compile_definitions(${the_module} PRIVATE "HAVE_TIMVX=1")
 endif()
 
+if(HAVE_CANN)
+  ocv_target_compile_definitions(${the_module} PRIVATE "HAVE_CANN=1")
+endif()
+
 ocv_option(OPENCV_DNN_CUDA "Build with CUDA support"
     HAVE_CUDA
```

Review comment:
We should avoid using of "global" `add_definitions()`. Use `ocv_target_compile_definitions` for test targets separately (under check `if(TARGET ...)`). See the last lines of this file.
**File:** modules/dnn/CMakeLists.txt
**Change Type:** modified
**Context:** PR #22634: dnn: add the CANN backend
**Review Line:** 172

**Code Changes:**
```diff
 endif()
 
+if(HAVE_CANN)
+  list(APPEND include_dirs ${CANN_INCLUDE_DIRS})
+  list(APPEND libs -Wl,--whole-archive ${CANN_LIBRARIES} -Wl,--no-whole-archive)
+endif()
+
 set(webnn_srcs "")
 if(NOT EMSCRIPTEN)
   if(HAVE_WEBNN)
@@ -264,3 +273,10 @@ if(TARGET ocv.3rdparty.openvino AND OPENCV_TEST_DNN_OPENVINO)
```

Review comment:
Need to reuse `ocv_add_external_target()` approach for 3rdparty libraries.
**File:** modules/dnn/src/op_cann.cpp
**Change Type:** added
**Context:** PR #22634: dnn: add the CANN backend

**Code Changes:**
```diff
@@ -0,0 +1,329 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+#include "op_cann.hpp"
+
+#include <mutex>
+#include <map>
```

Review comment:
Reuse `gst_initializer` singleton approach (from videoio)
**File:** modules/dnn/src/op_cann.cpp
**Change Type:** added
**Context:** PR #22634: dnn: add the CANN backend

**Code Changes:**
```diff
@@ -0,0 +1,329 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+#include "op_cann.hpp"
+
+#include <mutex>
+#include <map>
```

Review comment:
There are two APIs for finalizing device resources: `aclFinalize()` and `ge::aclgrphBuildFinalize()`. `aclFinalize()` can be called by std::atexit or the singleton approach, but `ge::aclgrphBuildFinalize()` does work with either ways (what I mean here is if this API is called by either ways, a segmentation fault will be triggered when program ends).
**File:** modules/dnn/src/op_cann.cpp
**Change Type:** added
**Context:** PR #22634: dnn: add the CANN backend

**Code Changes:**
```diff
@@ -0,0 +1,329 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "precomp.hpp"
+#include "op_cann.hpp"
+
+#include <mutex>
+#include <map>
```

Review comment:
Done with introducing `AclEnvGuard`.
**File:** modules/dnn/CMakeLists.txt
**Change Type:** modified
**Context:** PR #22634: dnn: add the CANN backend
**Review Line:** 172

**Code Changes:**
```diff
 endif()
 
+if(HAVE_CANN)
+  list(APPEND include_dirs ${CANN_INCLUDE_DIRS})
+  list(APPEND libs -Wl,--whole-archive ${CANN_LIBRARIES} -Wl,--no-whole-archive)
+endif()
+
 set(webnn_srcs "")
 if(NOT EMSCRIPTEN)
   if(HAVE_WEBNN)
@@ -264,3 +273,10 @@ if(TARGET ocv.3rdparty.openvino AND OPENCV_TEST_DNN_OPENVINO)
```

Review comment:
How about keep it as-is since other 3rdparty libraries are still using the old approach? We can do this kind of change for all other 3rdparty libraries in a separate pr.
**File:** modules/dnn/CMakeLists.txt
**Change Type:** modified
**Context:** PR #22634: dnn: add the CANN backend
**Review Line:** 172

**Code Changes:**
```diff
 endif()
 
+if(HAVE_CANN)
+  list(APPEND include_dirs ${CANN_INCLUDE_DIRS})
+  list(APPEND libs -Wl,--whole-archive ${CANN_LIBRARIES} -Wl,--no-whole-archive)
+endif()
+
 set(webnn_srcs "")
 if(NOT EMSCRIPTEN)
   if(HAVE_WEBNN)
@@ -264,3 +273,10 @@ if(TARGET ocv.3rdparty.openvino AND OPENCV_TEST_DNN_OPENVINO)
```

Review comment:
Do we still need this? (as there is `ocv.3rdparty.cann` usage below)
**File:** modules/dnn/src/layer.cpp
**Change Type:** modified
**Context:** PR #22634: dnn: add the CANN backend
**Review Line:** 90

**Code Changes:**
```diff
 }
 
+Ptr<BackendNode> Layer::initCann(const std::vector<Ptr<BackendWrapper> > &inputsWrapper, const int index, const std::vector<Ptr<BackendNode> >& nodes)
+{
+    CV_Error(Error::StsNotImplemented, "CANN pipeline of " + type + " layers is not defined.");
+    return Ptr<BackendNode>();
+}
+
 Ptr<BackendNode> Layer::tryAttach(const Ptr<BackendNode>& node)
 {
     return Ptr<BackendNode>();
```

Review comment:
> `return Ptr<BackendNode>();` unreachable code
**File:** modules/dnn/CMakeLists.txt
**Change Type:** modified
**Context:** PR #22634: dnn: add the CANN backend
**Review Line:** 172

**Code Changes:**
```diff
 endif()
 
+if(HAVE_CANN)
+  list(APPEND include_dirs ${CANN_INCLUDE_DIRS})
+  list(APPEND libs -Wl,--whole-archive ${CANN_LIBRARIES} -Wl,--no-whole-archive)
+endif()
+
 set(webnn_srcs "")
 if(NOT EMSCRIPTEN)
   if(HAVE_WEBNN)
@@ -264,3 +273,10 @@ if(TARGET ocv.3rdparty.openvino AND OPENCV_TEST_DNN_OPENVINO)
```

Review comment:
Yes, we do. `ocv.3rdparty.cann` is used to link for `opencv_test_dnn` only for now.