nareshmlx/opencv-pr huggingface dataset:
**File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #26170: 5.x merge 4.x - OpenCV Extra: https://github.com/opencv/opencv_extra/pull/1210 Contrib: https://github.com/opencv/opencv_contrib/pull/3795 ...
**Review Line:** 397

**Code Changes:**
```diff
   ocv_update(CPU_KNOWN_OPTIMIZATIONS "MSA")
   ocv_update(CPU_MSA_FLAGS_ON "-mmsa")
   set(CPU_BASELINE "DETECT" CACHE STRING "${HELP_CPU_BASELINE}")
+
 elseif(PPC64LE)
+
   ocv_update(CPU_KNOWN_OPTIMIZATIONS "VSX;VSX3")
   ocv_update(CPU_VSX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_vsx.cpp")
   ocv_update(CPU_VSX3_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_vsx3.cpp")
@@ -390,9 +415,6 @@ elseif(PPC64LE)
   set(CPU_BASELINE "VSX" CACHE STRING "${HELP_CPU_BASELINE}")
```

Review comment:
We need to keep FP16 and RVV_ZVFH in the list of known optimizations (line 55, line 397) as well as TEST_FILE, IMPLIES, FLAGS_ON variables (lines 399-407). I'll adapt flags-riscv64.cmake accordingly after the merge.
**File:** cmake/OpenCVCompilerOptimizations.cmake
**Change Type:** modified
**Context:** PR #26170: 5.x merge 4.x - OpenCV Extra: https://github.com/opencv/opencv_extra/pull/1210 Contrib: https://github.com/opencv/opencv_contrib/pull/3795 ...
**Review Line:** 397

**Code Changes:**
```diff
   ocv_update(CPU_KNOWN_OPTIMIZATIONS "MSA")
   ocv_update(CPU_MSA_FLAGS_ON "-mmsa")
   set(CPU_BASELINE "DETECT" CACHE STRING "${HELP_CPU_BASELINE}")
+
 elseif(PPC64LE)
+
   ocv_update(CPU_KNOWN_OPTIMIZATIONS "VSX;VSX3")
   ocv_update(CPU_VSX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_vsx.cpp")
   ocv_update(CPU_VSX3_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_vsx3.cpp")
@@ -390,9 +415,6 @@ elseif(PPC64LE)
   set(CPU_BASELINE "VSX" CACHE STRING "${HELP_CPU_BASELINE}")
```

Review comment:
Lines 55 and 399-407 should also be reverted.
**File:** modules/core/include/opencv2/core/cvdef.h
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...
**Review Line:** 972

**Code Changes:**
```diff
@@ -968,6 +968,9 @@ CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4)
     return (c1 & 255) + ((c2 & 255) << 8) + ((c3 & 255) << 16) + ((c4 & 255) << 24);
 }
 
+//! Macro to construct the fourcc code of the codec. Same as CV_FOURCC()
+#define CV_FOURCC_MACRO(c1, c2, c3, c4) (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24))
+
 //! @}
 
 #ifndef __cplusplus
```

Review comment:
May be move it to videoio.hpp as inline function (which could be exported to bindings) BTW, there is VideoWriter::fourcc (it is confusing because it is used outside of that). So global function is preferable.
**File:** modules/videoio/src/container_avi.cpp
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...

**Code Changes:**
```diff
@@ -2,8 +2,8 @@
 // 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 "opencv2/videoio/container_avi.private.hpp"
-#include <opencv2/core/utils/logger.hpp>
 #include <fstream>
 #include <limits>
 #include <typeinfo>
```

Review comment:
lets put `precomp.hpp` first
**File:** modules/core/include/opencv2/core/cvdef.h
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...
**Review Line:** 972

**Code Changes:**
```diff
@@ -968,6 +968,9 @@ CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4)
     return (c1 & 255) + ((c2 & 255) << 8) + ((c3 & 255) << 16) + ((c4 & 255) << 24);
 }
 
+//! Macro to construct the fourcc code of the codec. Same as CV_FOURCC()
+#define CV_FOURCC_MACRO(c1, c2, c3, c4) (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24))
+
 //! @}
 
 #ifndef __cplusplus
```

