instruction stringclasses 9 values | input stringlengths 279 5.47k | output stringlengths 6 9.58k |
|---|---|---|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/gatherND.cpp
**Change Type:** added
**Context:** PR #26106: Support for GatherND layer
**Review Line:** 71
**Code Changes:**
```diff
+ MatShape output_shape;
+ output_shape.reserve(q - 1 + r - batch_dims - last_indices_dim);
+ for (int i = 0; i < q - 1; ++i)
+ output_shape.push_back(indices[i]);
+ for (int i = batch_dims + last_indices_dim; i < r; ++i)
+ output_shape.push_back(data[i]);
+
+ outputs.assign(1, output_shape);
+ return false;
+ }
+
``` | makes sense to use `output_shape.reserve()` before the loops. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/gatherND.cpp
**Change Type:** added
**Context:** PR #26106: Support for GatherND layer
**Code Changes:**
```diff
@@ -0,0 +1,185 @@
+#include "../precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
+class GatherNDLayerImpl CV_FINAL : public GatherNDLayer
+{
+public:
+ GatherNDLayerImpl(const LayerParams& params)
``` | please add default branch with assert. It might be useful for debugging, |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/gatherND.cpp
**Change Type:** added
**Context:** PR #26106: Support for GatherND layer
**Review Line:** 126
**Code Changes:**
```diff
+ }
+
+ template <typename iT, typename dT>
+ void forward_impl(const Mat& data, const Mat& indices, Mat& out)
+ {
+ CV_Assert(out.isContinuous());
+ CV_Assert(indices.isContinuous());
+ CV_Assert(data.isContinuous());
+
+
+ const iT* indices_ptr = indices.ptr<iT>();
``` | check also indices and data |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/gatherND.cpp
**Change Type:** added
**Context:** PR #26106: Support for GatherND layer
**Code Changes:**
```diff
@@ -0,0 +1,185 @@
+#include "../precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
+class GatherNDLayerImpl CV_FINAL : public GatherNDLayer
+{
+public:
+ GatherNDLayerImpl(const LayerParams& params)
``` | you do not need vector here. just: ``` int* sliced_indices = indices_ptr + i * last_indices_dim; ``` |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/gatherND.cpp
**Change Type:** added
**Context:** PR #26106: Support for GatherND layer
**Code Changes:**
```diff
@@ -0,0 +1,185 @@
+#include "../precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
+class GatherNDLayerImpl CV_FINAL : public GatherNDLayer
+{
+public:
+ GatherNDLayerImpl(const LayerParams& params)
``` | `break` is missing: ``` 2024-09-03T16:01:13.0386984Z /home/ci/opencv/modules/dnn/src/layers/gatherND.cpp:95:17: warning: this statement may fall through [-Wimplicit-fallthrough=] 2024-09-03T16:01:13.0388547Z 95 | switch (dtype) { 2024-09-03T16:01:13.0389213Z | ^~~~~~ 2024-09-03T16:01:13.0390112Z /home/ci/opencv/modules/dnn/src/layers/gatherND.cpp:105:13: note: here 2024-09-03T16:01:13.0391087Z 105 | case CV_64S: 2024-09-03T16:01:13.0391668Z | ^~~~ ``` |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/gatherND.cpp
**Change Type:** added
**Context:** PR #26106: Support for GatherND layer
**Code Changes:**
```diff
@@ -0,0 +1,185 @@
+#include "../precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
+class GatherNDLayerImpl CV_FINAL : public GatherNDLayer
+{
+public:
+ GatherNDLayerImpl(const LayerParams& params)
``` | ``` /home/ci/opencv/modules/dnn/src/layers/gatherND.cpp:99:56: error: 'float16_t' was not declared in this scope; did you mean 'float_t'? 2024-09-03T15:59:18.3161177Z 99 | case CV_16F: forward_impl<int32_t, float16_t>(data, indices, out); break; ``` |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/gatherND.cpp
**Change Type:** added
**Context:** PR #26106: Support for GatherND layer
**Code Changes:**
```diff
@@ -0,0 +1,185 @@
+#include "../precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
+class GatherNDLayerImpl CV_FINAL : public GatherNDLayer
+{
+public:
+ GatherNDLayerImpl(const LayerParams& params)
``` | I propose to use s16 branch for `CV_16F` case to be hardware independent. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #26106: Support for GatherND layer
**Review Line:** 3217
**Code Changes:**
```diff
// URL: https://github.com/microsoft/onnxruntime/blob/master/docs/ContribOperators.md
@@ -3213,6 +3214,15 @@ void ONNXImporter::parseHardmax(LayerParams& layerParams, const opencv_onnx::Nod
addLayer(layerParams, node_proto);
}
+void ONNXImporter::parseGatherND(LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto)
+{
+ CV_Assert(node_proto.input_size() == 2);
+ layerParams.type = "GatherND";
+ int batch_dims = layerParams.get<int>("batch_dims", 0);
+ layerParams.set("batch_dims", batch_dims);
``` | Looks like you can simply use `parseSimpleLayers` to parse `GatherND` since it does not take extra operations. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/gatherND.cpp
**Change Type:** added
**Context:** PR #26106: Support for GatherND layer
**Code Changes:**
```diff
@@ -0,0 +1,185 @@
+#include "../precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
+class GatherNDLayerImpl CV_FINAL : public GatherNDLayer
+{
+public:
+ GatherNDLayerImpl(const LayerParams& params)
``` | int16_t is better here to ensure size. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/onnx/onnx_importer.cpp
**Change Type:** modified
**Context:** PR #26106: Support for GatherND layer
**Review Line:** 3217
**Code Changes:**
```diff
// URL: https://github.com/microsoft/onnxruntime/blob/master/docs/ContribOperators.md
@@ -3213,6 +3214,15 @@ void ONNXImporter::parseHardmax(LayerParams& layerParams, const opencv_onnx::Nod
addLayer(layerParams, node_proto);
}
+void ONNXImporter::parseGatherND(LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto)
+{
+ CV_Assert(node_proto.input_size() == 2);
+ layerParams.type = "GatherND";
+ int batch_dims = layerParams.get<int>("batch_dims", 0);
+ layerParams.set("batch_dims", batch_dims);
``` | I propose to leave this as it is, for new parser it makes sence |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/gatherND.cpp
**Change Type:** added
**Context:** PR #26106: Support for GatherND layer
**Code Changes:**
```diff
@@ -0,0 +1,185 @@
+#include "../precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
+class GatherNDLayerImpl CV_FINAL : public GatherNDLayer
+{
+public:
+ GatherNDLayerImpl(const LayerParams& params)
``` | This leads to crush during build time |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/gatherND.cpp
**Change Type:** added
**Context:** PR #26106: Support for GatherND layer
**Code Changes:**
```diff
@@ -0,0 +1,185 @@
+#include "../precomp.hpp"
+#include <opencv2/dnn/shape_utils.hpp>
+
+namespace cv { namespace dnn {
+
+class GatherNDLayerImpl CV_FINAL : public GatherNDLayer
+{
+public:
+ GatherNDLayerImpl(const LayerParams& params)
``` | I just pushed fix. `indices_ptr` has template type `iT*` and `sliced_indices` should. It's not always `int`. The solution with vector just hides the problem. |
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #25326: Improved and refactored text detection sample in dnn module
**Code Changes:**
```diff
@@ -1,21 +1,28 @@
/*
- Text detection model: https://github.com/argman/EAST
- Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
+ Text detection model (EAST): https://github.com/argman/EAST
+ Download link for EAST model: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
- Text recognition models can be downloaded directly here:
+ DB detector model:
+ https://drive.google.com/uc?export=download&id=17_ABp79PlFt9yPCxSaarVc_DKTmrSGGf
``` | Not necessary comment |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #25326: Improved and refactored text detection sample in dnn module
**Code Changes:**
```diff
@@ -1,21 +1,28 @@
/*
- Text detection model: https://github.com/argman/EAST
- Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
+ Text detection model (EAST): https://github.com/argman/EAST
+ Download link for EAST model: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
- Text recognition models can be downloaded directly here:
+ DB detector model:
+ https://drive.google.com/uc?export=download&id=17_ABp79PlFt9yPCxSaarVc_DKTmrSGGf
``` | The only generic parameter is `Size(width, height)`. Please update `TextDetectionModel_EAST_Impl` constructor with the rest of preprocessing options so in sample you just need to call `detector.setInputSize()` https://github.com/opencv/opencv/blob/f2c3d4dfe3843898d969a45e43d981e8af967bd5/modules/dnn/src/model.cpp#L1115 |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #25326: Improved and refactored text detection sample in dnn module
**Code Changes:**
```diff
@@ -1,21 +1,28 @@
/*
- Text detection model: https://github.com/argman/EAST
- Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
+ Text detection model (EAST): https://github.com/argman/EAST
+ Download link for EAST model: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
- Text recognition models can be downloaded directly here:
+ DB detector model:
+ https://drive.google.com/uc?export=download&id=17_ABp79PlFt9yPCxSaarVc_DKTmrSGGf
``` | Same request as for EAST. Let's move magic constants to `TextDetectionModel_DB` constructor |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #25326: Improved and refactored text detection sample in dnn module
**Code Changes:**
```diff
@@ -1,21 +1,28 @@
/*
- Text detection model: https://github.com/argman/EAST
- Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
+ Text detection model (EAST): https://github.com/argman/EAST
+ Download link for EAST model: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
- Text recognition models can be downloaded directly here:
+ DB detector model:
+ https://drive.google.com/uc?export=download&id=17_ABp79PlFt9yPCxSaarVc_DKTmrSGGf
``` | Why `frame2` is required? |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/models.yml
**Change Type:** modified
**Context:** PR #25326: Improved and refactored text detection sample in dnn module
**Review Line:** 312
**Code Changes:**
```diff
+ width: 736
+ height: 736
+ rgb: false
+ sample: "text_detection"
+
+East:
+ load_info:
+ url: "https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1"
+ sha1: "fffabf5ac36f37bddf68e34e84b45f5c4247ed06"
+ download_name: "frozen_east_text_detection.tar.gz"
+ download_sha: "3ca8233d6edd748f7ed23246c8ca24cbf696bb94"
``` | Exception: Hash mismatch: expected fffabf5ac36f37bddf68e34e84b45f5c4247ed06 vs actual of 3ca8233d6edd748f7ed23246c8ca24cbf696bb94 |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/text_detection.cpp
**Change Type:** modified
**Context:** PR #25326: Improved and refactored text detection sample in dnn module
**Code Changes:**
```diff
@@ -1,21 +1,28 @@
/*
- Text detection model: https://github.com/argman/EAST
- Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
+ Text detection model (EAST): https://github.com/argman/EAST
+ Download link for EAST model: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
- Text recognition models can be downloaded directly here:
+ DB detector model:
+ https://drive.google.com/uc?export=download&id=17_ABp79PlFt9yPCxSaarVc_DKTmrSGGf
``` | There is imageTextR.png, ImageTextN.png with text left.jpg, box_in_scene.png with book covers. They are better candidates for test image. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/text_detection.py
**Change Type:** modified
**Context:** PR #25326: Improved and refactored text detection sample in dnn module
**Code Changes:**
```diff
@@ -1,55 +1,82 @@
'''
- Text detection model: https://github.com/argman/EAST
- Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
+ Text detection model (EAST): https://github.com/argman/EAST
+ Download link for EAST model: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
- CRNN Text recognition model taken from here: https://github.com/meijieru/crnn.pytorch
- How to convert from pb to onnx:
- Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
``` | There is no model option in command line params |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/text_detection.py
**Change Type:** modified
**Context:** PR #25326: Improved and refactored text detection sample in dnn module
**Review Line:** 119
**Code Changes:**
```diff
+ stdImgSize = 512
+ imgWidth = min(frame.shape[:2])
+ fontSize = (stdSize*imgWidth)/stdImgSize
+ fontThickness = max(1,(stdWeight*imgWidth)//stdImgSize)
+
+ if(args.alias == "DB"):
+ # DB Detector initialization
+ detector = cv2.dnn_TextDetectionModel_DB(args.model)
+ detector.setBinaryThreshold(args.binary_threshold)
+ detector.setPolygonThreshold(args.polygon_threshold)
+ detector.setUnclipRatio(args.unclip_ratio)
``` | There is no alias option in command line params |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **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}")
``` | 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. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **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}")
``` | Lines 55 and 399-407 should also be reverted. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **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
``` | 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. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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>
``` | lets put `precomp.hpp` first |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **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
``` | 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. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **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
``` | That is a mess. Lets revise fourcc through a separate task then. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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
``` | .create() could be used instead. Here and several places bellow. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **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"
``` | m.b. removed. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **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",
``` | it should be removed too, right? |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **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;
``` | `const cv::Size& `? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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),
``` | `cv::Mat& mat`? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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),
``` | It should release automatically, right? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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),
``` | The same. Release is not needed. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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());
``` | Release not needed. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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";
``` | I propose to refresh warning messages here and bellow. `cvWriteFrame` does not exist anymore. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **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;
``` | You can use `OCL_TEST_TYPES + ::testing::Values(CV_16UC1)` for the both cases. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **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;
``` | Looks like it does not work in performance tests - implemented for accuracy tests only? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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
``` | cv::Mat::zeros() |
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback. | **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
``` | Call `parallel_for_` on the outer loop for performance. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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);
``` | 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. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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
``` | FP32 -> FP16 will cause invalid max operation. |
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback. | **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
``` | It creates a new memory. You should call `memset` on the pointer of dst to set all zero. |
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback. | **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
``` | 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. |
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback. | **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
``` | Looks like openvino does not have hardmax. See https://docs.openvino.ai/2024/documentation/openvino-ir-format/operation-sets/available-opsets/opset14.html. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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
``` | 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)`. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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
``` | `src.ptr<const T>` |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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
``` | where does `(1/1024.0)` or `1024.0` constant comes from? Just want to understand for myself. |
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback. | **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
``` | 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. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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;
``` | The change looks redundant. `dst` may be mot contiguous. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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;
``` | > 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. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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;
``` | lets use ::zeros or at least add contigous check. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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"
+
``` | Just found that filename is wrong, it should be `hardmax_layer.cpp`. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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"
``` | use cv::normalize() with NORM_MINMAX |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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"
``` | remove unnecessary whitespaces |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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"
``` | it would be really nice to be able to switch between Canny and deep learning-based modes with a key |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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"
``` | It should not happen on each iteration, but once before the loop. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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"
``` | 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. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **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
``` | 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. |
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #25515: Improved edge detection sample
**Code Changes:**
```diff
@@ -1885,7 +1885,7 @@ CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth,
//! @addtogroup imgproc_feature
//! @{
-/** @example samples/cpp/edge.cpp
+/** @example samples/cpp/snippets/edge.cpp
This program demonstrates usage of the Canny edge detector
Check @ref tutorial_canny_detector "the corresponding tutorial" for more details
``` | We still need simplified API usage example. Code with 200+ lines are just not suitable for initial leaning steps. We need 2 kind of "samples": - simplified API usage example (e.g. move to part of documentation - tutorial_code) - large "task solution" "demos" |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #25515: Improved edge detection sample
**Code Changes:**
```diff
@@ -1885,7 +1885,7 @@ CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth,
//! @addtogroup imgproc_feature
//! @{
-/** @example samples/cpp/edge.cpp
+/** @example samples/cpp/snippets/edge.cpp
This program demonstrates usage of the Canny edge detector
Check @ref tutorial_canny_detector "the corresponding tutorial" for more details
``` | edge.cpp has been moved to samples/cpp/snippets directory as it has been done for other basic cpp samples |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **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"
``` | fixed, canny is now default |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/edge_detection.cpp
**Change Type:** added
**Context:** PR #25515: Improved edge detection sample
**Review Line:** 13
**Code Changes:**
```diff
+
+#include "common.hpp"
+// Define namespace to simplify code
+using namespace cv;
+using namespace cv::dnn;
+using namespace std;
+
+int threshold1 = 0;
+int threshold2 = 50;
+int blurAmount = 5;
+
``` | Not the best practice in case of `std` namespace |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/test/test_tiff.cpp
**Change Type:** modified
**Context:** PR #26093: Update test_tiff.cpp
**Review Line:** 1111
**Code Changes:**
```diff
@@ -1109,7 +1108,7 @@ TEST(Imgcodecs_Tiff_Modes, write_multipage)
vector<Mat> pages;
for (size_t i = 0; i < page_count; i++)
{
- const Mat page = imread(root + page_files[i]);
+ const Mat page = imread(root + page_files[i], IMREAD_REDUCED_GRAYSCALE_8 + (int)i);
pages.push_back(page);
}
``` | I understood your idea to force output type to grayscale, but why REDUCED? |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/test/test_tiff.cpp
**Change Type:** modified
**Context:** PR #26093: Update test_tiff.cpp
**Review Line:** 1111
**Code Changes:**
```diff
@@ -1109,7 +1108,7 @@ TEST(Imgcodecs_Tiff_Modes, write_multipage)
vector<Mat> pages;
for (size_t i = 0; i < page_count; i++)
{
- const Mat page = imread(root + page_files[i]);
+ const Mat page = imread(root + page_files[i], IMREAD_REDUCED_GRAYSCALE_8 + (int)i);
pages.push_back(page);
}
``` | >I understood your idea to force output type to grayscale, but why REDUCED? to use smaller files to write and speed up the test. ( the code reads 2 gray scale and 4 color images ) |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #25945: Fix size() for 0d matrix
**Review Line:** 1278
**Code Changes:**
```diff
@@ -1275,7 +1275,7 @@ Size MatSize::operator()() const
{
int d = dims();
CV_DbgAssert(d <= 2);
- return d == 2 ? Size(p[1], p[0]) : Size(p[0], 1);
+ return d == 2 ? Size(p[1], p[0]) : d == 1 ? Size(p[0], 1) : Size(0, 0);
}
inline
``` | I believe, scalar should map to `Size(1,1)` rather than `Size(0,0)`. Of course, we should also distinguish between empty mat (the product of all dimensions must be 0) and scalar (the product of all dimensions must be 1). |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #25945: Fix size() for 0d matrix
**Review Line:** 1278
**Code Changes:**
```diff
@@ -1275,7 +1275,7 @@ Size MatSize::operator()() const
{
int d = dims();
CV_DbgAssert(d <= 2);
- return d == 2 ? Size(p[1], p[0]) : Size(p[0], 1);
+ return d == 2 ? Size(p[1], p[0]) : d == 1 ? Size(p[0], 1) : Size(0, 0);
}
inline
``` | `MatSize` is only used in `cv::Mat` and `cv::UMat` right? What is the scalar you are referring to? Would a matrix of size `1x1x1x1x1x1` be a scalar ? Would size be `(1,1)` then or undefined? An empty matrix can also be `1x0` (`dims()==2`). But when a matrix is newly created, `dims()==0`. It seems weird to also have a size of `(0,1)` |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #25945: Fix size() for 0d matrix
**Review Line:** 1278
**Code Changes:**
```diff
@@ -1275,7 +1275,7 @@ Size MatSize::operator()() const
{
int d = dims();
CV_DbgAssert(d <= 2);
- return d == 2 ? Size(p[1], p[0]) : Size(p[0], 1);
+ return d == 2 ? Size(p[1], p[0]) : d == 1 ? Size(p[0], 1) : Size(0, 0);
}
inline
``` | When empty matrix is created, dims()==0, but total() is 0 too. But there can be scalar matrix with dims() == 0, but total() == 1: ``` Mat m, mscalar(0, nullptr, CV_32F); mscalar.at<float>(0) = 1.f; printf("empty m dims: %d, total number of elements: %zu, empty m.empty(): %d, " "scalar m dims: %d, scalar m total: %zu, scalar m.empty(): %d\n", m.dims, m.total(), m.empty(), mscalar.dims, mscalar.total(), mscalar.empty()); ``` that is, in addition to dims member, empty() should also be used to distinguish between empty matrix and scalar matrix. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #25945: Fix size() for 0d matrix
**Review Line:** 1278
**Code Changes:**
```diff
@@ -1275,7 +1275,7 @@ Size MatSize::operator()() const
{
int d = dims();
CV_DbgAssert(d <= 2);
- return d == 2 ? Size(p[1], p[0]) : Size(p[0], 1);
+ return d == 2 ? Size(p[1], p[0]) : d == 1 ? Size(p[0], 1) : Size(0, 0);
}
inline
``` | Oh, regarding the other question. `1x1x1x1x1x1` is not a scalar, because `dims()==6`. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/include/opencv2/core/mat.inl.hpp
**Change Type:** modified
**Context:** PR #25945: Fix size() for 0d matrix
**Review Line:** 1278
**Code Changes:**
```diff
@@ -1275,7 +1275,7 @@ Size MatSize::operator()() const
{
int d = dims();
CV_DbgAssert(d <= 2);
- return d == 2 ? Size(p[1], p[0]) : Size(p[0], 1);
+ return d == 2 ? Size(p[1], p[0]) : d == 1 ? Size(p[0], 1) : Size(0, 0);
}
inline
``` | Thx for the explanation. It seems the scalar case is already handled properly because `d==1` in MatSize (though `dims()==0` in cv::Mat). I added a test for that. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Code Changes:**
```diff
@@ -0,0 +1,489 @@
+import cv2 as cv
+import numpy as np
+import argparse
+from tqdm import tqdm
+from functools import partial
+from copy import deepcopy
+
+## let use write description of the script and general information how to use it
+
``` | it could be simplified. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Code Changes:**
```diff
@@ -0,0 +1,489 @@
+import cv2 as cv
+import numpy as np
+import argparse
+from tqdm import tqdm
+from functools import partial
+from copy import deepcopy
+
+## let use write description of the script and general information how to use it
+
``` | Please remove VKCOM. It does not work for now. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Code Changes:**
```diff
@@ -0,0 +1,489 @@
+import cv2 as cv
+import numpy as np
+import argparse
+from tqdm import tqdm
+from functools import partial
+from copy import deepcopy
+
+## let use write description of the script and general information how to use it
+
``` | The same: cv.dnn.DNN_TARGET_VULKAN |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Review Line:** 158
**Code Changes:**
```diff
+
+ def make_schedule(self, ddim_num_steps, ddim_discretize="uniform", ddim_eta=0., verbose=True):
+ self.ddim_timesteps = make_ddim_timesteps(ddim_discr_method=ddim_discretize, num_ddim_timesteps=ddim_num_steps,
+ num_ddpm_timesteps=self.ddpm_num_timesteps,verbose=verbose)
+ alphas_cumprod = self.model.alphas_cumprod
+ assert alphas_cumprod.shape[0] == self.ddpm_num_timesteps, 'alphas have to be defined for each timestep'
+ to_numpy = partial(np.array, copy=True, dtype=np.float32)
+
+ self.register_buffer('betas', to_numpy(self.model.betas))
+ self.register_buffer('alphas_cumprod', to_numpy(alphas_cumprod))
+ self.register_buffer('alphas_cumprod_prev', to_numpy(self.model.alphas_cumprod_prev))
``` | I suppose there should be `num_ddpm_timesteps`. it's not used in the function. Also `self.ddpm_num_timesteps` is always 1000 as assigned in constructor and. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Review Line:** 475
**Code Changes:**
```diff
+
+def main(args):
+
+ image = cv.imread(args.image)
+ mask = create_mask(deepcopy(image))
+ image = cv.cvtColor(image, cv.COLOR_BGR2RGB)
+
+ batch = make_batch(image, mask)
+ image, mask, masked_image = batch["image"], batch["mask"], batch["masked_image"]
+
+ model = DDIMInpainter(args)
``` | You can use new cv.IMREAD_COLOR_RGB for imread to get rid of cvtColor. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Code Changes:**
```diff
@@ -0,0 +1,489 @@
+import cv2 as cv
+import numpy as np
+import argparse
+from tqdm import tqdm
+from functools import partial
+from copy import deepcopy
+
+## let use write description of the script and general information how to use it
+
``` | Most of parameters are not used in sample. Do we really need them? |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Review Line:** 475
**Code Changes:**
```diff
+
+def main(args):
+
+ image = cv.imread(args.image)
+ mask = create_mask(deepcopy(image))
+ image = cv.cvtColor(image, cv.COLOR_BGR2RGB)
+
+ batch = make_batch(image, mask)
+ image, mask, masked_image = batch["image"], batch["mask"], batch["masked_image"]
+
+ model = DDIMInpainter(args)
``` | I need to this seperately since `create_maks(...)` will show image with reversed channel if I use `cv.IMREAD_COLOR_RGB` in the `imread` |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Code Changes:**
```diff
@@ -0,0 +1,489 @@
+import cv2 as cv
+import numpy as np
+import argparse
+from tqdm import tqdm
+from functools import partial
+from copy import deepcopy
+
+## let use write description of the script and general information how to use it
+
``` | I would suggest put backends and targets that you tried. Others are not common. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Code Changes:**
```diff
@@ -0,0 +1,489 @@
+import cv2 as cv
+import numpy as np
+import argparse
+from tqdm import tqdm
+from functools import partial
+from copy import deepcopy
+
+## let use write description of the script and general information how to use it
+
``` | Prefer to use `np.newaxis` to make a new dimension, e.g. `image = image[np.newaxis, ...]` |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Code Changes:**
```diff
@@ -0,0 +1,489 @@
+import cv2 as cv
+import numpy as np
+import argparse
+from tqdm import tqdm
+from functools import partial
+from copy import deepcopy
+
+## let use write description of the script and general information how to use it
+
``` | Use `np.newaxis` as above |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Code Changes:**
```diff
@@ -0,0 +1,489 @@
+import cv2 as cv
+import numpy as np
+import argparse
+from tqdm import tqdm
+from functools import partial
+from copy import deepcopy
+
+## let use write description of the script and general information how to use it
+
``` | It seems `kwargs` is not needed. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Code Changes:**
```diff
@@ -0,0 +1,489 @@
+import cv2 as cv
+import numpy as np
+import argparse
+from tqdm import tqdm
+from functools import partial
+from copy import deepcopy
+
+## let use write description of the script and general information how to use it
+
``` | I believe it should be `np.newaxis` |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Code Changes:**
```diff
@@ -0,0 +1,489 @@
+import cv2 as cv
+import numpy as np
+import argparse
+from tqdm import tqdm
+from functools import partial
+from copy import deepcopy
+
+## let use write description of the script and general information how to use it
+
``` | There is no backend and target for openvino in line 46 to 47. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** samples/dnn/ldm_inpainting.py
**Change Type:** added
**Context:** PR #25950: Diffusion Inpainting Sample
**Code Changes:**
```diff
@@ -0,0 +1,489 @@
+import cv2 as cv
+import numpy as np
+import argparse
+from tqdm import tqdm
+from functools import partial
+from copy import deepcopy
+
+## let use write description of the script and general information how to use it
+
``` | `np.newaxis` |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/js/generator/CMakeLists.txt
**Change Type:** modified
**Context:** PR #25986: Split Javascript white-list to support contrib modules
**Code Changes:**
```diff
@@ -38,8 +38,21 @@ set(scripts_hdr_parser "${JS_SOURCE_DIR}/../python/src2/hdr_parser.py")
if(DEFINED ENV{OPENCV_JS_WHITELIST})
set(OPENCV_JS_WHITELIST_FILE "$ENV{OPENCV_JS_WHITELIST}")
+ message(STATUS "Use white list from environment ${OPENCV_JS_WHITELIST_FILE}")
else()
- set(OPENCV_JS_WHITELIST_FILE "${OpenCV_SOURCE_DIR}/platforms/js/opencv_js.config.py")
+ #generate white list from modules/<module_name>/misc/js/whitelist.json
+ set(OPENCV_JS_WHITELIST_FILE "${CMAKE_CURRENT_BINARY_DIR}/whitelist.json")
+ foreach(m in ${OPENCV_JS_MODULES})
``` | No need to write file each time. Generate string and update on changes only. See `ocv_update_file` Also generated file should be added as a dependency to the build graph of bindings generator target. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/js/generator/embindgen.py
**Change Type:** modified
**Context:** PR #25986: Split Javascript white-list to support contrib modules
**Review Line:** 956
**Code Changes:**
```diff
@@ -76,6 +76,7 @@
else:
from cStringIO import StringIO
+import json
func_table = {}
@@ -103,11 +104,32 @@ def makeWhiteList(module_list):
wl[k] = m[k]
return wl
+def makeWhiteListJson(module_list):
+ wl = {}
+ for n, gen_dict in module_list.items():
``` | Old behavior seems broken. Besides of json there are namespaces configuration were possible (see `namespace_prefix_override`), so python configuration code is preferable and provides full customization without unnecessary limitation of json. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/js/generator/CMakeLists.txt
**Change Type:** modified
**Context:** PR #25986: Split Javascript white-list to support contrib modules
**Code Changes:**
```diff
@@ -38,8 +38,21 @@ set(scripts_hdr_parser "${JS_SOURCE_DIR}/../python/src2/hdr_parser.py")
if(DEFINED ENV{OPENCV_JS_WHITELIST})
set(OPENCV_JS_WHITELIST_FILE "$ENV{OPENCV_JS_WHITELIST}")
+ message(STATUS "Use white list from environment ${OPENCV_JS_WHITELIST_FILE}")
else()
- set(OPENCV_JS_WHITELIST_FILE "${OpenCV_SOURCE_DIR}/platforms/js/opencv_js.config.py")
+ #generate white list from modules/<module_name>/misc/js/whitelist.json
+ set(OPENCV_JS_WHITELIST_FILE "${CMAKE_CURRENT_BINARY_DIR}/whitelist.json")
+ foreach(m in ${OPENCV_JS_MODULES})
``` | ocv_update_file - done. dependency is already there. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/perf/perf_layer.cpp
**Change Type:** modified
**Context:** PR #23279: dnn: add ONNX TopK
**Review Line:** 1097
**Code Changes:**
```diff
+}
+PERF_TEST_P_(Layer_TopK, TopK_3D_Axis1) {
+ test_layer(input_shape_3d, input_shape_3d[1] / 2, 1);
+}
+PERF_TEST_P_(Layer_TopK, TopK_3D_Axis2) {
+ test_layer(input_shape_3d, input_shape_3d[2] / 2, 2);
+}
+INSTANTIATE_TEST_CASE_P(/**/, Layer_TopK,
+ dnnBackendsAndTargets(/* withInferenceEngine= */ false,
+ /* withHalide= */ false,
+ /* withCpuOCV= */ true,
``` | I propose to add cases for top-5 at least. It's popular case for classification scenarios. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/test/test_color.cpp
**Change Type:** modified
**Context:** PR #25968: Correct Bayer2Gray u8 SIMD
**Code Changes:**
```diff
@@ -1863,6 +1863,26 @@ TEST(Imgproc_ColorBayer, regression)
EXPECT_EQ(0, countNonZero(diff.reshape(1) > 1));
}
+TEST(Imgproc_ColorBayer2Gray, regression_25823)
+{
+ const int n = 100;
+ Mat src(n, n, CV_8UC1);
+ Mat dst;
+
``` | ``` cv::Mat gt(rows, cols, cv::Scalar(1)); EXPECT_EQ(0, cv::norm(dst, gt, NORM_INF)); ``` |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/cuda4dnn/csl/tensor.hpp
**Change Type:** modified
**Context:** PR #26043: Support Matrices with axes > 6 CUDA
**Review Line:** 31
**Code Changes:**
```diff
@@ -28,7 +28,7 @@
#include <utility>
#ifndef CSL_MAX_TENSOR_RANK
- #define CSL_MAX_TENSOR_RANK 6
+ #define CSL_MAX_TENSOR_RANK 7
#endif
namespace cv { namespace dnn { namespace cuda4dnn { namespace csl {
``` | Not sure why there is a rank limit. Could it be removed? |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/cuda4dnn/csl/tensor.hpp
**Change Type:** modified
**Context:** PR #26043: Support Matrices with axes > 6 CUDA
**Review Line:** 31
**Code Changes:**
```diff
@@ -28,7 +28,7 @@
#include <utility>
#ifndef CSL_MAX_TENSOR_RANK
- #define CSL_MAX_TENSOR_RANK 6
+ #define CSL_MAX_TENSOR_RANK 7
#endif
namespace cv { namespace dnn { namespace cuda4dnn { namespace csl {
``` | I took a look at it. It seems that currently this variables is deeply rooted in CUDA backend. We can remove it from assertions and nothing happens. But to remove it completed quite a number of classes and function need to be refactored. |
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/test/test_onnx_conformance_layer_filter__cuda_denylist.inl.hpp
**Change Type:** modified
**Context:** PR #26043: Support Matrices with axes > 6 CUDA
**Review Line:** 93
**Code Changes:**
```diff
@@ -90,7 +90,6 @@
"test_scatternd_max",
"test_scatternd_min",
"test_scatternd_multiply",
-"test_nllloss_NCd1d2d3d4d5_none_no_weight_expanded", // crash: https://github.com/opencv/opencv/issues/25471
"test_dequantizelinear_blocked", // Issue https://github.com/opencv/opencv/issues/25999
"test_quantizelinear", // Issue https://github.com/opencv/opencv/issues/25999
"test_quantizelinear_axis", // Issue https://github.com/opencv/opencv/issues/25999
``` | just remove the line |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #26073: (5.x) Merge 4.x - Contrib: https://github.com/opencv/opencv_contrib/pull/3783 Extra: https://github.com/opencv/opencv_extra/pull/1205 #2327...
**Review Line:** 3302
**Code Changes:**
```diff
+ net.forward(outputs, std::vector<std::string>{"values", "indices"});
+
+ Mat output_res_val = outputs.front(),
+ output_res_ind = outputs.back();
+
+ output_ref_ind.convertTo(output_ref_ind, CV_32F); // TODO: revise this conversion in 5.x
+
+ normAssert(output_ref_val, output_res_val, (basename + " values").c_str(), l1 ? l1 : default_l1, lInf ? lInf : default_lInf);
+ normAssert(output_ref_ind, output_res_ind, (basename + " indices").c_str(), l1 ? l1 : default_l1, lInf ? lInf : default_lInf);
+
+ expectNoFallbacksFromIE(net);
``` | Well, it needs to be handled in `getType` in the layer impementation but 4.x does not have this. I can prepare a dedicated one for the 5.x merge. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/test/test_onnx_importer.cpp
**Change Type:** modified
**Context:** PR #26073: (5.x) Merge 4.x - Contrib: https://github.com/opencv/opencv_contrib/pull/3783 Extra: https://github.com/opencv/opencv_extra/pull/1205 #2327...
**Review Line:** 3302
**Code Changes:**
```diff
+ net.forward(outputs, std::vector<std::string>{"values", "indices"});
+
+ Mat output_res_val = outputs.front(),
+ output_res_ind = outputs.back();
+
+ output_ref_ind.convertTo(output_ref_ind, CV_32F); // TODO: revise this conversion in 5.x
+
+ normAssert(output_ref_val, output_res_val, (basename + " values").c_str(), l1 ? l1 : default_l1, lInf ? lInf : default_lInf);
+ normAssert(output_ref_ind, output_res_ind, (basename + " indices").c_str(), l1 ? l1 : default_l1, lInf ? lInf : default_lInf);
+
+ expectNoFallbacksFromIE(net);
``` | Filed ticket about it: https://github.com/opencv/opencv/issues/26076 |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/test/test_operations.cpp
**Change Type:** modified
**Context:** PR #26073: (5.x) Merge 4.x - Contrib: https://github.com/opencv/opencv_contrib/pull/3783 Extra: https://github.com/opencv/opencv_extra/pull/1205 #2327...
**Code Changes:**
```diff
@@ -42,7 +42,7 @@
#include "test_precomp.hpp"
#include "opencv2/ts/ocl_test.hpp" // T-API like tests
-#include "opencv2/core/core_c.h"
+#include <fenv.h>
namespace opencv_test {
namespace {
@@ -1087,7 +1087,6 @@ bool CV_OperationsTest::operations1()
``` | double check for what? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** modified
**Context:** PR #26073: (5.x) Merge 4.x - Contrib: https://github.com/opencv/opencv_contrib/pull/3783 Extra: https://github.com/opencv/opencv_extra/pull/1205 #2327...
**Review Line:** 545
**Code Changes:**
```diff
@@ -541,7 +542,7 @@ class LayerEinsumImpl CV_FINAL : public EinsumLayer
// Use either the preprocessed inputs (if it is available) or the corresponding raw inputs
result = pairwiseOperandProcess(!result.empty() ? result : rawInputs[0],
!result.empty() ? tmpResult : homogenizedInputDims[0],
- (!preProcessedInputs.empty() && !preProcessedInputs[input].empty()) ? preProcessedInputs[input] : rawInputs[input],
+ (!preProcessedInputs[input].empty()) ? preProcessedInputs[input] : rawInputs[input],
homogenizedInputDims[input],
reducedDims,
isFinalPair);
@@ -605,8 +606,8 @@ void LayerEinsumImpl::preProcessInputs(InputArrayOfArrays& inputs_arr)
std::vector<cv::Mat> inputs;
``` | Why is pre-check removed? (anyway it is wrong as it doesn't check vector size vs index) |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** modified
**Context:** PR #26073: (5.x) Merge 4.x - Contrib: https://github.com/opencv/opencv_contrib/pull/3783 Extra: https://github.com/opencv/opencv_extra/pull/1205 #2327...
**Review Line:** 542
**Code Changes:**
```diff
+ CV_CheckEQ((size_t)inputs_arr.total(), (size_t)numInputs, "Number of inputs in forward and inputs during graph constructions do not match");
if (inputs_arr.depth() == CV_16F)
{
@@ -541,7 +542,7 @@ class LayerEinsumImpl CV_FINAL : public EinsumLayer
// Use either the preprocessed inputs (if it is available) or the corresponding raw inputs
result = pairwiseOperandProcess(!result.empty() ? result : rawInputs[0],
!result.empty() ? tmpResult : homogenizedInputDims[0],
- (!preProcessedInputs.empty() && !preProcessedInputs[input].empty()) ? preProcessedInputs[input] : rawInputs[input],
+ (!preProcessedInputs[input].empty()) ? preProcessedInputs[input] : rawInputs[input],
homogenizedInputDims[input],
``` | Lost assertion: https://github.com/opencv/opencv/blame/4.x/modules/dnn/src/layers/einsum_layer.cpp#L462 |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/src/layers/einsum_layer.cpp
**Change Type:** modified
**Context:** PR #26073: (5.x) Merge 4.x - Contrib: https://github.com/opencv/opencv_contrib/pull/3783 Extra: https://github.com/opencv/opencv_extra/pull/1205 #2327...
**Review Line:** 545
**Code Changes:**
```diff
@@ -541,7 +542,7 @@ class LayerEinsumImpl CV_FINAL : public EinsumLayer
// Use either the preprocessed inputs (if it is available) or the corresponding raw inputs
result = pairwiseOperandProcess(!result.empty() ? result : rawInputs[0],
!result.empty() ? tmpResult : homogenizedInputDims[0],
- (!preProcessedInputs.empty() && !preProcessedInputs[input].empty()) ? preProcessedInputs[input] : rawInputs[input],
+ (!preProcessedInputs[input].empty()) ? preProcessedInputs[input] : rawInputs[input],
homogenizedInputDims[input],
reducedDims,
isFinalPair);
@@ -605,8 +606,8 @@ void LayerEinsumImpl::preProcessInputs(InputArrayOfArrays& inputs_arr)
std::vector<cv::Mat> inputs;
``` | After https://github.com/opencv/opencv/pull/26059 the `preProcessedInputs` is resized, but not reserved. As soon as the layer has inputs, the vector is not empty. I just selected 4.x version. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/perf/perf_warp.cpp
**Change Type:** modified
**Context:** PR #26054: Extended perf tests for warpPerspective to cover channels too
**Review Line:** 45
**Code Changes:**
```diff
TEST_CYCLE() warpAffine( src, dst, warpMat, sz, interType, borderMode, borderColor );
-#ifdef __ANDROID__
- SANITY_CHECK(dst, interType==INTER_LINEAR? 5 : 10);
-#else
SANITY_CHECK(dst, 1);
-#endif
}
PERF_TEST_P(TestWarpAffine, DISABLED_WarpAffine_ovx,
@@ -72,29 +68,28 @@ PERF_TEST_P(TestWarpAffine, DISABLED_WarpAffine_ovx,
``` | Maybe `SANITY_CHECK_NOTHING()`? We're trying to deprecate accuracy checks in perf tests for some time (https://github.com/opencv/opencv/wiki/HowToWritePerfTests#simple-regression-check). |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgproc/perf/perf_warp.cpp
**Change Type:** modified
**Context:** PR #26054: Extended perf tests for warpPerspective to cover channels too
**Review Line:** 45
**Code Changes:**
```diff
TEST_CYCLE() warpAffine( src, dst, warpMat, sz, interType, borderMode, borderColor );
-#ifdef __ANDROID__
- SANITY_CHECK(dst, interType==INTER_LINEAR? 5 : 10);
-#else
SANITY_CHECK(dst, 1);
-#endif
}
PERF_TEST_P(TestWarpAffine, DISABLED_WarpAffine_ovx,
@@ -72,29 +68,28 @@ PERF_TEST_P(TestWarpAffine, DISABLED_WarpAffine_ovx,
``` | Let's presume the checks, where we have it. No check for new code. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/dnn/misc/python/test/test_dnn.py
**Change Type:** modified
**Context:** PR #26026: Add support for boolan input/outputs in python bindings
**Code Changes:**
```diff
@@ -546,5 +546,24 @@ def test_net_builder(self):
out = net.forward()
self.assertEqual(out.shape, (1, 2, 3, 4))
+ def test_bool_operator(self):
+ n = self.find_dnn_file('dnn/onnx/models/and_op.onnx')
+
+ x = np.random.randint(0, 2, [5], dtype=np.bool_)
+ y = np.random.randint(0, 2, [5], dtype=np.bool_)
+ o = x & y
``` | Can we generate test data in runtime instead? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.