instruction
stringclasses
9 values
input
stringlengths
279
5.47k
output
stringlengths
6
9.58k
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/test/test_convhull.cpp **Change Type:** modified **Context:** PR #25842: imgproc: remove C-API usage from tests - Final cleanup will be done in 5.x after regular merge. Some tests have been reworked, some require... **Code Changes:** ```diff @@ -39,2026 +39,93 @@ // //M*/ +#include "opencv2/core/hal/interface.h" +#include "opencv2/ts.hpp" +#include "opencv2/ts/cuda_test.hpp" #include "test_precomp.hpp" namespace opencv_test { namespace { ```
The branches are the same besides convertTo/copyTo. Let's extract common part.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/core/include/opencv2/core/cvdef.h **Change Type:** modified **Context:** PR #25796: Use `hfloat` instead of `__fp16`. **Review Line:** 823 **Code Changes:** ```diff { public: #if CV_FP16_TYPE - - hfloat() : h(0) {} + hfloat() = default; explicit hfloat(float x) { h = (__fp16)x; } operator float() const { return (float)h; } +#if defined __ARM_FP16_FORMAT_IEEE protected: __fp16 h; ```
This doesn't guarantee zero value.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/core/include/opencv2/core/cvdef.h **Change Type:** modified **Context:** PR #25796: Use `hfloat` instead of `__fp16`. **Review Line:** 387 **Code Changes:** ```diff @@ -384,8 +384,10 @@ typedef union Cv16suf { short i; ushort u; -#if CV_FP16_TYPE +#if CV_FP16_TYPE && defined __ARM_FP16_FORMAT_IEEE __fp16 h; +#elif CV_FP16_TYPE // Other platforms suggested to use _Float16 + _Float16 h; #endif } ```
We should not limit that to ARM only
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.hpp **Change Type:** modified **Context:** PR #25796: Use `hfloat` instead of `__fp16`. **Review Line:** 169 **Code Changes:** ```diff @@ -166,7 +166,7 @@ CV_INTRIN_DEF_TYPE_TRAITS(schar, schar, uchar, uchar, short, int, int); CV_INTRIN_DEF_TYPE_TRAITS(ushort, short, ushort, ushort, unsigned, uint64, unsigned); CV_INTRIN_DEF_TYPE_TRAITS(short, short, ushort, ushort, int, int64, int); #if CV_FP16_TYPE -CV_INTRIN_DEF_TYPE_TRAITS(__fp16, short, ushort, __fp16, float, double, float); +CV_INTRIN_DEF_TYPE_TRAITS(hfloat, short, ushort, hfloat, float, double, float); #endif CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(unsigned, int, unsigned, unsigned, uint64, unsigned); CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(int, int, unsigned, unsigned, int64, int); @@ -370,7 +370,7 @@ template<typename _Tp> struct V_RegTraits CV_DEF_REG_TRAITS(v, v_uint16x8, ushort, u16, v_uint16x8, v_uint32x4, v_uint64x2, v_int16x8, void); ```
SIMD intrinsics are low level and they should not use `hfloat`-like shim types. OpenCV intrinsics should provide own type via `typedef` depending on backend (with helper functions). We are not expecting that intrinsics work with "ushort" (we already had that mess in DNN module).
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/include/opencv2/core/hal/intrin.hpp **Change Type:** modified **Context:** PR #25796: Use `hfloat` instead of `__fp16`. **Review Line:** 169 **Code Changes:** ```diff @@ -166,7 +166,7 @@ CV_INTRIN_DEF_TYPE_TRAITS(schar, schar, uchar, uchar, short, int, int); CV_INTRIN_DEF_TYPE_TRAITS(ushort, short, ushort, ushort, unsigned, uint64, unsigned); CV_INTRIN_DEF_TYPE_TRAITS(short, short, ushort, ushort, int, int64, int); #if CV_FP16_TYPE -CV_INTRIN_DEF_TYPE_TRAITS(__fp16, short, ushort, __fp16, float, double, float); +CV_INTRIN_DEF_TYPE_TRAITS(hfloat, short, ushort, hfloat, float, double, float); #endif CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(unsigned, int, unsigned, unsigned, uint64, unsigned); CV_INTRIN_DEF_TYPE_TRAITS_NO_Q_TYPE(int, int, unsigned, unsigned, int64, int); @@ -370,7 +370,7 @@ template<typename _Tp> struct V_RegTraits CV_DEF_REG_TRAITS(v, v_uint16x8, ushort, u16, v_uint16x8, v_uint32x4, v_uint64x2, v_int16x8, void); ```
Discussed offline. It seems fine to use `hfloat` as **external** interface for scalar/pointer FP16 types of universal SIMD intrinsics.
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/core/include/opencv2/core/cvdef.h **Change Type:** modified **Context:** PR #25796: Use `hfloat` instead of `__fp16`. **Review Line:** 387 **Code Changes:** ```diff @@ -384,8 +384,10 @@ typedef union Cv16suf { short i; ushort u; -#if CV_FP16_TYPE +#if CV_FP16_TYPE && defined __ARM_FP16_FORMAT_IEEE __fp16 h; +#elif CV_FP16_TYPE // Other platforms suggested to use _Float16 + _Float16 h; #endif } ```
Looks like `__fp16` works well with ARM only. Other platforms suggested to use `_Float16`: - https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html - https://releases.llvm.org/16.0.0/tools/clang/docs/LanguageExtensions.html - https://en.cppreference.com/w/cpp/types/floating-point
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/core/include/opencv2/core/cvdef.h **Change Type:** modified **Context:** PR #25796: Use `hfloat` instead of `__fp16`. **Review Line:** 823 **Code Changes:** ```diff { public: #if CV_FP16_TYPE - - hfloat() : h(0) {} + hfloat() = default; explicit hfloat(float x) { h = (__fp16)x; } operator float() const { return (float)h; } +#if defined __ARM_FP16_FORMAT_IEEE protected: __fp16 h; ```
Yes, I didn't want to change this code, but `hfloat() : h(0) {}` will cause an error at compile time: ```bash opencv/modules/core/include/opencv2/core/hal/intrin.hpp:169:1 error: call to implicitly-deleted default constructor of 'union CV_INTRIN_DEF_TYPE_TRAITS(hfloat, short, ushort, hfloat, float, double, float); ^ opencv/modules/core/include/opencv2/core/hal/intrin.hpp:126:43: note: expanded from macro 'CV_INTRIN_DEF_TYPE_TRAITS' union { type l; int_type i; } v; \ ^ note: default constructor of '' is implicitly deleted because variant field 'l' has a non-trivial default constructor ``` Any suggestions?
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/core/include/opencv2/core/cvdef.h **Change Type:** modified **Context:** PR #25796: Use `hfloat` instead of `__fp16`. **Review Line:** 387 **Code Changes:** ```diff @@ -384,8 +384,10 @@ typedef union Cv16suf { short i; ushort u; -#if CV_FP16_TYPE +#if CV_FP16_TYPE && defined __ARM_FP16_FORMAT_IEEE __fp16 h; +#elif CV_FP16_TYPE // Other platforms suggested to use _Float16 + _Float16 h; #endif } ```
Agree, should we add `_Float16` part in `#else` block via this PR, or via the RISC-V PR https://github.com/opencv/opencv/pull/25743 after this PR has been merged?
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/core/include/opencv2/core/cvdef.h **Change Type:** modified **Context:** PR #25796: Use `hfloat` instead of `__fp16`. **Review Line:** 387 **Code Changes:** ```diff @@ -384,8 +384,10 @@ typedef union Cv16suf { short i; ushort u; -#if CV_FP16_TYPE +#if CV_FP16_TYPE && defined __ARM_FP16_FORMAT_IEEE __fp16 h; +#elif CV_FP16_TYPE // Other platforms suggested to use _Float16 + _Float16 h; #endif } ```
Let's try to add it for x86_64 platforms in this PR and extend to RISC-V later in #25743. If we make it in a separate commit, then it would be easy to cherry-pick or revert it if something goes wrong.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/core/include/opencv2/core/cvdef.h **Change Type:** modified **Context:** PR #25796: Use `hfloat` instead of `__fp16`. **Review Line:** 390 **Code Changes:** ```diff ushort u; -#if CV_FP16_TYPE +#if CV_FP16_TYPE && defined __ARM_FP16_FORMAT_IEEE __fp16 h; +#elif CV_FP16_TYPE // Other platforms suggested to use _Float16 + _Float16 h; #endif } Cv16suf; @@ -818,12 +820,16 @@ class hfloat { ```
If I understand correctly, currently there is no x86_64 platform satisfying this case because `CV_FP16_TYPE` is enabled only for `__ARM_FP16_FORMAT_IEEE`. And in order to test this branch we need to also add support for `-mavx512fp16` and maybe some other option for RISC-V. Am I correct?
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/core/include/opencv2/core/hal/intrin_cpp.hpp **Change Type:** modified **Context:** PR #25872: core: add v_erf **Review Line:** 267 **Code Changes:** ```diff ### Other math -- Some frequent operations: @ref v_sqrt, @ref v_invsqrt, @ref v_magnitude, @ref v_sqr_magnitude, @ref v_exp +- Some frequent operations: @ref v_sqrt, @ref v_invsqrt, @ref v_magnitude, @ref v_sqr_magnitude, @ref v_exp, + @ref v_erf - Absolute values: @ref v_abs, @ref v_absdiff, @ref v_absdiffs ### Conversions @@ -761,6 +762,13 @@ OPENCV_HAL_IMPL_MATH_FUNC(v_exp, std::exp, _Tp) OPENCV_HAL_IMPL_MATH_FUNC(v_log, std::log, _Tp) ```
/build/precommit_docs/4.x/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:269: warning: unable to resolve reference to 'v_erf' for \ref command
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/python/src2/gen2.py **Change Type:** modified **Context:** PR #25810: python: attempts to fix 3d mat parsing problem for dnn **Code Changes:** ```diff @@ -488,6 +488,10 @@ def export_name(self): return self.name + '_' return self.name + @property + def nd_mat(self): + return '/ND' in self._modifiers + @property def inputarg(self): ```
use `misc/python` instead.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/misc/python/test/test_dnn.py **Change Type:** modified **Context:** PR #25810: python: attempts to fix 3d mat parsing problem for dnn **Review Line:** 461 **Code Changes:** ```diff @@ -455,10 +455,6 @@ def test_input_3d(self): "Verify OPENCV_DNN_TEST_DATA_PATH configuration parameter.") input = np.load(input_file) - # we have to expand the shape of input tensor because Python bindings cut 3D tensors to 2D - # it should be fixed in future. see : https://github.com/opencv/opencv/issues/19091 - # please remove `expand_dims` after that - input = np.expand_dims(input, axis=3) gold_output = np.load(output_file) for backend, target in self.dnnBackendsAndTargets: @@ -469,10 +465,63 @@ def test_input_3d(self): net.setPreferableBackend(backend) net.setPreferableTarget(target) ```
`setInput` has been tested in this one. It was previously hacked to make it passed. --- I also added `CV_ND` macro for `setParam`. Does it need to be tested? This API is not tested any where though.
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:** CMakeLists.txt **Change Type:** modified **Context:** PR #25858: Enable KleidiCV for Android aarch64 by default. **Code Changes:** ```diff @@ -261,7 +261,7 @@ OCV_OPTION(WITH_CAP_IOS "Enable iOS video capture" ON VERIFY HAVE_CAP_IOS) OCV_OPTION(WITH_CAROTENE "Use NVidia carotene acceleration library for ARM platform" (NOT CV_DISABLE_OPTIMIZATION) VISIBLE_IF (ARM OR AARCH64) AND NOT IOS AND NOT XROS) -OCV_OPTION(WITH_KLEIDICV "Use KleidiCV library for ARM platforms" OFF +OCV_OPTION(WITH_KLEIDICV "Use KleidiCV library for ARM platforms" (ANDROID AND AARCH64 AND NOT CV_DISABLE_OPTIMIZATION) VISIBLE_IF (AARCH64 AND (ANDROID OR UNIX AND NOT IOS AND NOT XROS))) OCV_OPTION(WITH_NDSRVP "Use Andes RVP extension" (NOT CV_DISABLE_OPTIMIZATION) VISIBLE_IF RISCV) ```
`NOT CV_DISABLE_OPTIMIZATION`
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/segmentation.cpp **Change Type:** modified **Context:** PR #25756: [BUG FIX] Segmentation sample u2netp model results **Code Changes:** ```diff @@ -79,7 +79,7 @@ int main(int argc, char **argv) // Open file with classes names. if (parser.has("classes")) { - string file = parser.get<String>("classes"); + string file = findFile(parser.get<String>("classes")); ifstream ifs(file.c_str()); if (!ifs.is_open()) CV_Error(Error::StsError, "File " + file + " not found"); @@ -92,7 +92,7 @@ int main(int argc, char **argv) ```
Why do you remove the solution with overlays? It looks better, IMHO.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/models.yml **Change Type:** modified **Context:** PR #25756: [BUG FIX] Segmentation sample u2netp model results **Review Line:** 263 **Code Changes:** ```diff @@ -261,4 +261,4 @@ u2netp: width: 320 height: 320 rgb: true - sample: "segmentation" \ No newline at end of file + sample: "segmentation" ```
It's incorrect change. I checked the rembg/bg.py sample in the model release and the model expects RGB input, but not BGR.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/models.yml **Change Type:** modified **Context:** PR #25756: [BUG FIX] Segmentation sample u2netp model results **Code Changes:** ```diff @@ -261,4 +261,4 @@ u2netp: width: 320 height: 320 rgb: true - sample: "segmentation" \ No newline at end of file + sample: "segmentation" ```
The change looks suspicious. OpenCV subtracts mean and then divides by scale. Input image has 0..255 range.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/segmentation.cpp **Change Type:** modified **Context:** PR #25756: [BUG FIX] Segmentation sample u2netp model results **Code Changes:** ```diff @@ -79,7 +79,7 @@ int main(int argc, char **argv) // Open file with classes names. if (parser.has("classes")) { - string file = parser.get<String>("classes"); + string file = findFile(parser.get<String>("classes")); ifstream ifs(file.c_str()); if (!ifs.is_open()) CV_Error(Error::StsError, "File " + file + " not found"); @@ -92,7 +92,7 @@ int main(int argc, char **argv) ```
split is not needed here. You can create single channel Mat with zeros and then use it several times for merge, e.g.: ``` Mat all_zeros = Mat::zeros(frame.size(), CV_8UC1); vector<Mat> channels = {all_zeros, all_zeros, mask}; merge(channels, foreground_overlay); ```
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/videocapture_depth.cpp **Change Type:** added **Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap... **Code Changes:** ```diff @@ -0,0 +1,174 @@ +#include "opencv2/videoio.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/imgproc.hpp" + +#include <iostream> + +using namespace cv; + +static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f) ```
I propose to rename to OpenNI-Orbbec. Current name is not obvious.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/videocapture_depth.cpp **Change Type:** added **Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap... **Code Changes:** ```diff @@ -0,0 +1,174 @@ +#include "opencv2/videoio.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/imgproc.hpp" + +#include <iostream> + +using namespace cv; + +static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f) ```
`-h` / `--help` is not handled.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/videocapture_depth.cpp **Change Type:** added **Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap... **Code Changes:** ```diff @@ -0,0 +1,174 @@ +#include "opencv2/videoio.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/imgproc.hpp" + +#include <iostream> + +using namespace cv; + +static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f) ```
Invalid pixel values are unpredictable here, because `validColorDisparityMap` is not initialized. I propose not create `validColorDisparityMap`, but call setTo with mask for for `colorDisparityMap` to mark invalid pixels with black.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/videocapture_depth.cpp **Change Type:** added **Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap... **Code Changes:** ```diff @@ -0,0 +1,174 @@ +#include "opencv2/videoio.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/imgproc.hpp" + +#include <iostream> + +using namespace cv; + +static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f) ```
rgb = Mat::zeros(gray.size(), CV_8UC3);
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/videocapture_depth.cpp **Change Type:** added **Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap... **Code Changes:** ```diff @@ -0,0 +1,174 @@ +#include "opencv2/videoio.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/imgproc.hpp" + +#include <iostream> + +using namespace cv; + +static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f) ```
0 -> nullptr
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/videocapture_depth.cpp **Change Type:** added **Context:** PR #25410: Add videocapture_depth.cpp sample - The PR is to combine the examples `videocapture_openni.cpp`, `videocapture_realsense.cpp` and `videocap... **Code Changes:** ```diff @@ -0,0 +1,174 @@ +#include "opencv2/videoio.hpp" +#include "opencv2/highgui.hpp" +#include "opencv2/imgproc.hpp" + +#include <iostream> + +using namespace cv; + +static void colorizeDisparity(const Mat& gray, Mat& rgb, double maxDisp=-1.f) ```
It depends on camera optics and may be different. I propose to add it to command line parameters with default value and promote as function parameter here.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/layers/slice_layer.cpp **Change Type:** modified **Context:** PR #25861: Support for `Unflatten` operation requred by `Attention` layer - 4.x **Code Changes:** ```diff @@ -69,10 +69,12 @@ Range normalizeRange(const Range& input_range, int n) { Range range = input_range; - range.start = std::min(std::max(range.start, -n), n - 1); - if (range.start < 0) - { - range.start += n; + if (range.start != n){ + range.start = std::min(std::max(range.start, -n), n - 1); ```
`range.start != n`
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/test/test_onnx_importer.cpp **Change Type:** modified **Context:** PR #25861: Support for `Unflatten` operation requred by `Attention` layer - 4.x **Code Changes:** ```diff @@ -3034,6 +3034,13 @@ TEST_P(Test_ONNX_layers, Attention) { TEST_P(Test_ONNX_layers, AttentionSingleHead) { testONNXModels("attention_single_head"); } +TEST_P(Test_ONNX_layers, PyTorchAttentionSingleHead){ + testONNXModels("pytorch_attention_single_head"); +} + +TEST_P(Test_ONNX_layers, PyTorchUnflatten){ + testONNXModels("unflatten"); ```
`Torch` and `PyTorch` is different. I propose to name it `PyTorchXXX`.
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_jpeg.cpp **Change Type:** modified **Context:** PR #25809: imgcodecs: Add rgb flag for imread and imdecode **Review Line:** 530 **Code Changes:** ```diff + { + if( cinfo->out_color_components == 3 ) + icvCvt_RGB2BGR_8u_C3R( buffer[0], 0, data, 0, Size(m_width,1) ); + else + icvCvt_CMYK2BGR_8u_C4C3R( buffer[0], 0, data, 0, Size(m_width,1) ); + } } else { ```
If and else branch are the same.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_precomp.hpp **Change Type:** modified **Context:** PR #25809: imgcodecs: Add rgb flag for imread and imdecode **Code Changes:** ```diff @@ -51,6 +51,11 @@ void PrintTo(const ImreadModes& val, std::ostream* os) v &= ~IMREAD_IGNORE_ORIENTATION; *os << "IMREAD_IGNORE_ORIENTATION" << (v == 0 ? "" : " | "); } + if ((v & IMREAD_COLOR_RGB) != 0) + { + v &= ~IMREAD_COLOR_RGB; + *os << "IMREAD_COLOR_RGB" << (v == 0 ? "" : " | "); + } switch (v) ```
Assert is redundant 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/imgcodecs/test/test_tiff.cpp **Change Type:** modified **Context:** PR #25809: imgcodecs: Add rgb flag for imread and imdecode **Review Line:** 1087 **Code Changes:** ```diff const string root = cvtest::TS::ptr()->get_data_path(); @@ -1066,6 +1084,7 @@ const int all_modes[] = IMREAD_UNCHANGED, IMREAD_GRAYSCALE, IMREAD_COLOR, + IMREAD_COLOR_RGB, IMREAD_ANYDEPTH, IMREAD_ANYCOLOR }; ```
Tiff tests for RGB are weak. There is no test with pixels check against well known ground truth. The test compares tiff with tiff with the same flags.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_png.cpp **Change Type:** modified **Context:** PR #25809: imgcodecs: Add rgb flag for imread and imdecode **Review Line:** 93 **Code Changes:** ```diff + ASSERT_TRUE(img.channels() == 3); + + // pixel is red in RGB + EXPECT_EQ(img.at<Vec3b>(0, 0), Vec3b(255, 0, 0)); + EXPECT_EQ(img.at<Vec3b>(0, 1), Vec3b(255, 0, 0)); + // Fourth Test : Read PNG without alpha, imread flag 1 img = imread(root + "readwrite/color_palette_no_alpha.png", IMREAD_COLOR); ASSERT_FALSE(img.empty()); @@ -91,6 +99,14 @@ TEST(Imgcodecs_Png, read_color_palette_with_alpha) // pixel is red in BGR ```
I propose to add test with RGBA output.
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 #25809: imgcodecs: Add rgb flag for imread and imdecode **Review Line:** 83 **Code Changes:** ```diff IMREAD_REDUCED_COLOR_4 = 33, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/4. IMREAD_REDUCED_GRAYSCALE_8 = 64, //!< If set, always convert image to the single channel grayscale image and the image size reduced 1/8. IMREAD_REDUCED_COLOR_8 = 65, //!< If set, always convert image to the 3 channel BGR color image and the image size reduced 1/8. - IMREAD_IGNORE_ORIENTATION = 128 //!< If set, do not rotate the image according to EXIF's orientation flag. + IMREAD_IGNORE_ORIENTATION = 128, //!< If set, do not rotate the image according to EXIF's orientation flag. + IMREAD_COLOR_RGB = 256, //!< If set, always convert image to the 3 channel RGB color image. }; //! Imwrite flags @@ -268,7 +270,7 @@ Currently, the following file formats are supported: @param filename Name of file to be loaded. ```
I propose to introduce `IMREAD_COLOR_BGR` as synonym for `IMREAD_COLOR`, or better `IMREAD_COLOR_BGR` is default and `IMREAD_COLOR` as synonym.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** doc/tutorials/app/orbbec_astra_openni.markdown **Change Type:** renamed **Context:** PR #25813: Update the tutorial of using Orbbec Astra cameras **Code Changes:** ```diff @@ -1,4 +1,4 @@ -Using Orbbec Astra 3D cameras {#tutorial_orbbec_astra} +Using Orbbec Astra 3D cameras {#tutorial_orbbec_astra_openni} ====================================================== @tableofcontents @@ -9,7 +9,7 @@ Using Orbbec Astra 3D cameras {#tutorial_orbbec_astra} ### Introduction ```
I propose to rewrite the part and point, that latest version of SDK does not work with modern Linux/ Latest known good version is published on the Orbbec forum ....
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/onnx/onnx_importer.cpp **Change Type:** modified **Context:** PR #23613: dnn: refactor reduce **Code Changes:** ```diff @@ -1176,165 +1176,49 @@ void ONNXImporter::parseGlobalPool(LayerParams &layerParams, const opencv_onnx:: addLayer(layerParams, node_proto); } -void ONNXImporter::parseReduce(LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto_) -{ - opencv_onnx::NodeProto node_proto = node_proto_; - const std::string& layer_type = node_proto.op_type(); - const std::string output_name = node_proto.output(0); - int depth = layerParams.get<int>("depth", CV_32F); ```
unnecessary whitespace changes which brokes indentation.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/onnx/onnx_importer.cpp **Change Type:** modified **Context:** PR #23613: dnn: refactor reduce **Code Changes:** ```diff @@ -1176,165 +1176,49 @@ void ONNXImporter::parseGlobalPool(LayerParams &layerParams, const opencv_onnx:: addLayer(layerParams, node_proto); } -void ONNXImporter::parseReduce(LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto_) -{ - opencv_onnx::NodeProto node_proto = node_proto_; - const std::string& layer_type = node_proto.op_type(); - const std::string output_name = node_proto.output(0); - int depth = layerParams.get<int>("depth", CV_32F); ```
Already included by "opencv2/core/base.hpp" (available almost anywhere from the box). Please tune your IDE separately.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/onnx/onnx_graph_simplifier.cpp **Change Type:** modified **Context:** PR #23296: Fix identifying initializers in ONNX graph simplification **Code Changes:** ```diff @@ -82,7 +82,8 @@ class ONNXGraphWrapper : public ImportGraphWrapper for (int i = 0; i < numInitializers; ++i) if (net.initializer(i).name() == node_input_name) return i; - CV_Error(Error::StsParseError, "Initializer with name " + node_input_name + " not found"); + // CV_Error(Error::StsParseError, "Initializer with name " + node_input_name + " not found"); + return -1; } Mat getMatFromInitializer(int idx) ```
why don't we use fabs() here? it's not a part of your patch, but this place looks strange
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/onnx/onnx_graph_simplifier.cpp **Change Type:** modified **Context:** PR #23296: Fix identifying initializers in ONNX graph simplification **Code Changes:** ```diff @@ -82,7 +82,8 @@ class ONNXGraphWrapper : public ImportGraphWrapper for (int i = 0; i < numInitializers; ++i) if (net.initializer(i).name() == node_input_name) return i; - CV_Error(Error::StsParseError, "Initializer with name " + node_input_name + " not found"); + // CV_Error(Error::StsParseError, "Initializer with name " + node_input_name + " not found"); + return -1; } Mat getMatFromInitializer(int idx) ```
Sure. It is fixed with the use of fabs().
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/test/test_int.cpp **Change Type:** modified **Context:** PR #25755: Added more types support to dnn layers **Code Changes:** ```diff @@ -12,7 +12,13 @@ namespace opencv_test { namespace { int64_t getValueAt(const Mat &m, const int *indices) { - if (m.type() == CV_32S) + if (m.type() == CV_Bool) + return m.at<bool>(indices); + else if (m.type() == CV_8U) + return m.at<uint8_t>(indices); + else if (m.type() == CV_8S) ```
It's bad idea. OpenCV TS does not control seed for std::rand. You'll get different sequence subset of tests is requested by user, or test order is changed by some reason. cv::RNG::fill may be used for all branches: https://docs.opencv.org/5.x/d1/dd6/classcv_1_1RNG.html#ad26f2b09d9868cf108e84c9814aa682d
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/op_cann.cpp **Change Type:** added **Context:** PR #22634: dnn: add the CANN backend **Code Changes:** ```diff @@ -0,0 +1,329 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" +#include "op_cann.hpp" + +#include <mutex> +#include <map> ```
There is a potential issue of reset the same device multiple times when we load multiple models into the deivce. Resetting a device multiple times will not trigger unexpected exit but will leave error messages in the log of CANN runtime. Possible solution: force using `device_id=0` and call `aclrtResetDevice` in `CannClient::finalize()`;
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/CMakeLists.txt **Change Type:** modified **Context:** PR #22634: dnn: add the CANN backend **Code Changes:** ```diff @@ -31,6 +31,10 @@ if(HAVE_TIMVX) ocv_target_compile_definitions(${the_module} PRIVATE "HAVE_TIMVX=1") endif() +if(HAVE_CANN) + ocv_target_compile_definitions(${the_module} PRIVATE "HAVE_CANN=1") +endif() + ocv_option(OPENCV_DNN_CUDA "Build with CUDA support" HAVE_CUDA ```
We should avoid using of "global" `add_definitions()`. Use `ocv_target_compile_definitions` for test targets separately (under check `if(TARGET ...)`). See the last lines of this file.
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/dnn/CMakeLists.txt **Change Type:** modified **Context:** PR #22634: dnn: add the CANN backend **Review Line:** 172 **Code Changes:** ```diff endif() +if(HAVE_CANN) + list(APPEND include_dirs ${CANN_INCLUDE_DIRS}) + list(APPEND libs -Wl,--whole-archive ${CANN_LIBRARIES} -Wl,--no-whole-archive) +endif() + set(webnn_srcs "") if(NOT EMSCRIPTEN) if(HAVE_WEBNN) @@ -264,3 +273,10 @@ if(TARGET ocv.3rdparty.openvino AND OPENCV_TEST_DNN_OPENVINO) ```
Need to reuse `ocv_add_external_target()` approach for 3rdparty libraries.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/op_cann.cpp **Change Type:** added **Context:** PR #22634: dnn: add the CANN backend **Code Changes:** ```diff @@ -0,0 +1,329 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" +#include "op_cann.hpp" + +#include <mutex> +#include <map> ```
Reuse `gst_initializer` singleton approach (from videoio)
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/dnn/src/op_cann.cpp **Change Type:** added **Context:** PR #22634: dnn: add the CANN backend **Code Changes:** ```diff @@ -0,0 +1,329 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" +#include "op_cann.hpp" + +#include <mutex> +#include <map> ```
There are two APIs for finalizing device resources: `aclFinalize()` and `ge::aclgrphBuildFinalize()`. `aclFinalize()` can be called by std::atexit or the singleton approach, but `ge::aclgrphBuildFinalize()` does work with either ways (what I mean here is if this API is called by either ways, a segmentation fault will be triggered when program ends).
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/op_cann.cpp **Change Type:** added **Context:** PR #22634: dnn: add the CANN backend **Code Changes:** ```diff @@ -0,0 +1,329 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" +#include "op_cann.hpp" + +#include <mutex> +#include <map> ```
Done with introducing `AclEnvGuard`.
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/dnn/CMakeLists.txt **Change Type:** modified **Context:** PR #22634: dnn: add the CANN backend **Review Line:** 172 **Code Changes:** ```diff endif() +if(HAVE_CANN) + list(APPEND include_dirs ${CANN_INCLUDE_DIRS}) + list(APPEND libs -Wl,--whole-archive ${CANN_LIBRARIES} -Wl,--no-whole-archive) +endif() + set(webnn_srcs "") if(NOT EMSCRIPTEN) if(HAVE_WEBNN) @@ -264,3 +273,10 @@ if(TARGET ocv.3rdparty.openvino AND OPENCV_TEST_DNN_OPENVINO) ```
How about keep it as-is since other 3rdparty libraries are still using the old approach? We can do this kind of change for all other 3rdparty libraries in a separate pr.
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/dnn/CMakeLists.txt **Change Type:** modified **Context:** PR #22634: dnn: add the CANN backend **Review Line:** 172 **Code Changes:** ```diff endif() +if(HAVE_CANN) + list(APPEND include_dirs ${CANN_INCLUDE_DIRS}) + list(APPEND libs -Wl,--whole-archive ${CANN_LIBRARIES} -Wl,--no-whole-archive) +endif() + set(webnn_srcs "") if(NOT EMSCRIPTEN) if(HAVE_WEBNN) @@ -264,3 +273,10 @@ if(TARGET ocv.3rdparty.openvino AND OPENCV_TEST_DNN_OPENVINO) ```
Do we still need this? (as there is `ocv.3rdparty.cann` usage below)
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/layer.cpp **Change Type:** modified **Context:** PR #22634: dnn: add the CANN backend **Review Line:** 90 **Code Changes:** ```diff } +Ptr<BackendNode> Layer::initCann(const std::vector<Ptr<BackendWrapper> > &inputsWrapper, const int index, const std::vector<Ptr<BackendNode> >& nodes) +{ + CV_Error(Error::StsNotImplemented, "CANN pipeline of " + type + " layers is not defined."); + return Ptr<BackendNode>(); +} + Ptr<BackendNode> Layer::tryAttach(const Ptr<BackendNode>& node) { return Ptr<BackendNode>(); ```
> `return Ptr<BackendNode>();` unreachable code
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/CMakeLists.txt **Change Type:** modified **Context:** PR #22634: dnn: add the CANN backend **Review Line:** 172 **Code Changes:** ```diff endif() +if(HAVE_CANN) + list(APPEND include_dirs ${CANN_INCLUDE_DIRS}) + list(APPEND libs -Wl,--whole-archive ${CANN_LIBRARIES} -Wl,--no-whole-archive) +endif() + set(webnn_srcs "") if(NOT EMSCRIPTEN) if(HAVE_WEBNN) @@ -264,3 +273,10 @@ if(TARGET ocv.3rdparty.openvino AND OPENCV_TEST_DNN_OPENVINO) ```
Yes, we do. `ocv.3rdparty.cann` is used to link for `opencv_test_dnn` only for now.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/layer.cpp **Change Type:** modified **Context:** PR #22634: dnn: add the CANN backend **Review Line:** 90 **Code Changes:** ```diff } +Ptr<BackendNode> Layer::initCann(const std::vector<Ptr<BackendWrapper> > &inputsWrapper, const int index, const std::vector<Ptr<BackendNode> >& nodes) +{ + CV_Error(Error::StsNotImplemented, "CANN pipeline of " + type + " layers is not defined."); + return Ptr<BackendNode>(); +} + Ptr<BackendNode> Layer::tryAttach(const Ptr<BackendNode>& node) { return Ptr<BackendNode>(); ```
This will be useful if we have the graph split. We still need to keep it though for inheritance, don't we?
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/layer.cpp **Change Type:** modified **Context:** PR #22634: dnn: add the CANN backend **Review Line:** 90 **Code Changes:** ```diff } +Ptr<BackendNode> Layer::initCann(const std::vector<Ptr<BackendWrapper> > &inputsWrapper, const int index, const std::vector<Ptr<BackendNode> >& nodes) +{ + CV_Error(Error::StsNotImplemented, "CANN pipeline of " + type + " layers is not defined."); + return Ptr<BackendNode>(); +} + Ptr<BackendNode> Layer::tryAttach(const Ptr<BackendNode>& node) { return Ptr<BackendNode>(); ```
This will be useful if we have the graph split. We still need to keep it though for inheritance, don't we?
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/layer.cpp **Change Type:** modified **Context:** PR #22634: dnn: add the CANN backend **Review Line:** 90 **Code Changes:** ```diff } +Ptr<BackendNode> Layer::initCann(const std::vector<Ptr<BackendWrapper> > &inputsWrapper, const int index, const std::vector<Ptr<BackendNode> >& nodes) +{ + CV_Error(Error::StsNotImplemented, "CANN pipeline of " + type + " layers is not defined."); + return Ptr<BackendNode>(); +} + Ptr<BackendNode> Layer::tryAttach(const Ptr<BackendNode>& node) { return Ptr<BackendNode>(); ```
`CV_Error()` throws exception unconditionally. Code after that line is dead. There is no question about inheritance.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/layer.cpp **Change Type:** modified **Context:** PR #22634: dnn: add the CANN backend **Review Line:** 90 **Code Changes:** ```diff } +Ptr<BackendNode> Layer::initCann(const std::vector<Ptr<BackendWrapper> > &inputsWrapper, const int index, const std::vector<Ptr<BackendNode> >& nodes) +{ + CV_Error(Error::StsNotImplemented, "CANN pipeline of " + type + " layers is not defined."); + return Ptr<BackendNode>(); +} + Ptr<BackendNode> Layer::tryAttach(const Ptr<BackendNode>& node) { return Ptr<BackendNode>(); ```
I just followed what other backends do. I can do the change though in later tonight.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/layer.cpp **Change Type:** modified **Context:** PR #22634: dnn: add the CANN backend **Review Line:** 90 **Code Changes:** ```diff } +Ptr<BackendNode> Layer::initCann(const std::vector<Ptr<BackendWrapper> > &inputsWrapper, const int index, const std::vector<Ptr<BackendNode> >& nodes) +{ + CV_Error(Error::StsNotImplemented, "CANN pipeline of " + type + " layers is not defined."); + return Ptr<BackendNode>(); +} + Ptr<BackendNode> Layer::tryAttach(const Ptr<BackendNode>& node) { return Ptr<BackendNode>(); ```
OK. This should be fixed separately then for all cases.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/layers/blank_layer.cpp **Change Type:** modified **Context:** PR #25739: Fixed blank layer for OpenVINO 2022.1 **Review Line:** 169 **Code Changes:** ```diff + // We use Reshape as blank layer. + // Previously, we used Concat layer, but it didn't work with scalar tensor. + // Also we used ConvertLike layer, but it did't work with old OpenVINO versions. + auto shape = std::make_shared<ov::op::v0::ShapeOf>(ieInpNode); + auto blank = std::make_shared<ov::op::v1::Reshape>(ieInpNode, shape, false); return Ptr<BackendNode>(new InfEngineNgraphNode(blank)); } #endif // HAVE_DNN_NGRAPH ```
May be just return `ieInpNode` without any "operations".
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/src/layers/blank_layer.cpp **Change Type:** modified **Context:** PR #25739: Fixed blank layer for OpenVINO 2022.1 **Review Line:** 169 **Code Changes:** ```diff + // We use Reshape as blank layer. + // Previously, we used Concat layer, but it didn't work with scalar tensor. + // Also we used ConvertLike layer, but it did't work with old OpenVINO versions. + auto shape = std::make_shared<ov::op::v0::ShapeOf>(ieInpNode); + auto blank = std::make_shared<ov::op::v1::Reshape>(ieInpNode, shape, false); return Ptr<BackendNode>(new InfEngineNgraphNode(blank)); } #endif // HAVE_DNN_NGRAPH ```
Unfortunately, that won't work and workaround is to create a dummy node. I've checked that nGraph usually removes such kind of nodes as a part of middle graph processing (like identical Reshape, ConvertLike to the same type and so on).
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/include/opencv2/dnn/dnn.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 74 **Code Changes:** ```diff //! DNN_BACKEND_DEFAULT equals to OPENCV_DNN_BACKEND_DEFAULT, which can be defined using CMake or a configuration parameter DNN_BACKEND_DEFAULT = 0, - DNN_BACKEND_HALIDE, - DNN_BACKEND_INFERENCE_ENGINE, //!< Intel OpenVINO computational backend - //!< @note Tutorial how to build OpenCV with OpenVINO: @ref tutorial_dnn_openvino + DNN_BACKEND_INFERENCE_ENGINE = 2, //!< Intel OpenVINO computational backend + //!< @note Tutorial how to build OpenCV with OpenVINO: @ref tutorial_dnn_openvino DNN_BACKEND_OPENCV, DNN_BACKEND_VKCOM, DNN_BACKEND_CUDA, @@ -314,18 +313,6 @@ CV__DNN_INLINE_NS_BEGIN ```
Please assign values to other enumerations so removing `DNN_BACKEND_HALIDE` won't break them.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/test/test_common.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 140 **Code Changes:** ```diff testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargets( bool withInferenceEngine = true, - bool withHalide = false, + bool obsolete_withHalide = false, // this is kept for compatibility bool withCpuOCV = true, bool withVkCom = true, bool withCUDA = true, ```
Might break the tests. Can we just check for `CV_Assert(!withHalide`)?
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/test/test_common.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 140 **Code Changes:** ```diff testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargets( bool withInferenceEngine = true, - bool withHalide = false, + bool obsolete_withHalide = false, // this is kept for compatibility bool withCpuOCV = true, bool withVkCom = true, bool withCUDA = true, ```
I can review every location where `dnnBackendsAndTargets` is used, and make changes if needed. Let me try.
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/dnn/include/opencv2/dnn/dnn.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 74 **Code Changes:** ```diff //! DNN_BACKEND_DEFAULT equals to OPENCV_DNN_BACKEND_DEFAULT, which can be defined using CMake or a configuration parameter DNN_BACKEND_DEFAULT = 0, - DNN_BACKEND_HALIDE, - DNN_BACKEND_INFERENCE_ENGINE, //!< Intel OpenVINO computational backend - //!< @note Tutorial how to build OpenCV with OpenVINO: @ref tutorial_dnn_openvino + DNN_BACKEND_INFERENCE_ENGINE = 2, //!< Intel OpenVINO computational backend + //!< @note Tutorial how to build OpenCV with OpenVINO: @ref tutorial_dnn_openvino DNN_BACKEND_OPENCV, DNN_BACKEND_VKCOM, DNN_BACKEND_CUDA, @@ -314,18 +313,6 @@ CV__DNN_INLINE_NS_BEGIN ```
I set `DNN_BACKEND_INFERENCE_ENGINE = 2,` to keep compatibility.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/test/test_common.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 140 **Code Changes:** ```diff testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargets( bool withInferenceEngine = true, - bool withHalide = false, + bool obsolete_withHalide = false, // this is kept for compatibility bool withCpuOCV = true, bool withVkCom = true, bool withCUDA = true, ```
All `dnnBackendsAndTargets` called with parameters should be taken well care 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:** modules/dnn/test/test_common.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 140 **Code Changes:** ```diff testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargets( bool withInferenceEngine = true, - bool withHalide = false, + bool obsolete_withHalide = false, // this is kept for compatibility bool withCpuOCV = true, bool withVkCom = true, bool withCUDA = true, ```
> I can review every location This is not one time activity. In case of parameter change we need to review each of "(5.x) Merge 4.x" PRs. It is much safer to rename this parameter to `bool obsolete_withHalide = false`.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/test/test_common.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 140 **Code Changes:** ```diff testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargets( bool withInferenceEngine = true, - bool withHalide = false, + bool obsolete_withHalide = false, // this is kept for compatibility bool withCpuOCV = true, bool withVkCom = true, bool withCUDA = true, ```
So how can we completely remove that in this case?
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/test/test_common.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 140 **Code Changes:** ```diff testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargets( bool withInferenceEngine = true, - bool withHalide = false, + bool obsolete_withHalide = false, // this is kept for compatibility bool withCpuOCV = true, bool withVkCom = true, bool withCUDA = true, ```
I think we can resolve this thread. The latest commits provide compatible removal of `withHalide` flag from `dnnBackendsAndTargets`.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/test/test_common.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 140 **Code Changes:** ```diff testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargets( bool withInferenceEngine = true, - bool withHalide = false, + bool obsolete_withHalide = false, // this is kept for compatibility bool withCpuOCV = true, bool withVkCom = true, bool withCUDA = true, ```
Again, fixing it here will not resolve merging 4.x->5.x issues (no errors would be raised in the most part of cases) which would lead to 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/dnn/test/test_common.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 140 **Code Changes:** ```diff testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargets( bool withInferenceEngine = true, - bool withHalide = false, + bool obsolete_withHalide = false, // this is kept for compatibility bool withCpuOCV = true, bool withVkCom = true, bool withCUDA = true, ```
So how about removing the parameter from 4.x like what we want to do with `modules/dnn/test/test_halide_layers.cpp`? Does this address your concern?
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/test/test_common.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 140 **Code Changes:** ```diff testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargets( bool withInferenceEngine = true, - bool withHalide = false, + bool obsolete_withHalide = false, // this is kept for compatibility bool withCpuOCV = true, bool withVkCom = true, bool withCUDA = true, ```
So how do we do for this issue?
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/test/test_common.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 140 **Code Changes:** ```diff testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargets( bool withInferenceEngine = true, - bool withHalide = false, + bool obsolete_withHalide = false, // this is kept for compatibility bool withCpuOCV = true, bool withVkCom = true, bool withCUDA = true, ```
Series of boolean parameters is anti-pattern, especially in form with optional default values. Any obvious refactoring is dangerous here, especially in case of regular merges between branches. > It is much safer to rename this parameter to `bool obsolete_withHalide = false`
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/test/test_common.hpp **Change Type:** modified **Context:** PR #24231: dnn: cleanup of halide backend for 5.x **Review Line:** 140 **Code Changes:** ```diff testing::internal::ParamGenerator< tuple<Backend, Target> > dnnBackendsAndTargets( bool withInferenceEngine = true, - bool withHalide = false, + bool obsolete_withHalide = false, // this is kept for compatibility bool withCpuOCV = true, bool withVkCom = true, bool withCUDA = true, ```
> It is much safer to rename this parameter to bool obsolete_withHalide = false Okay, I will do this. I guess we can safely remove this legacy once our main dev branch switches to 5.x, right?
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/models.yml **Change Type:** modified **Context:** PR #25775: Add yolov8l.onnx to samples **Review Line:** 79 **Code Changes:** ```diff @@ -76,6 +76,20 @@ yolov8m: background_label_id: 0 sample: "yolo_detector" +yolov8l: + load_info: + url: "https://github.com/CVHub520/X-AnyLabeling/releases/download/v0.1.0/yolov8l.onnx" + sha1: "462df53ca3a85d110bf6be7fc2e2bb1277124395" + model: "yolov8l.onnx" + mean: 0.0 ```
``` opencv-master/samples/dnn$ python3 ./download_models.py yolov8l DownloadInstance <opencv_face_detector_fp16> DownloadInstance <opencv_face_detector_uint8> DownloadInstance <opencv_fd> DownloadInstance <yolov8x> DownloadInstance <yolov8s> DownloadInstance <yolov8n> DownloadInstance <yolov8m> DownloadInstance <yolov8l> Model: yolov8l Working on yolov8l Getting file yolov8l.onnx expected SHA1: 5c5cc8ad7ab50973a84444bae4e613065a479ea1 there is already a file with the same name actual SHA1:462df53ca3a85d110bf6be7fc2e2bb1277124395 hash didn't match, loading file hash check failed - loading Preparing to download file yolov8l.onnx expected SHA1: 5c5cc8ad7ab50973a84444bae4e613065a479ea1 there is already a file with the same name actual SHA1:462df53ca3a85d110bf6be7fc2e2bb1277124395 200 OK [166.78626346588135 Mb] progress >>>>>>>>>>>>>>>>> Downloaded yolov8l.onnx with size 166.78626346588135 Mb expected SHA1: 5c5cc8ad7ab50973a84444bae4e613065a479ea1 there is already a file with the same name actual SHA1:462df53ca3a85d110bf6be7fc2e2bb1277124395 There was some problem with loading file yolov8l.onnx for yolov8l Exception: Hash mismatch: expected 5c5cc8ad7ab50973a84444bae4e613065a479ea1 vs actual of 462df53ca3a85d110bf6be7fc2e2bb1277124395 ```
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:** CMakeLists.txt **Change Type:** modified **Context:** PR #25661: Highgui backend on top of Framebuffer **Review Line:** 307 **Code Changes:** ```diff @@ -304,6 +304,10 @@ OCV_OPTION(WITH_GTK "Include GTK support" ON OCV_OPTION(WITH_GTK_2_X "Use GTK version 2" OFF VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID VERIFY HAVE_GTK AND NOT HAVE_GTK3) +OCV_OPTION(WITH_FRAMEBUFFER "Include framebuffer support" OFF + VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID) +OCV_OPTION(WITH_FRAMEBUFFER_XVFB "Include virtual framebuffer support" OFF + VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID) OCV_OPTION(WITH_WAYLAND "Include Wayland support" OFF VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID ```
We can set it to "ON" temporarily in order to enable build on CI.
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/highgui/src/window_framebuffer.hpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,135 @@ +// 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_HIGHGUI_WINDOWS_FRAMEBUFFER_HPP +#define OPENCV_HIGHGUI_WINDOWS_FRAMEBUFFER_HPP + +#include "backend.hpp" + ```
`getName` from the base class is not implemented. https://github.com/opencv/opencv/blob/d8f0838fa35b879e24196feafbf9dd1d683f0af0/modules/highgui/src/backend.hpp#L109
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Review Line:** 130 **Code Changes:** ```diff + { + Mat tmp(img.rows, img.cols, CV_8UC3); + convertToShow(img, tmp, true); + img = tmp; + } + break; + default: + CV_Error(cv::Error::StsBadArg, "Bad image: wrong number of channels"); + } + { + Mat bgra(img.rows, img.cols, CV_8UC4); ```
default section with assert is needed.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
XWDFileHeader* xwd_header = (XWDFileHeader*) mmap(NULL, sizeof(XWDFileHeader), PROT_READ, MAP_SHARED, fb_fd, 0);
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Review Line:** 130 **Code Changes:** ```diff + { + Mat tmp(img.rows, img.cols, CV_8UC3); + convertToShow(img, tmp, true); + img = tmp; + } + break; + default: + CV_Error(cv::Error::StsBadArg, "Bad image: wrong number of channels"); + } + { + Mat bgra(img.rows, img.cols, CV_8UC4); ```
default section added
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
fixed style in all code
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Review Line:** 130 **Code Changes:** ```diff + { + Mat tmp(img.rows, img.cols, CV_8UC3); + convertToShow(img, tmp, true); + img = tmp; + } + break; + default: + CV_Error(cv::Error::StsBadArg, "Bad image: wrong number of channels"); + } + { + Mat bgra(img.rows, img.cols, CV_8UC4); ```
default section added
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:** CMakeLists.txt **Change Type:** modified **Context:** PR #25661: Highgui backend on top of Framebuffer **Review Line:** 307 **Code Changes:** ```diff @@ -304,6 +304,10 @@ OCV_OPTION(WITH_GTK "Include GTK support" ON OCV_OPTION(WITH_GTK_2_X "Use GTK version 2" OFF VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID VERIFY HAVE_GTK AND NOT HAVE_GTK3) +OCV_OPTION(WITH_FRAMEBUFFER "Include framebuffer support" OFF + VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID) +OCV_OPTION(WITH_FRAMEBUFFER_XVFB "Include virtual framebuffer support" OFF + VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID) OCV_OPTION(WITH_WAYLAND "Include Wayland support" OFF VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID ```
the flag value is replaced with "ON"
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/highgui/src/window_framebuffer.hpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,135 @@ +// 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_HIGHGUI_WINDOWS_FRAMEBUFFER_HPP +#define OPENCV_HIGHGUI_WINDOWS_FRAMEBUFFER_HPP + +#include "backend.hpp" + ```
the method appeared after the fork I synchronized my fork and added a method implementation
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
LOG info is redundant here. The following warning will be shown anyway.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
the same for log info.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
Why not just VGA? It's more common in cv.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
changed the resolution to 640x480
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:** CMakeLists.txt **Change Type:** modified **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -304,6 +304,10 @@ OCV_OPTION(WITH_GTK "Include GTK support" ON OCV_OPTION(WITH_GTK_2_X "Use GTK version 2" OFF VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID VERIFY HAVE_GTK AND NOT HAVE_GTK3) +OCV_OPTION(WITH_FRAMEBUFFER "Include framebuffer support" OFF + VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID) +OCV_OPTION(WITH_FRAMEBUFFER_XVFB "Include virtual framebuffer support" OFF + VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID) OCV_OPTION(WITH_WAYLAND "Include Wayland support" OFF VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID ```
Please revert this option back to OFF.
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** CMakeLists.txt **Change Type:** modified **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -304,6 +304,10 @@ OCV_OPTION(WITH_GTK "Include GTK support" ON OCV_OPTION(WITH_GTK_2_X "Use GTK version 2" OFF VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID VERIFY HAVE_GTK AND NOT HAVE_GTK3) +OCV_OPTION(WITH_FRAMEBUFFER "Include framebuffer support" OFF + VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID) +OCV_OPTION(WITH_FRAMEBUFFER_XVFB "Include virtual framebuffer support" OFF + VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID) OCV_OPTION(WITH_WAYLAND "Include Wayland support" OFF VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID ```
Please remove `VERIFY HAVE_FRAMEBUFFER` part, it does not work and probably is useless anyway.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Review Line:** 7 **Code Changes:** ```diff +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> +#include <opencv2/core/utils/logger.defines.hpp> +#ifdef NDEBUG +#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG + 1 ```
Add license header: https://github.com/opencv/opencv/wiki/Coding_Style_Guide#file-structure
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Review Line:** 7 **Code Changes:** ```diff +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> +#include <opencv2/core/utils/logger.defines.hpp> +#ifdef NDEBUG +#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG + 1 ```
The first include should be `precomp.hpp`
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
Avoid indentation in namespaces.
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
> img, img There is no implementation for in-place processing. Performance is degraded. ``` { Mat bgra; cvtColor(img, bgra, COLOR_RGB2BGRA); img = bgra; } ```
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
Use the second parameter of `getConfigurationParameterString()` instead.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
> INFO DEBUG or VERBOSE
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
`.rows` and `.cols`. Or better is `.empty()`. Also we should not eat problems silently, report them to the user. Also `.dims == 2` check should be added through `CV_CheckEQ`.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
what is the difference from image.getMat()
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
data race is possible here. Why do we need such global variable?
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/highgui/src/window_framebuffer.hpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Review Line:** 5 **Code Changes:** ```diff @@ -0,0 +1,135 @@ +// 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_HIGHGUI_WINDOWS_FRAMEBUFFER_HPP +#define OPENCV_HIGHGUI_WINDOWS_FRAMEBUFFER_HPP + +#include "backend.hpp" + +#include <linux/fb.h> ```
Add license header: https://github.com/opencv/opencv/wiki/Coding_Style_Guide#file-structure
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/highgui/src/window_framebuffer.hpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,135 @@ +// 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_HIGHGUI_WINDOWS_FRAMEBUFFER_HPP +#define OPENCV_HIGHGUI_WINDOWS_FRAMEBUFFER_HPP + +#include "backend.hpp" + ```
No `CV_EXPORTS` for non-public API.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Review Line:** 7 **Code Changes:** ```diff +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> +#include <opencv2/core/utils/logger.defines.hpp> +#ifdef NDEBUG +#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_DEBUG + 1 ```
The manual specifies the url http://opencv.org/license.html The transition gives the error "Not found, error 404" The real way is https://opencv.org/license/ Which one should I specify in the source files?
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
If don't clone the image, the original image will be change (size and colorspase). Copy of the image is used to copy data into the framebuffer
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
currentImg local variable for Windows. currentImg is used to display the image when Windows is resized and moved.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
Fixed all places of inplace transformations (lines 68-132 167-169)
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
Fixed it in two functions: static std::string& getFBMode() (line 41-42) static std::string& getFBFileName() (line 48-49)
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/highgui/src/window_framebuffer.cpp **Change Type:** added **Context:** PR #25661: Highgui backend on top of Framebuffer **Code Changes:** ```diff @@ -0,0 +1,798 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. + +#include "precomp.hpp" + +#include "window_framebuffer.hpp" + +#include <opencv2/core/utils/configuration.private.hpp> ```
All indicators that the method was called were replaced with CV_LOG_DEBUG