Review comment:
There is `CV_FOURCC` inline function above (used in ~70 places). Do you mean move it too? It is used in _imgproc_ for font rendering params. Perhaps we can remove `CV_FOURCC_MACRO` completely, I didn't do it to reduce total changes, because it is used in ~50 places. `VideoWriter::fourcc` is used in ~50 places too.
**File:** modules/core/include/opencv2/core/cvdef.h
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...
**Review Line:** 972

**Code Changes:**
```diff
@@ -968,6 +968,9 @@ CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4)
     return (c1 & 255) + ((c2 & 255) << 8) + ((c3 & 255) << 16) + ((c4 & 255) << 24);
 }
 
+//! Macro to construct the fourcc code of the codec. Same as CV_FOURCC()
+#define CV_FOURCC_MACRO(c1, c2, c3, c4) (((c1) & 255) + (((c2) & 255) << 8) + (((c3) & 255) << 16) + (((c4) & 255) << 24))
+
 //! @}
 
 #ifndef __cplusplus
```

Review comment:
That is a mess. Lets revise fourcc through a separate task then.
**File:** modules/videoio/src/cap_ximea.cpp
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...

**Code Changes:**
```diff
@@ -8,31 +8,33 @@
 #endif
 
 using namespace std;
+using namespace cv;
 
 /**********************************************************************************/
 
-class CvCaptureCAM_XIMEA : public CvCapture
+class CvCaptureCAM_XIMEA : public IVideoCapture
```

Review comment:
.create() could be used instead. Here and several places bellow.
**File:** modules/videoio/src/precomp.hpp
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...
**Review Line:** 58

**Code Changes:**
```diff
@@ -55,7 +55,6 @@
 
 
 #include "opencv2/videoio.hpp"
-#include "opencv2/videoio/legacy/constants_c.h"
 
 #include "opencv2/core/utility.hpp"
 #ifdef __OPENCV_BUILD
@@ -74,7 +73,6 @@
 #include "opencv2/imgcodecs.hpp"
 
```

Review comment:
m.b. removed.
**File:** modules/videoio/misc/gen_dict.json
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...

**Code Changes:**
```diff
@@ -1,9 +1,7 @@
 {
     "const_ignore_list": [
         "CV_CAP_OPENNI2",
-        "CV_CAP_PROP_OPENNI_",
         "CV_CAP_INTELPERC",
-        "CV_CAP_PROP_INTELPERC_",
         "CV_CAP_ANY",
         "CV_CAP_MIL",
         "CV_CAP_V4L",
```

Review comment:
it should be removed too, right?
**File:** modules/videoio/src/cap_avfoundation.mm
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...
**Review Line:** 189

**Code Changes:**
```diff
                 int is_color=1);
         ~CvVideoWriter_AVFoundation();
-        bool writeFrame(const IplImage* image) CV_OVERRIDE;
+        bool isOpened() const CV_OVERRIDE { return mMovieWriter != NULL && mMovieWriter.status != AVAssetWriterStatusFailed; }
+        void write(cv::InputArray image) CV_OVERRIDE;
         int getCaptureDomain() const CV_OVERRIDE { return cv::CAP_AVFOUNDATION; }
     private:
-        IplImage* argbimage;
+        cv::Mat argbimage;
 
         AVAssetWriter *mMovieWriter;
```

Review comment:
`const cv::Size& `?
**File:** modules/highgui/src/window_QT.cpp
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...

**Code Changes:**
```diff
@@ -138,12 +138,11 @@ void cv::addText( const Mat& img, const String& text, Point org, const QtFont& f
     if (!guiMainThread)
         CV_Error( cv::Error::StsNullPtr, "NULL guiReceiver (please create a window)" );
 
-    CvMat _img = cvMat(img);
     QMetaObject::invokeMethod(
         guiMainThread,
         "putText",
         autoBlockingConnection(),
-        Q_ARG(void*, (void*)&_img),
```

Review comment:
`cv::Mat& mat`?
**File:** modules/highgui/src/window_QT.cpp
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...

