instruction stringclasses 9 values | input stringlengths 279 5.47k | output stringlengths 6 9.58k |
|---|---|---|
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:** 3rdparty/hal_rvv/hal_rvv_1p0/sincos.hpp
**Change Type:** added
**Context:** PR #26999: [HAL RVV] unify and impl polar_to_cart | add perf test
**Review Line:** 1
**Code Changes:**
```diff
@@ -0,0 +1,72 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level
+// directory of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2025, Institute of Software, Chinese Academy of Sciences.
+
``` | Better to move the content of this file to `common.hpp` or `common_utils.hpp` when we have such files. |
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/src/mathfuncs_core.simd.hpp
**Change Type:** modified
**Context:** PR #26999: [HAL RVV] unify and impl polar_to_cart | add perf test
**Review Line:** 14
**Code Changes:**
```diff
@@ -11,6 +11,8 @@ CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
// forward declarations
void cartToPolar32f(const float *X, const float *Y, float* mag, float *angle, int len, bool angleInDegrees);
void cartToPolar64f(const double *X, const double *Y, double* mag, double *angle, int len, bool angleInDegrees);
+void polarToCart32f(const float *mag, const float *angle, float *X, float *Y, int len, bool angleInDegrees);
+void polarToCart64f(const double *mag, const double *angle, double *X, double *Y, int len, bool angleInDegrees);
void fastAtan32f(const float *Y, const float *X, float *angle, int len, bool angleInDegrees);
void fastAtan64f(const double *Y, const double *X, double *angle, int len, bool angleInDegrees);
void fastAtan2(const float *Y, const float *X, float *angle, int len, bool angleInDegrees);
@@ -178,6 +180,167 @@ void cartToPolar64f(const double *X, const double *Y, double *mag, double *angle
``` | Why is `isInPlace` dropped? |
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/src/mathfuncs_core.simd.hpp
**Change Type:** modified
**Context:** PR #26999: [HAL RVV] unify and impl polar_to_cart | add perf test
**Review Line:** 185
**Code Changes:**
```diff
}
}
+namespace {
+
+static inline void SinCos_32f(const float* mag, const float* angle, float* cosval, float* sinval, int len, int angle_in_degrees)
+{
+ const int N = 64;
+
+ static const double sin_table[] =
+ {
``` | It would be nice if you can refactor this function with v_sincos from https://github.com/opencv/opencv/pull/25892. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/sincos.hpp
**Change Type:** added
**Context:** PR #26999: [HAL RVV] unify and impl polar_to_cart | add perf test
**Review Line:** 1
**Code Changes:**
```diff
@@ -0,0 +1,72 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level
+// directory of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2025, Institute of Software, Chinese Academy of Sciences.
+
``` | In fact, this function is currently only used by `polar_to_cart` in `core`, so it’s not really "common." I split it into a separate file because it represents a standalone, reusable functionality. If I just put it in `polar_to_cart.hpp`, it may also be confusing why the seemingly standalone function `sin_cos` is there. |
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/core/src/mathfuncs_core.simd.hpp
**Change Type:** modified
**Context:** PR #26999: [HAL RVV] unify and impl polar_to_cart | add perf test
**Review Line:** 14
**Code Changes:**
```diff
@@ -11,6 +11,8 @@ CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
// forward declarations
void cartToPolar32f(const float *X, const float *Y, float* mag, float *angle, int len, bool angleInDegrees);
void cartToPolar64f(const double *X, const double *Y, double* mag, double *angle, int len, bool angleInDegrees);
+void polarToCart32f(const float *mag, const float *angle, float *X, float *Y, int len, bool angleInDegrees);
+void polarToCart64f(const double *mag, const double *angle, double *X, double *Y, int len, bool angleInDegrees);
void fastAtan32f(const float *Y, const float *X, float *angle, int len, bool angleInDegrees);
void fastAtan64f(const double *Y, const double *X, double *angle, int len, bool angleInDegrees);
void fastAtan2(const float *Y, const float *X, float *angle, int len, bool angleInDegrees);
@@ -178,6 +180,167 @@ void cartToPolar64f(const double *X, const double *Y, double *mag, double *angle
``` | Because it looks quite different from cartToPolar and is inconsistent with the current HAL interface. And it is no longer necessary in the current approach. You can see the detail in this part of the first comment: > ### Effect of Point 4 |
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/src/mathfuncs_core.simd.hpp
**Change Type:** modified
**Context:** PR #26999: [HAL RVV] unify and impl polar_to_cart | add perf test
**Review Line:** 185
**Code Changes:**
```diff
}
}
+namespace {
+
+static inline void SinCos_32f(const float* mag, const float* angle, float* cosval, float* sinval, int len, int angle_in_degrees)
+{
+ const int N = 64;
+
+ static const double sin_table[] =
+ {
``` | I will give it a try. However, `SinCos_32f` has specific optimizations for AVX2. Where should I place it? Should I leave it here or put it in `intrin_avx.hpp`? I'm not familiar with the UI conventions. |
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/src/mathfuncs_core.simd.hpp
**Change Type:** modified
**Context:** PR #26999: [HAL RVV] unify and impl polar_to_cart | add perf test
**Review Line:** 185
**Code Changes:**
```diff
}
}
+namespace {
+
+static inline void SinCos_32f(const float* mag, const float* angle, float* cosval, float* sinval, int len, int angle_in_degrees)
+{
+ const int N = 64;
+
+ static const double sin_table[] =
+ {
``` | If you implement UI version and find out that it is much faster, then just drop it. Otherwise, preserve it somehow. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/sincos.hpp
**Change Type:** added
**Context:** PR #26999: [HAL RVV] unify and impl polar_to_cart | add perf test
**Review Line:** 1
**Code Changes:**
```diff
@@ -0,0 +1,72 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level
+// directory of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2025, Institute of Software, Chinese Academy of Sciences.
+
``` | We can leave it as-is. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/perf/perf_flip.cpp
**Change Type:** added
**Context:** PR #26943: Impl RISC-V HAL for cv::flip | Add perf test for flip
**Review Line:** 5
**Code Changes:**
```diff
@@ -0,0 +1,45 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+#include "perf_precomp.hpp"
+
+namespace opencv_test { namespace {
+using namespace perf;
+
+enum
``` | License header is missing. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/types.hpp
**Change Type:** added
**Context:** PR #26977: [Refactor](HAL RVV): Consolidate Helpers for Code Reusability
**Code Changes:**
```diff
@@ -0,0 +1,485 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level
+// directory of this distribution and at http://opencv.org/license.html.
+#pragma once
+
+#include <riscv_vector.h>
+#include <type_traits>
+
+namespace cv { namespace cv_hal_rvv {
``` | Maybe split names for better readability? `RVV_##TYPE_NAME##M1`? |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/types.hpp
**Change Type:** added
**Context:** PR #26977: [Refactor](HAL RVV): Consolidate Helpers for Code Reusability
**Code Changes:**
```diff
@@ -0,0 +1,485 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level
+// directory of this distribution and at http://opencv.org/license.html.
+#pragma once
+
+#include <riscv_vector.h>
+#include <type_traits>
+
+namespace cv { namespace cv_hal_rvv {
``` | I meant adding an underscore between `RVV` and type, e.g. `RVV_U8M1` |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/types.hpp
**Change Type:** added
**Context:** PR #26977: [Refactor](HAL RVV): Consolidate Helpers for Code Reusability
**Code Changes:**
```diff
@@ -0,0 +1,485 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level
+// directory of this distribution and at http://opencv.org/license.html.
+#pragma once
+
+#include <riscv_vector.h>
+#include <type_traits>
+
+namespace cv { namespace cv_hal_rvv {
``` | I'm really sorry for misunderstanding you again. I thought you were saying that the macro concatenation was too ugly and asked me to split the type name definition. Of course, I also think the macro is ugly, so I’ve now changed the name and also expanded the macro. |
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/objdetect/test/test_arucodetection.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 658
**Code Changes:**
```diff
+TEST(CV_ArucoMultiDict, setGetDictionaries)
+{
+ vector<aruco::Dictionary> dictionaries = {aruco::getPredefinedDictionary(aruco::DICT_4X4_50), aruco::getPredefinedDictionary(aruco::DICT_5X5_100)};
+ aruco::ArucoDetector detector(dictionaries);
+ vector<aruco::Dictionary> dicts = detector.getDictionaries();
+ ASSERT_EQ(dicts.size(), 2ul);
+ EXPECT_EQ(dicts[0].markerSize, 4);
+ EXPECT_EQ(dicts[1].markerSize, 5);
+ dictionaries.clear();
+ dictionaries.push_back(aruco::getPredefinedDictionary(aruco::DICT_6X6_100));
+ dictionaries.push_back(aruco::getPredefinedDictionary(aruco::DICT_7X7_250));
``` | Please add comment to the detector constructor that it uses one of predefined dictionaries by default. Value `2` is not obvious here. |
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/objdetect/include/opencv2/objdetect/aruco_detector.hpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -285,6 +285,16 @@ class CV_EXPORTS_W ArucoDetector : public Algorithm
const DetectorParameters &detectorParams = DetectorParameters(),
const RefineParameters& refineParams = RefineParameters());
+ /** @brief ArucoDetector constructor for multiple dictionaries
+ *
+ * @param dictionaries indicates the type of markers that will be searched. Empty dictionaries will throw an error.
+ * @param detectorParams marker detection parameters
+ * @param refineParams marker refine detection parameters
+ */
``` | size_t does not work well with Java and Python bindings. let's use just int. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/test/test_arucodetection.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -6,6 +6,18 @@
#include "opencv2/objdetect/aruco_detector.hpp"
#include "opencv2/calib3d.hpp"
+namespace cv {
+ namespace aruco {
+ bool operator==(const Dictionary& d1, const Dictionary& d2);
+ bool operator==(const Dictionary& d1, const Dictionary& d2) {
+ return d1.markerSize == d2.markerSize
+ && std::equal(d1.bytesList.begin<Vec<uint8_t, 4>>(), d1.bytesList.end<Vec<uint8_t, 4>>(), d2.bytesList.begin<Vec<uint8_t, 4>>())
``` | ``` Point2f firstCorner(markerSidePixels / 2.f + x * (1.5f * markerSidePixels), markerSidePixels / 2.f + y * (1.5f * markerSidePixels)); Mat aux = img((int)firstCorner.x, (int)firstCorner.y, markerSidePixels. markerSidePixels); ``` |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/test/test_arucodetection.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -6,6 +6,18 @@
#include "opencv2/objdetect/aruco_detector.hpp"
#include "opencv2/calib3d.hpp"
+namespace cv {
+ namespace aruco {
+ bool operator==(const Dictionary& d1, const Dictionary& d2);
+ bool operator==(const Dictionary& d1, const Dictionary& d2) {
+ return d1.markerSize == d2.markerSize
+ && std::equal(d1.bytesList.begin<Vec<uint8_t, 4>>(), d1.bytesList.end<Vec<uint8_t, 4>>(), d2.bytesList.begin<Vec<uint8_t, 4>>())
``` | I propose to add assertion to `removeDictionary()` call and not allow the case without dictionaries, because we get detector with invalid state and it's definitely a bug. |
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/objdetect/misc/python/test/test_objdetect_aruco.py
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -458,5 +458,30 @@ def test_draw_detected_diamonds(self):
with self.assertRaises(Exception):
img = cv.aruco.drawDetectedDiamonds(img, points2, borderColor=255)
+ def test_multi_dict_arucodetector(self):
+ aruco_params = cv.aruco.DetectorParameters()
+ aruco_dicts = [
+ cv.aruco.getPredefinedDictionary(cv.aruco.DICT_4X4_250),
+ cv.aruco.getPredefinedDictionary(cv.aruco.DICT_5X5_250)
+ ]
``` | It breaks compatibility. M.b. rename the method to detectMarkersMultiDict? |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -10,6 +10,7 @@
#include "apriltag/apriltag_quad_thresh.hpp"
#include "aruco_utils.hpp"
#include <cmath>
+#include <map>
namespace cv {
namespace aruco {
@@ -640,9 +641,14 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes
}
``` | Add `index>= 0` to assert. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -10,6 +10,7 @@
#include "apriltag/apriltag_quad_thresh.hpp"
#include "aruco_utils.hpp"
#include <cmath>
+#include <map>
namespace cv {
namespace aruco {
@@ -640,9 +641,14 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes
}
``` | Add `index>= 0` to assert. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -10,6 +10,7 @@
#include "apriltag/apriltag_quad_thresh.hpp"
#include "aruco_utils.hpp"
#include <cmath>
+#include <map>
namespace cv {
namespace aruco {
@@ -640,9 +641,14 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes
}
``` | Add index>= 0 to assert. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 1117
**Code Changes:**
```diff
@@ -10,6 +10,7 @@
#include "apriltag/apriltag_quad_thresh.hpp"
#include "aruco_utils.hpp"
#include <cmath>
+#include <map>
namespace cv {
namespace aruco {
@@ -640,9 +641,14 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes
}
}
+enum class DictionaryMode {
+ Single,
+ Multi
``` | I propose to add `refineDetectedMarkersMultiDict` overload with dictionaries id like in detect. May be useful for multi-scale markers. |
You are an expert OpenCV code reviewer specializing in test coverage and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/misc/python/test/test_objdetect_aruco.py
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -458,5 +458,30 @@ def test_draw_detected_diamonds(self):
with self.assertRaises(Exception):
img = cv.aruco.drawDetectedDiamonds(img, points2, borderColor=255)
+ def test_multi_dict_arucodetector(self):
+ aruco_params = cv.aruco.DetectorParameters()
+ aruco_dicts = [
+ cv.aruco.getPredefinedDictionary(cv.aruco.DICT_4X4_250),
+ cv.aruco.getPredefinedDictionary(cv.aruco.DICT_5X5_250)
+ ]
``` | Unfortunate, but I managed to do create a detectMarkersMultiDict function with relative little redundant code. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 1117
**Code Changes:**
```diff
@@ -10,6 +10,7 @@
#include "apriltag/apriltag_quad_thresh.hpp"
#include "aruco_utils.hpp"
#include <cmath>
+#include <map>
namespace cv {
namespace aruco {
@@ -640,9 +641,14 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes
}
}
+enum class DictionaryMode {
+ Single,
+ Multi
``` | Made sure refine is now looping over the markers and checked the output. Looks like this can be done safely without having to have two functions. |
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/objdetect/include/opencv2/objdetect/aruco_detector.hpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -285,6 +285,16 @@ class CV_EXPORTS_W ArucoDetector : public Algorithm
const DetectorParameters &detectorParams = DetectorParameters(),
const RefineParameters& refineParams = RefineParameters());
+ /** @brief ArucoDetector constructor for multiple dictionaries
+ *
+ * @param dictionaries indicates the type of markers that will be searched. Empty dictionaries will throw an error.
+ * @param detectorParams marker detection parameters
+ * @param refineParams marker refine detection parameters
+ */
``` | 1. In my opinion, methods `get(set)Dictionary`, `add(remove)Dictionary` are redundant. It is enough to have `get(set)Dictionaries`. Perhaps it would be better to preserve old `get(set)Dictionary`, so that they would return the first one. 2. Is it safe to return reference to internal vector in method `getDictionaries`? Maybe it would be better to return a copy. 3. What about corner cases: empty vector, duplicates? 4. Methods should be documented. |
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/objdetect/include/opencv2/objdetect/aruco_detector.hpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 373
**Code Changes:**
```diff
+ * Note that this function does not perform pose estimation.
+ * @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
+ * input image with corresponding camera model, if camera parameters are known
+ * @sa undistort, estimatePoseSingleMarkers, estimatePoseBoard
+ */
+ CV_WRAP void detectMarkersMultiDict(InputArray image, OutputArrayOfArrays corners, OutputArray ids,
+ OutputArrayOfArrays rejectedImgPoints = noArray(), OutputArray dictIndices = noArray()) const;
+
+ /** @brief Returns first dictionary from internal list used for marker detection.
+ *
+ * @return The first dictionary from the configured ArucoDetector.
``` | Wouldn't it be more convenient to modify Dictionary class, so that it would be able to combine several dictionaries underneath. It could also handle duplicate markers and provide convenient indexing. Detector interface would stay the same and users would require minimal changes in their code. |
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/objdetect/include/opencv2/objdetect/aruco_detector.hpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 373
**Code Changes:**
```diff
+ * Note that this function does not perform pose estimation.
+ * @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
+ * input image with corresponding camera model, if camera parameters are known
+ * @sa undistort, estimatePoseSingleMarkers, estimatePoseBoard
+ */
+ CV_WRAP void detectMarkersMultiDict(InputArray image, OutputArrayOfArrays corners, OutputArray ids,
+ OutputArrayOfArrays rejectedImgPoints = noArray(), OutputArray dictIndices = noArray()) const;
+
+ /** @brief Returns first dictionary from internal list used for marker detection.
+ *
+ * @return The first dictionary from the configured ArucoDetector.
``` | Not a bad idea, but the Dictionary class is also used for these calibration boards and the Charuco stuff as well. Its public members (`errorCorrection`, `markerSize`, `bytesList`) would all need to change because they would be ambiguous. Just from a quick check I think such a change would be more disruptive than the interface change suggested in this PR. |
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/objdetect/include/opencv2/objdetect/aruco_detector.hpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 373
**Code Changes:**
```diff
+ * Note that this function does not perform pose estimation.
+ * @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
+ * input image with corresponding camera model, if camera parameters are known
+ * @sa undistort, estimatePoseSingleMarkers, estimatePoseBoard
+ */
+ CV_WRAP void detectMarkersMultiDict(InputArray image, OutputArrayOfArrays corners, OutputArray ids,
+ OutputArrayOfArrays rejectedImgPoints = noArray(), OutputArray dictIndices = noArray()) const;
+
+ /** @brief Returns first dictionary from internal list used for marker detection.
+ *
+ * @return The first dictionary from the configured ArucoDetector.
``` | > I think such a change would be more disruptive than the interface change suggested in this PR. Agree and support |
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/objdetect/include/opencv2/objdetect/aruco_detector.hpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 373
**Code Changes:**
```diff
+ * Note that this function does not perform pose estimation.
+ * @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
+ * input image with corresponding camera model, if camera parameters are known
+ * @sa undistort, estimatePoseSingleMarkers, estimatePoseBoard
+ */
+ CV_WRAP void detectMarkersMultiDict(InputArray image, OutputArrayOfArrays corners, OutputArray ids,
+ OutputArrayOfArrays rejectedImgPoints = noArray(), OutputArray dictIndices = noArray()) const;
+
+ /** @brief Returns first dictionary from internal list used for marker detection.
+ *
+ * @return The first dictionary from the configured ArucoDetector.
``` | We already have function `extendDictionary` which adds randomized markers to the existing dictionary, so I believe creating similar function to combine several dictionaries with the same marker size would be quite easy. Or do we need to have dictionaries with different marker sizes? |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/include/opencv2/objdetect/aruco_detector.hpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -285,6 +285,16 @@ class CV_EXPORTS_W ArucoDetector : public Algorithm
const DetectorParameters &detectorParams = DetectorParameters(),
const RefineParameters& refineParams = RefineParameters());
+ /** @brief ArucoDetector constructor for multiple dictionaries
+ *
+ * @param dictionaries indicates the type of markers that will be searched. Empty dictionaries will throw an error.
+ * @param detectorParams marker detection parameters
+ * @param refineParams marker refine detection parameters
+ */
``` | 1. Old get/setDictionary API would work, yes. But ABI compatibility would be broken. Can we avoid it? 2. No I meant safety in terms of exposing internal structure. For example it allows user to create iterator which might become invalid suddenly. Also we won't be able to change internal data structure. 3. Each access function must be tested for possible errors then. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 1386
**Code Changes:**
```diff
}
-void ArucoDetector::write(FileStorage &fs) const
-{
- arucoDetectorImpl->dictionary.writeDictionary(fs);
+void ArucoDetector::write(FileStorage &fs) const {
+ // preserve old format for single dictionary case
+ if (1 == arucoDetectorImpl->dictionaries.size()) {
+ arucoDetectorImpl->dictionaries[0].writeDictionary(fs);
+ } else {
+ fs << "dictionaries" << "[";
``` | I believe (de)serialization is not tested. Is old format supported? I.e. if we have just one dictionary, would older versions of OpenCV be able to read it? |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 1386
**Code Changes:**
```diff
}
-void ArucoDetector::write(FileStorage &fs) const
-{
- arucoDetectorImpl->dictionary.writeDictionary(fs);
+void ArucoDetector::write(FileStorage &fs) const {
+ // preserve old format for single dictionary case
+ if (1 == arucoDetectorImpl->dictionaries.size()) {
+ arucoDetectorImpl->dictionaries[0].writeDictionary(fs);
+ } else {
+ fs << "dictionaries" << "[";
``` | True, I couldn't find a unit test for it, but I tested it locally. I can clean the code up and add it as a test. I made sure it could read the old format, but it wouldn't produce the old format if there's only one dictionary. I'll add that, so both read and write support the old format if there is only on dict. |
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/objdetect/include/opencv2/objdetect/aruco_detector.hpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 373
**Code Changes:**
```diff
+ * Note that this function does not perform pose estimation.
+ * @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
+ * input image with corresponding camera model, if camera parameters are known
+ * @sa undistort, estimatePoseSingleMarkers, estimatePoseBoard
+ */
+ CV_WRAP void detectMarkersMultiDict(InputArray image, OutputArrayOfArrays corners, OutputArray ids,
+ OutputArrayOfArrays rejectedImgPoints = noArray(), OutputArray dictIndices = noArray()) const;
+
+ /** @brief Returns first dictionary from internal list used for marker detection.
+ *
+ * @return The first dictionary from the configured ArucoDetector.
``` | At least for the use case we have in mind you would want to scan dictionaries of different marker sizes, yes. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/include/opencv2/objdetect/aruco_detector.hpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -285,6 +285,16 @@ class CV_EXPORTS_W ArucoDetector : public Algorithm
const DetectorParameters &detectorParams = DetectorParameters(),
const RefineParameters& refineParams = RefineParameters());
+ /** @brief ArucoDetector constructor for multiple dictionaries
+ *
+ * @param dictionaries indicates the type of markers that will be searched. Empty dictionaries will throw an error.
+ * @param detectorParams marker detection parameters
+ * @param refineParams marker refine detection parameters
+ */
``` | 1. Alright, I've updated the PR to keep the behavior of the set/get functions and the ABI the same. 2. Yeah, good point with the iterators. I make it return a copy now. 3. I think I had tests already, but since you asked about it earlier, the most current version now has no add/remove functions and thus it's a lot easier to use and also easier to test. I hope this addresses all the concerns. I left a bit of documentation for the set/getDictionary functions so it's clear what they do with the dictionaries list. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -10,6 +10,7 @@
#include "apriltag/apriltag_quad_thresh.hpp"
#include "aruco_utils.hpp"
#include <cmath>
+#include <map>
namespace cv {
namespace aruco {
@@ -640,9 +641,14 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes
}
``` | Why not regular `std::set`? |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/test/test_arucodetection.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -6,6 +6,18 @@
#include "opencv2/objdetect/aruco_detector.hpp"
#include "opencv2/calib3d.hpp"
+namespace cv {
+ namespace aruco {
+ bool operator==(const Dictionary& d1, const Dictionary& d2);
+ bool operator==(const Dictionary& d1, const Dictionary& d2) {
+ return d1.markerSize == d2.markerSize
+ && std::equal(d1.bytesList.begin<Vec<uint8_t, 4>>(), d1.bytesList.end<Vec<uint8_t, 4>>(), d2.bytesList.begin<Vec<uint8_t, 4>>())
``` | Please use `cv::tempfile` for file name and make sure file is removed using `remove` at the end (no `ASSERT_` can be used). Alternatively you can try to use in-memory storage: https://github.com/opencv/opencv/blob/dbd3ef9a6f838d3ac42f8cf4d9d1dd5c709cb807/modules/features2d/test/test_matchers_algorithmic.cpp#L591-L595 |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/test/test_arucodetection.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -6,6 +6,18 @@
#include "opencv2/objdetect/aruco_detector.hpp"
#include "opencv2/calib3d.hpp"
+namespace cv {
+ namespace aruco {
+ bool operator==(const Dictionary& d1, const Dictionary& d2);
+ bool operator==(const Dictionary& d1, const Dictionary& d2) {
+ return d1.markerSize == d2.markerSize
+ && std::equal(d1.bytesList.begin<Vec<uint8_t, 4>>(), d1.bytesList.end<Vec<uint8_t, 4>>(), d2.bytesList.begin<Vec<uint8_t, 4>>())
``` | Failure to open file should become test failure. Here and in other places. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/include/opencv2/objdetect/aruco_detector.hpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 365
**Code Changes:**
```diff
+ * @param rejectedImgPoints contains the imgPoints of those squares whose inner code has not a
+ * correct codification. Useful for debugging purposes.
+ * @param dictIndices vector of dictionary indices for each detected marker. Use getDictionaries() to get the
+ * list of corresponding dictionaries.
+ *
+ * Performs marker detection in the input image. Only markers included in the specific dictionaries
+ * are searched. For each detected marker, it returns the 2D position of its corner in the image
+ * and its corresponding identifier.
+ * Note that this function does not perform pose estimation.
+ * @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
+ * input image with corresponding camera model, if camera parameters are known
``` | Perhaps it would be useful to define and test behavior in case when several dictionaries contain same markers. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -10,6 +10,7 @@
#include "apriltag/apriltag_quad_thresh.hpp"
#include "aruco_utils.hpp"
#include <cmath>
+#include <map>
namespace cv {
namespace aruco {
@@ -640,9 +641,14 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes
}
``` | If I understand correctly, this function filters candidates using marker size as a hint to estimate distances or something. Could dictionaries with different marker sizes affect detections of each other? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -10,6 +10,7 @@
#include "apriltag/apriltag_quad_thresh.hpp"
#include "aruco_utils.hpp"
#include <cmath>
+#include <map>
namespace cv {
namespace aruco {
@@ -640,9 +641,14 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes
}
``` | Can dictionary have marker size other than 4, 5, 6, 7? I don't see any checks in `Dictionary` constructor or other places. If it can, then we have possible out-of-bounds access. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 785
**Code Changes:**
```diff
+ if (_dictIndices.needed()) {
+ dictIndices.insert(dictIndices.end(), currentCandidates.size(), dictIndex);
+ }
+
+ /// STEP 3: Corner refinement :: use corner subpix
+ if (detectorParams.cornerRefinementMethod == (int)CORNER_REFINE_SUBPIX) {
+ performCornerSubpixRefinement(grey, grey_pyramid, closest_pyr_image_idx, currentCandidates, currentDictionary);
+ }
+ candidates.insert(candidates.end(), currentCandidates.begin(), currentCandidates.end());
+ dictIndex++;
+ }
``` | Is it possible to extract this large block to separate function to reduce code duplication? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -10,6 +10,7 @@
#include "apriltag/apriltag_quad_thresh.hpp"
#include "aruco_utils.hpp"
#include <cmath>
+#include <map>
namespace cv {
namespace aruco {
@@ -640,9 +641,14 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes
}
``` | Yeah, I was thinking about the predefined dictionaries only, but custom dictionaries could potentially break this. I made it more flexible that now any size of marker is supported. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -10,6 +10,7 @@
#include "apriltag/apriltag_quad_thresh.hpp"
#include "aruco_utils.hpp"
#include <cmath>
+#include <map>
namespace cv {
namespace aruco {
@@ -640,9 +641,14 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes
}
``` | That was also my worry and when reading into the code of the function it may affect candidates in some corner cases. This is why I'm making copies of the vectors before filtering, so the order of identifying with multiple dictionaries doesn't matter. The copies are an overhead though that I'd like to avoid. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/include/opencv2/objdetect/aruco_detector.hpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Review Line:** 365
**Code Changes:**
```diff
+ * @param rejectedImgPoints contains the imgPoints of those squares whose inner code has not a
+ * correct codification. Useful for debugging purposes.
+ * @param dictIndices vector of dictionary indices for each detected marker. Use getDictionaries() to get the
+ * list of corresponding dictionaries.
+ *
+ * Performs marker detection in the input image. Only markers included in the specific dictionaries
+ * are searched. For each detected marker, it returns the 2D position of its corner in the image
+ * and its corresponding identifier.
+ * Note that this function does not perform pose estimation.
+ * @note The function does not correct lens distortion or takes it into account. It's recommended to undistort
+ * input image with corresponding camera model, if camera parameters are known
``` | Good idea. Added a test that shows off how you can detect three markers for 2 similar dictionaries. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/aruco/aruco_detector.cpp
**Change Type:** modified
**Context:** PR #26934: Extend ArUcoDetector to run multiple dictionaries in an efficient manner.
**Code Changes:**
```diff
@@ -10,6 +10,7 @@
#include "apriltag/apriltag_quad_thresh.hpp"
#include "aruco_utils.hpp"
#include <cmath>
+#include <map>
namespace cv {
namespace aruco {
@@ -640,9 +641,14 @@ static inline void findCornerInPyrImage(const float scale_init, const int closes
}
``` | made it a map now as marker size needs to map to candidate tree. I made this connection now more deliberately and direct so I also don't need to calculate indices for other containers which may cause bounds issues as you correctly pointed out. |
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/test/test_thresh.cpp
**Change Type:** modified
**Context:** PR #26842: added optional mask to cv::threshold
**Code Changes:**
```diff
@@ -520,6 +520,98 @@ TEST(Imgproc_Threshold, threshold_dryrun)
}
}
+typedef tuple < bool, int, int, int, int > Imgproc_Threshold_Masked_Params_t;
+
+typedef testing::TestWithParam< Imgproc_Threshold_Masked_Params_t > Imgproc_Threshold_Masked_Fixed;
+
+TEST_P(Imgproc_Threshold_Masked_Fixed, threshold_mask_fixed)
+{
``` | I propose to use parameterized google test here. It generates all "loops" by itself and print options combination in case of failure |
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/test/test_thresh.cpp
**Change Type:** modified
**Context:** PR #26842: added optional mask to cv::threshold
**Code Changes:**
```diff
@@ -520,6 +520,98 @@ TEST(Imgproc_Threshold, threshold_dryrun)
}
}
+typedef tuple < bool, int, int, int, int > Imgproc_Threshold_Masked_Params_t;
+
+typedef testing::TestWithParam< Imgproc_Threshold_Masked_Params_t > Imgproc_Threshold_Masked_Fixed;
+
+TEST_P(Imgproc_Threshold_Masked_Fixed, threshold_mask_fixed)
+{
``` | If-else branches use different pattern and a bit different logic. I propose to split them on 2 test cases with different names. It also allows to get rid of complex logic with `isValidConfig` flag. |
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/imgproc/src/opencl/threshold_mask.cl
**Change Type:** added
**Context:** PR #26842: added optional mask to cv::threshold
**Code Changes:**
```diff
@@ -0,0 +1,60 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+// @Authors
+// Zhang Ying, zhangying913@gmail.com
+// Pierre Chatelier, pierre@chachatelier.fr
+
+#ifdef DOUBLE_SUPPORT
+#ifdef cl_amd_fp64
``` | I propose to use modern copyright header and mention the original OpenCL code author 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:** 3rdparty/hal_rvv/hal_rvv_1p0/magnitude.hpp
**Change Type:** added
**Context:** PR #27002: [HAL RVV] impl magnitude | add perf test
**Code Changes:**
```diff
@@ -0,0 +1,42 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2025, Institute of Software, Chinese Academy of Sciences.
+
+#ifndef OPENCV_HAL_RVV_MAGNITUDE_HPP_INCLUDED
+#define OPENCV_HAL_RVV_MAGNITUDE_HPP_INCLUDED
+
``` | I guess you can try the same as in https://github.com/opencv/opencv/pull/27015. |
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/src/mathfuncs_core.simd.hpp
**Change Type:** modified
**Context:** PR #27010: [HAL RVV] impl exp and log | add log perf test
**Code Changes:**
```diff
@@ -771,7 +771,7 @@ void log32f( const float *_x, float *y, int n )
int i = 0;
const int* x = (const int*)_x;
-#if CV_SIMD
+#if (CV_SIMD || CV_SIMD_SCALABLE)
const int VECSZ = VTraits<v_float32>::vlanes();
const v_float32 vln2 = vx_setall_f32((float)ln_2);
const v_float32 v1 = vx_setall_f32(1.f);
@@ -846,7 +846,7 @@ void log64f( const double *x, double *y, int n )
``` | It should be `CV_SIMD_SCALABLE_64F`. Double may be not supported by the platform. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/exp.hpp
**Change Type:** added
**Context:** PR #27010: [HAL RVV] impl exp and log | add log perf test
**Review Line:** 1
**Code Changes:**
```diff
@@ -0,0 +1,202 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level
+// directory of this distribution and at http://opencv.org/license.html.
+#pragma once
+
+#include <riscv_vector.h>
``` | Basic math function like exp and log may be used in other HAL implementation as well. Consider to put them in `common.hpp` or `common_utils.hpp` when we have such files. |
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_arithm.cpp
**Change Type:** modified
**Context:** PR #27010: [HAL RVV] impl exp and log | add log perf test
**Review Line:** 1102
**Code Changes:**
```diff
@@ -1099,7 +1099,7 @@ struct ExpOp : public BaseElemWiseOp
}
void getValueRange(int depth, double& minval, double& maxval)
{
- maxval = depth == CV_32F ? 50 : 100;
+ maxval = depth == CV_32F ? 80 : 700;
minval = -maxval;
}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
``` | Why changing the value here? |
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/test/test_arithm.cpp
**Change Type:** modified
**Context:** PR #27010: [HAL RVV] impl exp and log | add log perf test
**Review Line:** 1102
**Code Changes:**
```diff
@@ -1099,7 +1099,7 @@ struct ExpOp : public BaseElemWiseOp
}
void getValueRange(int depth, double& minval, double& maxval)
{
- maxval = depth == CV_32F ? 50 : 100;
+ maxval = depth == CV_32F ? 80 : 700;
minval = -maxval;
}
void op(const vector<Mat>& src, Mat& dst, const Mat&)
``` | > And I found a logical error in my implementation of `exp`, which caused the CI to fail. This error only occurs when the input is large enough, and that's why it passes all tests related to `exp` in the core module (Core_HAL/mathfuncs._:Core_Exp/ElemWiseTest_). This is discussed above. And the new value is approaching the limit of float/double. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/exp.hpp
**Change Type:** added
**Context:** PR #27010: [HAL RVV] impl exp and log | add log perf test
**Review Line:** 1
**Code Changes:**
```diff
@@ -0,0 +1,202 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level
+// directory of this distribution and at http://opencv.org/license.html.
+#pragma once
+
+#include <riscv_vector.h>
``` | Same discussion [here](https://github.com/opencv/opencv/pull/27000#discussion_r1986729939) |
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:** doc/tutorials/imgproc/table_of_content_imgproc.markdown
**Change Type:** modified
**Context:** PR #26441: Update tutorials
**Code Changes:**
```diff
@@ -1,8 +1,15 @@
Image Processing (imgproc module) {#tutorial_table_of_content_imgproc}
=================================
-Basic
------
+@tableofcontents
+
+The imgproc module in OpenCV is a collection of per-pixel image operations (color conversions, filters) drawing (contours, objects, text), and
+geometry transformations (warping, resize) useful for computer vision.
``` | The imgproc module in OpenCV is a collection of per-pixel image operations (color conversions, filters) drawing (contours, objects, text), and geometry transformations (warping, resize) useful for computer vision. Here's an overview of the content in the imgproc module, categorized for easier navigation. |
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/perf_lut.cpp
**Change Type:** modified
**Context:** PR #26941: Impl hal_rvv LUT | Add more LUT test
**Code Changes:**
```diff
@@ -24,4 +24,23 @@ PERF_TEST_P( SizePrm, LUT,
SANITY_CHECK(dst, 0.1);
}
+PERF_TEST_P( SizePrm, LUT_multi,
+ testing::Values(szQVGA, szVGA, sz1080p)
+ )
+{
+ Size sz = GetParam();
+
``` | My thoughts on dropping this test: 1. This patch does not bring speedup in case of multiple channels lut. 2. It does not check sanity. 3. You have added a regression test to test the accuracy of multi-channel lut. |
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/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #27112: cuda: Force C++17 Standard for CUDA targets when CUDA Toolkit >=12.8
**Code Changes:**
```diff
@@ -151,12 +151,14 @@ macro(ocv_cuda_compile VAR)
ocv_check_windows_crt_linkage()
ocv_nvcc_flags()
- if(UNIX OR APPLE)
- if(NOT " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG} ${CUDA_NVCC_FLAGS}" MATCHES "-std=")
+ if(NOT " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG} ${CUDA_NVCC_FLAGS}" MATCHES "-std=")
+ if(UNIX OR APPLE)
if(CUDA_VERSION VERSION_LESS "11.0")
list(APPEND CUDA_NVCC_FLAGS "--std=c++11")
``` | Why `--std=c++11` and `--std=c++14` are set for UNIX or APPLE, but -`-std=c++17` - for all platforms. Most probably it's a mistake. |
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/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #27112: cuda: Force C++17 Standard for CUDA targets when CUDA Toolkit >=12.8
**Code Changes:**
```diff
@@ -151,12 +151,14 @@ macro(ocv_cuda_compile VAR)
ocv_check_windows_crt_linkage()
ocv_nvcc_flags()
- if(UNIX OR APPLE)
- if(NOT " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG} ${CUDA_NVCC_FLAGS}" MATCHES "-std=")
+ if(NOT " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG} ${CUDA_NVCC_FLAGS}" MATCHES "-std=")
+ if(UNIX OR APPLE)
if(CUDA_VERSION VERSION_LESS "11.0")
list(APPEND CUDA_NVCC_FLAGS "--std=c++11")
``` | Please presume the empty line. |
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/OpenCVDetectCUDA.cmake
**Change Type:** modified
**Context:** PR #27112: cuda: Force C++17 Standard for CUDA targets when CUDA Toolkit >=12.8
**Code Changes:**
```diff
@@ -151,12 +151,14 @@ macro(ocv_cuda_compile VAR)
ocv_check_windows_crt_linkage()
ocv_nvcc_flags()
- if(UNIX OR APPLE)
- if(NOT " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG} ${CUDA_NVCC_FLAGS}" MATCHES "-std=")
+ if(NOT " ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_DEBUG} ${CUDA_NVCC_FLAGS}" MATCHES "-std=")
+ if(UNIX OR APPLE)
if(CUDA_VERSION VERSION_LESS "11.0")
list(APPEND CUDA_NVCC_FLAGS "--std=c++11")
``` | Perhaps Windows requires other flags (of there is similar problem - need Windows configuration to check that first). BTW, We use `CMAKE_CXX_STANDARD` variable for general C++ code: https://github.com/opencv/opencv/blob/4.11.0/cmake/OpenCVDetectCXXCompiler.cmake#L211 May be we should have proper `try_compile()` check for nvcc? Perhaps `CMAKE_CXX_STANDARD` should be tuned (or checked/[forced](https://github.com/opencv/opencv/blob/4.11.0/cmake/OpenCVFindProtobuf.cmake#L83-L85)) instead of manual flags |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/sqrt.hpp
**Change Type:** added
**Context:** PR #27015: [HAL RVV] impl sqrt and invSqrt
**Code Changes:**
```diff
@@ -0,0 +1,122 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level
+// directory of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_SQRT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_SQRT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+#include <cmath>
+#include "hal_rvv_1p0/types.hpp"
``` | nit: Use something like below https://github.com/opencv/opencv/blob/12d182bf9e2fa518aafad75dd5b77835c75674b4/3rdparty/hal_rvv/hal_rvv_1p0/merge.hpp#L4-L5 |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/sqrt.hpp
**Change Type:** added
**Context:** PR #27015: [HAL RVV] impl sqrt and invSqrt
**Review Line:** 49
**Code Changes:**
```diff
+ t = __riscv_vfmul(t, x2, vl);
+ t = __riscv_vfrsub(t, 1.5, vl);
+ y = __riscv_vfmul(t, y, vl);
+ }
+ // just to prevent the compiler from calculating mask before the invSqrt, which will run out
+ // of registers and cause memory access.
+ asm volatile("" ::: "memory");
+ auto mask = __riscv_vmfne(x, 0.0, vl);
+ mask = __riscv_vmfne_mu(mask, mask, x, INFINITY, vl);
+ return __riscv_vfmul_mu(mask, x, x, y, vl);
+}
``` | How does this happen? |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/sqrt.hpp
**Change Type:** added
**Context:** PR #27015: [HAL RVV] impl sqrt and invSqrt
**Code Changes:**
```diff
@@ -0,0 +1,122 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level
+// directory of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_SQRT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_SQRT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+#include <cmath>
+#include "hal_rvv_1p0/types.hpp"
``` | Considering that RISC-V is relatively new, it's unlikely any compiler that doesn't support `#pragma once`. So I think using `#pragma once` should be acceptable. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/sqrt.hpp
**Change Type:** added
**Context:** PR #27015: [HAL RVV] impl sqrt and invSqrt
**Code Changes:**
```diff
@@ -0,0 +1,122 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level
+// directory of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_SQRT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_SQRT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+#include <cmath>
+#include "hal_rvv_1p0/types.hpp"
``` | Just follow the convention to avoid confusion. |
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/hal_rvv/hal_rvv_1p0/sqrt.hpp
**Change Type:** added
**Context:** PR #27015: [HAL RVV] impl sqrt and invSqrt
**Review Line:** 49
**Code Changes:**
```diff
+ t = __riscv_vfmul(t, x2, vl);
+ t = __riscv_vfrsub(t, 1.5, vl);
+ y = __riscv_vfmul(t, y, vl);
+ }
+ // just to prevent the compiler from calculating mask before the invSqrt, which will run out
+ // of registers and cause memory access.
+ asm volatile("" ::: "memory");
+ auto mask = __riscv_vmfne(x, 0.0, vl);
+ mask = __riscv_vmfne_mu(mask, mask, x, INFINITY, vl);
+ return __riscv_vfmul_mu(mask, x, x, y, vl);
+}
``` | In the `for` loop (calculating `invSqrt`), at most four variables, `x`, `x2`, `y`, `t`, need to be stored simultaneously, so it occupies at least 4 LMUL registers. However, after exiting the `for` loop, only `x` and `y` need to be retained. Therefore, when using mask registers, the number of registers used should not exceed the previous 4 LMUL. However, without a memory barrier, both GCC and Clang from the `riscv-collab/riscv-gnu-toolchain` release `Nightly: December 16, 2024` tend to do the mask calculation first, causing the `for` loop to require 4 LMUL registers plus one additional mask register at the same time. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/src/persistence_base64_encoding.cpp
**Change Type:** modified
**Context:** PR #26937: Support bool type for FileStorage Base64
**Code Changes:**
```diff
@@ -202,6 +202,7 @@ int base64::icvCalcStructSize(const char *dt, int initial_size) {
switch ( *type )
{
case 'u': { elem_max_size = std::max( elem_max_size, sizeof(uchar ) ); break; }
+ case 'b': { elem_max_size = std::max( elem_max_size, sizeof(uchar ) ); break; }
case 'c': { elem_max_size = std::max( elem_max_size, sizeof(schar ) ); break; }
case 'w': { elem_max_size = std::max( elem_max_size, sizeof(ushort) ); break; }
case 's': { elem_max_size = std::max( elem_max_size, sizeof(short ) ); break; }
@@ -333,6 +334,10 @@ size_t base64::RawDataToBinaryConvertor::make_to_binary_funcs(const std::string
size = sizeof(uchar);
``` | sizeof(bool) may be different on different platforms. `to_binary()` converts it to uchar. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/src/persistence_base64_encoding.cpp
**Change Type:** modified
**Context:** PR #26937: Support bool type for FileStorage Base64
**Code Changes:**
```diff
@@ -202,6 +202,7 @@ int base64::icvCalcStructSize(const char *dt, int initial_size) {
switch ( *type )
{
case 'u': { elem_max_size = std::max( elem_max_size, sizeof(uchar ) ); break; }
+ case 'b': { elem_max_size = std::max( elem_max_size, sizeof(uchar ) ); break; }
case 'c': { elem_max_size = std::max( elem_max_size, sizeof(schar ) ); break; }
case 'w': { elem_max_size = std::max( elem_max_size, sizeof(ushort) ); break; }
case 's': { elem_max_size = std::max( elem_max_size, sizeof(short ) ); break; }
@@ -333,6 +334,10 @@ size_t base64::RawDataToBinaryConvertor::make_to_binary_funcs(const std::string
size = sizeof(uchar);
``` | sizeof(bool) may be different on different platforms. to_binary() converts it to uchar. |
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/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Code Changes:**
```diff
@@ -756,10 +756,28 @@ inline int hal_ni_dft1D(cvhalDFT *context, const uchar *src, uchar *dst) { retur
*/
inline int hal_ni_dftFree1D(cvhalDFT *context) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
+/**
+@param src source data
+@param dst destination data
+@param depth depth of source
+@param nf OcvDftOptions data
+@param factors OcvDftOptions data
``` | Why do you need Ocv suffix here and on the caller side? It breaks existing code style. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/dxt.hpp
**Change Type:** added
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Code Changes:**
```diff
@@ -0,0 +1,569 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+
+namespace cv { namespace cv_hal_rvv { namespace dxt {
``` | Could you add reference to paper or other implementation details. |
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/hal_rvv/hal_rvv_1p0/dxt.hpp
**Change Type:** added
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Code Changes:**
```diff
@@ -0,0 +1,569 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+
+namespace cv { namespace cv_hal_rvv { namespace dxt {
``` | It was copied from core/src/dxt.cpp, I have added some comments on it. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/dxt.hpp
**Change Type:** added
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Code Changes:**
```diff
@@ -0,0 +1,569 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+
+namespace cv { namespace cv_hal_rvv { namespace dxt {
``` | Usually we do not indent code inside namespaced: ```.cpp namespace myns { void exampleFunction(); } ``` |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/dxt.hpp
**Change Type:** added
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Code Changes:**
```diff
@@ -0,0 +1,569 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+
+namespace cv { namespace cv_hal_rvv { namespace dxt {
``` | Perhaps eventually it would make sense to unify this helper structure with others (minmax) and move it to separate header. |
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/hal_rvv/hal_rvv_1p0/dxt.hpp
**Change Type:** added
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Code Changes:**
```diff
@@ -0,0 +1,569 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+
+namespace cv { namespace cv_hal_rvv { namespace dxt {
``` | Technically this macro is not available for HAL implementations - only things from `*/hal/interface.h` should be used. It works because this HAL is header-only and is included after cvdef.h. |
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/hal_rvv/hal_rvv_1p0/dxt.hpp
**Change Type:** added
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Code Changes:**
```diff
@@ -0,0 +1,569 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+#define OPENCV_HAL_RVV_DXT_HPP_INCLUDED
+
+#include <riscv_vector.h>
+
+namespace cv { namespace cv_hal_rvv { namespace dxt {
``` | It would be hard to unify because different algorithms need different EMUL to achieve best performance. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9
**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
#include <riscv_vector.h>
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
#undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
#undef cv_hal_minMaxIdxMaskStep
``` | Reasons to add yet another layer of namespace? It breaks all the current code. Revert this and other changes on adding namespaces if possible. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9
**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
#include <riscv_vector.h>
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
#undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
#undef cv_hal_minMaxIdxMaskStep
``` | There will be naming conflicts about `template rvv<T>`. If there is no namespace (using anonymous space cannot solve the problem), there will be names such as `rvv_dxt` and `rvv_minmax`. In addition, some HAL implementations have some singleton classes, and I think it is inappropriate to expose these classes in `cv_hal_rvv`. |
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9
**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
#include <riscv_vector.h>
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
#undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
#undef cv_hal_minMaxIdxMaskStep
``` | There are already several interfaces added. Your change is not complete and I propose to do it in a separate PR if you want to. This PR seems to be fine without this namespace change. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9
**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
#include <riscv_vector.h>
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
#undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
#undef cv_hal_minMaxIdxMaskStep
``` | Do you think I should use `rvv_dxt` and `rvv_minmax`? Or should I keep the `namespace dxt` in this PR and keep `minmax.hpp` without namespace? |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9
**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
#include <riscv_vector.h>
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
#undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
#undef cv_hal_minMaxIdxMaskStep
``` | > There will be naming conflicts about template rvv<T> Could you give me an example to demonstrate the problem? --- > Or should I keep the namespace dxt in this PR and keep minmax.hpp without namespace? I don't see problem with this solution for now. |
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:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9
**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
#include <riscv_vector.h>
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
#undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
#undef cv_hal_minMaxIdxMaskStep
``` | ```cpp mimmax.hpp: #pragma once namespace cv { namespace cv_hal_rvv { template<typename T> rvv; template<> rvv<int> { ... }; }} dxt.hpp: #pragma once namespace cv { namespace cv_hal_rvv { template<typename T> rvv; template<> rvv<int> { ... }; }} hal_rvv.hpp: #include "hal_rvv_1p0/minmax.hpp" #include "hal_rvv_1p0/dxt.hpp" xxxx.cpp: #include "hal_rvv.hpp" // error ``` |
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** modified
**Context:** PR #26865: Add RISC-V HAL implementation for cv::dft and cv::dct
**Review Line:** 9
**Code Changes:**
```diff
+#define OPENCV_HAL_RVV_MINMAX_HPP_INCLUDED
#include <riscv_vector.h>
-namespace cv { namespace cv_hal_rvv {
+namespace cv { namespace cv_hal_rvv { namespace minmax {
#undef cv_hal_minMaxIdx
-#define cv_hal_minMaxIdx cv::cv_hal_rvv::minMaxIdx
+#define cv_hal_minMaxIdx cv::cv_hal_rvv::minmax::minMaxIdx
#undef cv_hal_minMaxIdxMaskStep
``` | > There are already several interfaces added. Interfaces that don't have `rvv` structures don't have to make this change. The only thing that really needs to be changed right now is `minmax`. |
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/hal/intrin_rvv_scalable.hpp
**Change Type:** modified
**Context:** PR #27006: Fix issues in RISC-V Vector (RVV) Universal Intrinsic
**Code Changes:**
```diff
@@ -8,6 +8,7 @@
#ifndef OPENCV_HAL_INTRIN_RVV_SCALABLE_HPP
#define OPENCV_HAL_INTRIN_RVV_SCALABLE_HPP
+#include <array>
#include <opencv2/core/check.hpp>
#if defined(__GNUC__) && !defined(__clang__)
@@ -62,8 +63,9 @@ struct VTraits<REG> \
{ \
``` | What about using std::array to store `idx_interleave_quads` so that we can get array length instead of a fixed number here to avoid mistakes. |
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/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #27006: Fix issues in RISC-V Vector (RVV) Universal Intrinsic
**Review Line:** 993
**Code Changes:**
```diff
- dataC *= (LaneType)-1;
+ for (int i = 0; i < VTraits<R>::vlanes(); i++)
+ {
+ auto c_signed = dataC.as_int(i);
+ dataC[i] = (LaneType)(c_signed == 0 ? -1 : -std::abs(c_signed));
+ }
R a = dataA, b = dataB, c = dataC, d = dataD, e = dataE;
dataC[VTraits<R>::vlanes() - 1] = 0;
R nl = dataC;
@@ -1905,7 +1917,7 @@ template<typename R> struct TheTest
EXPECT_TRUE(std::isnan(outputs[j]));
``` | Why do we need to change that? ~~It is code for testing, all checks are below.~~ Code of input preparation - so it is OK. |
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/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #27006: Fix issues in RISC-V Vector (RVV) Universal Intrinsic
**Review Line:** 993
**Code Changes:**
```diff
- dataC *= (LaneType)-1;
+ for (int i = 0; i < VTraits<R>::vlanes(); i++)
+ {
+ auto c_signed = dataC.as_int(i);
+ dataC[i] = (LaneType)(c_signed == 0 ? -1 : -std::abs(c_signed));
+ }
R a = dataA, b = dataB, c = dataC, d = dataD, e = dataE;
dataC[VTraits<R>::vlanes() - 1] = 0;
R nl = dataC;
@@ -1905,7 +1917,7 @@ template<typename R> struct TheTest
EXPECT_TRUE(std::isnan(outputs[j]));
``` | Because we need `dataC` to be all negative numbers, then `v_check_all(c)` will be `true`. ``` R c = dataC; EXPECT_EQ(true, v_check_all(c)); ``` The previous `dataC *= (LaneType)-1;` cannot handle the case where the length of `dataC` greater than `128` for `int_8` |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
next_seq_num = 0;
trnssize = 0;
palsize = 0;
+ m_compression_level = Z_BEST_SPEED;
+ m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+ m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+ m_isBilevel = false;
memset(palette, 0, sizeof(palette));
memset(trns, 0, sizeof(trns));
``` | for better readibility, should i replace with ``` if (animation.frames.size() == 1) return write(animation.frames[0], params); ``` |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
next_seq_num = 0;
trnssize = 0;
palsize = 0;
+ m_compression_level = Z_BEST_SPEED;
+ m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+ m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+ m_isBilevel = false;
memset(palette, 0, sizeof(palette));
memset(trns, 0, sizeof(trns));
``` | I still think this is an error: a 1-frame APNG is not the same as a PNG. The spec allows for 1 frame APNG: "1 is a valid value for a single-frame APNG.", cf https://wiki.mozilla.org/APNG_Specification |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
next_seq_num = 0;
trnssize = 0;
palsize = 0;
+ m_compression_level = Z_BEST_SPEED;
+ m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+ m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+ m_isBilevel = false;
memset(palette, 0, sizeof(palette));
memset(trns, 0, sizeof(trns));
``` | Well, that is a bug in itself. Sure, usually, when you ask for a 1-frame APNG, the user probably wants a PNG but OpenCV should not be the one to decide. |
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
next_seq_num = 0;
trnssize = 0;
palsize = 0;
+ m_compression_level = Z_BEST_SPEED;
+ m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+ m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+ m_isBilevel = false;
memset(palette, 0, sizeof(palette));
memset(trns, 0, sizeof(trns));
``` | It breaks `compression_level = Z_BEST_SPEED;` in constructor. |
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
next_seq_num = 0;
trnssize = 0;
palsize = 0;
+ m_compression_level = Z_BEST_SPEED;
+ m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+ m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+ m_isBilevel = false;
memset(palette, 0, sizeof(palette));
memset(trns, 0, sizeof(trns));
``` | Why not just set Z_BEST_SPEED in constructor and remove the line here? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -814,6 +814,10 @@ PngEncoder::PngEncoder()
next_seq_num = 0;
trnssize = 0;
palsize = 0;
+ m_compression_level = Z_BEST_SPEED;
+ m_compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+ m_filter = IMWRITE_PNG_FILTER_SUB; // Default filter
+ m_isBilevel = false;
memset(palette, 0, sizeof(palette));
memset(trns, 0, sizeof(trns));
``` | then https://github.com/opencv/opencv/blob/4.x/modules/imgcodecs/src/grfmt_png.cpp#L910-L920 will be meaningless without `compression_level = -1;` let me look later with a fresh mind |
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/perf/perf_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -11,7 +11,10 @@ namespace opencv_test
using namespace perf;
-typedef perf::TestBaseWithParam<std::string> PNG;
+CV_ENUM(PNGStrategy, IMWRITE_PNG_STRATEGY_DEFAULT, IMWRITE_PNG_STRATEGY_FILTERED, IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, IMWRITE_PNG_STRATEGY_RLE, IMWRITE_PNG_STRATEGY_FIXED);
+CV_ENUM(PNGFilters, IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, IMWRITE_PNG_FILTER_UP, IMWRITE_PNG_FILTER_AVG, IMWRITE_PNG_FILTER_PAETH, IMWRITE_PNG_FAST_FILTERS, IMWRITE_PNG_ALL_FILTERS);
+
+typedef perf::TestBaseWithParam<testing::tuple<PNGStrategy, PNGFilters, int>> PNG;
``` | Please use CV_ENUM instead of int like here: https://github.com/opencv/opencv/blob/d32d4da9a39ce92bdc5603749ea6f2d90215f4ea/modules/imgproc/test/test_templmatch.cpp#L306 GTest prints enum names instead of magic integer values. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/perf/perf_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -11,7 +11,10 @@ namespace opencv_test
using namespace perf;
-typedef perf::TestBaseWithParam<std::string> PNG;
+CV_ENUM(PNGStrategy, IMWRITE_PNG_STRATEGY_DEFAULT, IMWRITE_PNG_STRATEGY_FILTERED, IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, IMWRITE_PNG_STRATEGY_RLE, IMWRITE_PNG_STRATEGY_FIXED);
+CV_ENUM(PNGFilters, IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, IMWRITE_PNG_FILTER_UP, IMWRITE_PNG_FILTER_AVG, IMWRITE_PNG_FILTER_PAETH, IMWRITE_PNG_FAST_FILTERS, IMWRITE_PNG_ALL_FILTERS);
+
+typedef perf::TestBaseWithParam<testing::tuple<PNGStrategy, PNGFilters, int>> PNG;
``` | Why is it disabled? |
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/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
IMWRITE_PNG_BILEVEL = 18, //!< Binary level PNG, 0 or 1, default is 0.
+ IMWRITE_PNG_FILTER = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
IMWRITE_EXR_TYPE = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
IMWRITE_EXR_COMPRESSION = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
IMWRITE_PNG_STRATEGY_FIXED = 4 //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
``` | What is difference between IMWRITE_PNG_NO_FILTERS and IMWRITE_PNG_FILTER_NONE? Why do we need both? |
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/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Review Line:** 99
**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
IMWRITE_PNG_BILEVEL = 18, //!< Binary level PNG, 0 or 1, default is 0.
+ IMWRITE_PNG_FILTER = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
IMWRITE_EXR_TYPE = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
IMWRITE_EXR_COMPRESSION = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
IMWRITE_PNG_STRATEGY_FIXED = 4 //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
``` | Are there any changes against 4.11 (APNG support) and 4.10 (old style PNG)? |
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/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Review Line:** 99
**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
IMWRITE_PNG_BILEVEL = 18, //!< Binary level PNG, 0 or 1, default is 0.
+ IMWRITE_PNG_FILTER = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
IMWRITE_EXR_TYPE = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
IMWRITE_EXR_COMPRESSION = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
IMWRITE_PNG_STRATEGY_FIXED = 4 //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
``` | It'll be great to add some accuracy test for the new option. You can, for example, compare file sizes or byte array sizes to ensure the compression applied properly. |
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/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Review Line:** 99
**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
IMWRITE_PNG_BILEVEL = 18, //!< Binary level PNG, 0 or 1, default is 0.
+ IMWRITE_PNG_FILTER = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
IMWRITE_EXR_TYPE = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
IMWRITE_EXR_COMPRESSION = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
IMWRITE_PNG_STRATEGY_FIXED = 4 //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
``` | > It'll be great to add some accuracy test for the new option. You can, for example, compare file sizes or byte array sizes to ensure the compression applied properly. as far as i tested file sizes are various according used zlib or zlib-ng ( maybe also used versions creates different sizes) |
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/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Review Line:** 99
**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
IMWRITE_PNG_BILEVEL = 18, //!< Binary level PNG, 0 or 1, default is 0.
+ IMWRITE_PNG_FILTER = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
IMWRITE_EXR_TYPE = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
IMWRITE_EXR_COMPRESSION = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
IMWRITE_PNG_STRATEGY_FIXED = 4 //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
``` | Let's compare fast/best compression to ensure best is smaller the fast, for example. |
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/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
IMWRITE_PNG_BILEVEL = 18, //!< Binary level PNG, 0 or 1, default is 0.
+ IMWRITE_PNG_FILTER = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
IMWRITE_EXR_TYPE = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
IMWRITE_EXR_COMPRESSION = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
IMWRITE_PNG_STRATEGY_FIXED = 4 //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
``` | they produces different sized outputs |
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/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Review Line:** 99
**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
IMWRITE_PNG_BILEVEL = 18, //!< Binary level PNG, 0 or 1, default is 0.
+ IMWRITE_PNG_FILTER = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
IMWRITE_EXR_TYPE = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
IMWRITE_EXR_COMPRESSION = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
IMWRITE_PNG_STRATEGY_FIXED = 4 //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
``` | > Are there any changes against 4.11 (APNG support) and 4.10 (old style PNG)? default values are same as 4.10 |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/perf/perf_png.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -11,7 +11,10 @@ namespace opencv_test
using namespace perf;
-typedef perf::TestBaseWithParam<std::string> PNG;
+CV_ENUM(PNGStrategy, IMWRITE_PNG_STRATEGY_DEFAULT, IMWRITE_PNG_STRATEGY_FILTERED, IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY, IMWRITE_PNG_STRATEGY_RLE, IMWRITE_PNG_STRATEGY_FIXED);
+CV_ENUM(PNGFilters, IMWRITE_PNG_FILTER_NONE, IMWRITE_PNG_FILTER_SUB, IMWRITE_PNG_FILTER_UP, IMWRITE_PNG_FILTER_AVG, IMWRITE_PNG_FILTER_PAETH, IMWRITE_PNG_FAST_FILTERS, IMWRITE_PNG_ALL_FILTERS);
+
+typedef perf::TestBaseWithParam<testing::tuple<PNGStrategy, PNGFilters, int>> PNG;
``` | when a common user run it takes so long time ( --perf_force_samples default value is 100 ) |
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/imgcodecs/include/opencv2/imgcodecs.hpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -96,6 +96,7 @@ enum ImwriteFlags {
IMWRITE_PNG_COMPRESSION = 16, //!< For PNG, it can be the compression level from 0 to 9. A higher value means a smaller size and longer compression time. If specified, strategy is changed to IMWRITE_PNG_STRATEGY_DEFAULT (Z_DEFAULT_STRATEGY). Default value is 1 (best speed setting).
IMWRITE_PNG_STRATEGY = 17, //!< One of cv::ImwritePNGFlags, default is IMWRITE_PNG_STRATEGY_RLE.
IMWRITE_PNG_BILEVEL = 18, //!< Binary level PNG, 0 or 1, default is 0.
+ IMWRITE_PNG_FILTER = 19, //!< One of cv::ImwritePNGFilterFlags, default is IMWRITE_PNG_FILTER_SUB.
IMWRITE_PXM_BINARY = 32, //!< For PPM, PGM, or PBM, it can be a binary format flag, 0 or 1. Default value is 1.
IMWRITE_EXR_TYPE = (3 << 4) + 0 /* 48 */, //!< override EXR storage type (FLOAT (FP32) is default)
IMWRITE_EXR_COMPRESSION = (3 << 4) + 1 /* 49 */, //!< override EXR compression type (ZIP_COMPRESSION = 3 is default)
@@ -211,6 +212,17 @@ enum ImwritePNGFlags {
IMWRITE_PNG_STRATEGY_FIXED = 4 //!< Using this value prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications.
``` | IMWRITE_PNG_NO_FILTERS removed. with libpng IMWRITE_PNG_NO_FILTERS and IMWRITE_PNG_ALL_FILTERS gives same results. with libspng IMWRITE_PNG_NO_FILTERS and IMWRITE_PNG_FILTER_NONE gives same results. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/src/grfmt_spng.cpp
**Change Type:** modified
**Context:** PR #26849: APNG encoding optimization
**Code Changes:**
```diff
@@ -535,9 +535,12 @@ bool SPngEncoder::write(const Mat &img, const std::vector<int> ¶ms)
struct spng_ihdr ihdr = {};
ihdr.height = height;
ihdr.width = width;
- int compression_level = -1; // Invalid value to allow setting 0-9 as valid
+ int compression_level = Z_BEST_SPEED;
int compression_strategy = IMWRITE_PNG_STRATEGY_RLE; // Default strategy
+ int filter = IMWRITE_PNG_FILTER_SUB; // Default filter
bool isBilevel = false;
+ bool set_compression_level = false;
``` | those two should not be outside `if (ctx)` below right? I guess they should be kept right after `ihdr.width = width;` no ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.