**Code Changes:**
```diff
@@ -138,12 +138,11 @@ void cv::addText( const Mat& img, const String& text, Point org, const QtFont& f
     if (!guiMainThread)
         CV_Error( cv::Error::StsNullPtr, "NULL guiReceiver (please create a window)" );
 
-    CvMat _img = cvMat(img);
     QMetaObject::invokeMethod(
         guiMainThread,
         "putText",
         autoBlockingConnection(),
-        Q_ARG(void*, (void*)&_img),
```

Review comment:
It should release automatically, right?
**File:** modules/highgui/src/window_QT.cpp
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...

**Code Changes:**
```diff
@@ -138,12 +138,11 @@ void cv::addText( const Mat& img, const String& text, Point org, const QtFont& f
     if (!guiMainThread)
         CV_Error( cv::Error::StsNullPtr, "NULL guiReceiver (please create a window)" );
 
-    CvMat _img = cvMat(img);
     QMetaObject::invokeMethod(
         guiMainThread,
         "putText",
         autoBlockingConnection(),
-        Q_ARG(void*, (void*)&_img),
```

Review comment:
The same. Release is not needed.
**File:** modules/highgui/src/window_gtk.cpp
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...
**Review Line:** 359

**Code Changes:**
```diff
+        image_widget->scaled_image.release();
     }
-    if( !image_widget->scaled_image ){
-        image_widget->scaled_image = cvCreateMat( scaled_image_size.height, scaled_image_size.width, CV_8UC3 );
+    if( image_widget->scaled_image.empty() ){
+        image_widget->scaled_image.create(scaled_image_size.height, scaled_image_size.width, CV_8UC3);
 
 
     }
-    CV_Assert(image_widget->scaled_image);
+    CV_Assert(!image_widget->scaled_image.empty());
```

Review comment:
Release not needed.
**File:** modules/videoio/src/cap_gstreamer.cpp
**Change Type:** modified
**Context:** PR #26025: C-API cleanup: highgui, videoio - :exclamation: Potential conflicts with #25958 :exclamation: Merge with: opencv/opencv_contrib#3780 This P...

**Code Changes:**
```diff
@@ -287,10 +287,10 @@ std::string get_gst_propname(int propId)
 {
     switch (propId)
     {
-    case CV_CAP_PROP_BRIGHTNESS: return "brightness";
-    case CV_CAP_PROP_CONTRAST: return "contrast";
-    case CV_CAP_PROP_SATURATION: return "saturation";
-    case CV_CAP_PROP_HUE: return "hue";
+    case CAP_PROP_BRIGHTNESS: return "brightness";
+    case CAP_PROP_CONTRAST: return "contrast";
```

Review comment:
I propose to refresh warning messages here and bellow. `cvWriteFrame` does not exist anymore.
**File:** modules/core/perf/opencl/perf_arithm.cpp
**Change Type:** modified
**Context:** PR #26115: Added more data types to OCL flip() and rotate() perf tests
**Review Line:** 361

**Code Changes:**
```diff
 
 OCL_PERF_TEST_P(FlipFixture, Flip,
             ::testing::Combine(OCL_TEST_SIZES,
-                               OCL_TEST_TYPES, FlipType::all()))
+                               ::testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_32FC1, CV_32FC4),
+                               FlipType::all()))
 {
     const FlipParams params = GetParam();
     const Size srcSize = get<0>(params);
@@ -387,7 +388,9 @@ typedef tuple<Size, MatType, RotateType> RotateParams;
 typedef TestBaseWithParam<RotateParams> RotateFixture;
```

Review comment:
You can use `OCL_TEST_TYPES + ::testing::Values(CV_16UC1)` for the both cases.
**File:** modules/core/perf/opencl/perf_arithm.cpp
**Change Type:** modified
**Context:** PR #26115: Added more data types to OCL flip() and rotate() perf tests
**Review Line:** 361

**Code Changes:**
```diff
 
 OCL_PERF_TEST_P(FlipFixture, Flip,
             ::testing::Combine(OCL_TEST_SIZES,
-                               OCL_TEST_TYPES, FlipType::all()))
+                               ::testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_16UC1, CV_32FC1, CV_32FC4),
+                               FlipType::all()))
 {
     const FlipParams params = GetParam();
     const Size srcSize = get<0>(params);
@@ -387,7 +388,9 @@ typedef tuple<Size, MatType, RotateType> RotateParams;
 typedef TestBaseWithParam<RotateParams> RotateFixture;
```

Review comment:
Looks like it does not work in performance tests - implemented for accuracy tests only?
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+#include <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "../ie_ngraph.hpp"
+
+namespace cv
+{
+namespace dnn
```

Review comment:
cv::Mat::zeros()
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+#include <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "../ie_ngraph.hpp"
+
+namespace cv
+{
+namespace dnn
```

Review comment:
Call `parallel_for_` on the outer loop for performance.
**File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #26079: Add Support for Hardmax Layer

**Code Changes:**
```diff
@@ -197,6 +197,7 @@ class ONNXImporter
     void parseLayerNorm            (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseSimpleLayers         (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseEinsum               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
+    void parseHardmax              (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
 
     // Domain: com.microsoft
     // URL: https://github.com/microsoft/onnxruntime/blob/master/docs/ContribOperators.md
@@ -3190,6 +3191,12 @@ void ONNXImporter::parseSimpleLayers(LayerParams& layerParams, const opencv_onnx
     addLayer(layerParams, node_proto);
```

Review comment:
Dont preprocess axis during importing stage, since we are going to support dynamic shape and shape can be unknown during importing. --- You already called `normalize_axis` in `forward()`. So safe to drop this code.
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+#include <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "../ie_ngraph.hpp"
+
+namespace cv
+{
+namespace dnn
```

Review comment:
FP32 -> FP16 will cause invalid max operation.
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+#include <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "../ie_ngraph.hpp"
+
+namespace cv
+{
+namespace dnn
```

Review comment:
It creates a new memory. You should call `memset` on the pointer of dst to set all zero.
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+#include <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "../ie_ngraph.hpp"
+
+namespace cv
+{
+namespace dnn
```

Review comment:
Returning `true` here stands for input and output can be a shared memory, which is not valid for calling `memset` on dst (because it also sets the input zero). So return `false` here.
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+#include <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "../ie_ngraph.hpp"
+
+namespace cv
+{
+namespace dnn
```

Review comment:
Looks like openvino does not have hardmax. See https://docs.openvino.ai/2024/documentation/openvino-ir-format/operation-sets/available-opsets/opset14.html.
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+#include <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "../ie_ngraph.hpp"
+
+namespace cv
+{
+namespace dnn
```

Review comment:
Add `nstripes` behind the lambda function. It equals to total number of loops divided by a constant, e.g. `outer_size * inner_size * (1 / 1024.0)`.
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+#include <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "../ie_ngraph.hpp"
+
+namespace cv
+{
+namespace dnn
```

Review comment:
`src.ptr<const T>`
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+#include <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "../ie_ngraph.hpp"
+
+namespace cv
+{
+namespace dnn
```

Review comment:
where does `(1/1024.0)` or `1024.0` constant comes from? Just want to understand for myself.
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+#include <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "../ie_ngraph.hpp"
+
+namespace cv
+{
+namespace dnn
```

Review comment:
I learned it from other folks. They said that it is empirical. You could tune it if performance is critical. My understanding is that I want each worker takes care of 1024 times of loops, and there I need `total_loops / 1024` workers in total from the thread pool.
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer
**Review Line:** 77

**Code Changes:**
```diff
+
+        axis = normalize_axis(axis, src.dims);
+        MatShape shape(src.size.p, src.size.p + src.dims);
+
+        // Prepare output
+        memset(dst.ptr(), 0, dst.total() * dst.elemSize());
+
+        switch (src.depth())
+        {
+            case CV_8U: hardmaxApply<uchar>(src, dst, axis); break;
+            case CV_8S: hardmaxApply<schar>(src, dst, axis); break;
```

Review comment:
The change looks redundant. `dst` may be mot contiguous.
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer
**Review Line:** 77

**Code Changes:**
```diff
+
+        axis = normalize_axis(axis, src.dims);
+        MatShape shape(src.size.p, src.size.p + src.dims);
+
+        // Prepare output
+        memset(dst.ptr(), 0, dst.total() * dst.elemSize());
+
+        switch (src.depth())
+        {
+            case CV_8U: hardmaxApply<uchar>(src, dst, axis); break;
+            case CV_8S: hardmaxApply<schar>(src, dst, axis); break;
```

Review comment:
> dst may be mot contiguous. Theoretically it is but I assume it is quite rare in dnn use cases. But anyway, zero can be set inside the loop.
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer
**Review Line:** 77

**Code Changes:**
```diff
+
+        axis = normalize_axis(axis, src.dims);
+        MatShape shape(src.size.p, src.size.p + src.dims);
+
+        // Prepare output
+        memset(dst.ptr(), 0, dst.total() * dst.elemSize());
+
+        switch (src.depth())
+        {
+            case CV_8U: hardmaxApply<uchar>(src, dst, axis); break;
+            case CV_8S: hardmaxApply<schar>(src, dst, axis); break;
```

Review comment:
lets use ::zeros or at least add contigous check.
**File:** modules/dnn/src/layers/harmax.cpp
**Change Type:** added
**Context:** PR #26079: Add Support for Hardmax Layer
**Review Line:** 1

**Code Changes:**
```diff
@@ -0,0 +1,140 @@
+#include <inttypes.h>
+#include <opencv2/dnn/shape_utils.hpp>
+#include "../precomp.hpp"
+#include "layers_common.hpp"
+#include "../ie_ngraph.hpp"
+
```

Review comment:
Just found that filename is wrong, it should be `hardmax_layer.cpp`.
**File:** samples/dnn/edge_detection.cpp
**Change Type:** added
**Context:** PR #25515: Improved edge detection sample

**Code Changes:**
```diff
@@ -0,0 +1,242 @@
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+#include <iostream>
+#include <string>
+#include <cmath>
+#include <vector>
+
+#include "common.hpp"
```

Review comment:
use cv::normalize() with NORM_MINMAX
**File:** samples/dnn/edge_detection.cpp
**Change Type:** added
**Context:** PR #25515: Improved edge detection sample

**Code Changes:**
```diff
@@ -0,0 +1,242 @@
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+#include <iostream>
+#include <string>
+#include <cmath>
+#include <vector>
+
+#include "common.hpp"
```

Review comment:
remove unnecessary whitespaces
**File:** samples/dnn/edge_detection.cpp
**Change Type:** added
**Context:** PR #25515: Improved edge detection sample

**Code Changes:**
```diff
@@ -0,0 +1,242 @@
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+#include <iostream>
+#include <string>
+#include <cmath>
+#include <vector>
+
+#include "common.hpp"
```

Review comment:
it would be really nice to be able to switch between Canny and deep learning-based modes with a key
**File:** samples/dnn/edge_detection.cpp
**Change Type:** added
**Context:** PR #25515: Improved edge detection sample

**Code Changes:**
```diff
@@ -0,0 +1,242 @@
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+#include <iostream>
+#include <string>
+#include <cmath>
+#include <vector>
+
+#include "common.hpp"
```

Review comment:
It should not happen on each iteration, but once before the loop.
**File:** samples/dnn/edge_detection.cpp
**Change Type:** added
**Context:** PR #25515: Improved edge detection sample

**Code Changes:**
```diff
@@ -0,0 +1,242 @@
+#include <opencv2/dnn.hpp>
+#include <opencv2/imgproc.hpp>
+#include <opencv2/highgui.hpp>
+#include <iostream>
+#include <string>
+#include <cmath>
+#include <vector>
+
+#include "common.hpp"
```

Review comment:
Let's use Canny by default, if model is not provided. Also I propose to handle the case in run-time, e.g. show warning, but not fail.
**File:** samples/dnn/custom_layer.py
**Change Type:** added
**Context:** PR #25515: Improved edge detection sample
**Review Line:** 1

**Code Changes:**
```diff
@@ -0,0 +1,31 @@
+import cv2 as cv
+
+#! [CropLayer]
+class CropLayer(object):
+    def __init__(self, params, blobs):
+        self.xstart = 0
```

Review comment:
The new approach destroys original sample with custom layer. Formally, all code blocks are there, but the sample does not create Net and does not use the new layer.