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/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)); ```
shouldn't that be in `if( setjmp( png_jmpbuf ( png_ptr ) ) == 0 )` below ?
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/filter.hpp **Change Type:** added **Context:** PR #27045: 5.x merge 4.x - No related changes in extra and contrib #26441 from sturkmen72:upd_tutorials #26849 from sturkmen72:apng-writeanimation #26... **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. +#ifndef OPENCV_HAL_RVV_FILTER_HPP_INCLUDED +#define OPENCV_HAL_RVV_FILTER_HPP_INCLUDED + +#include "../../imgproc/include/opencv2/imgproc/hal/interface.h" +#include <riscv_vector.h> + +struct cvhalFilter2D; + +namespace cv { namespace cv_hal_rvv { ```
I noticed this in PR #27026, but that PR has already been closed. I'm not sure whether I should create a separate issue for such a small problem or mention it somewhere and address it in a larger update. So, I’m bringing it up here. I think it should be added in `hal_rvv.hpp` like [this](https://github.com/opencv/opencv/blob/656038346b77eea03b54ae4d15bbc8caf2b52235/3rdparty/hal_rvv/hal_rvv.hpp#L8).
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/filter.hpp **Change Type:** added **Context:** PR #27045: 5.x merge 4.x - No related changes in extra and contrib #26441 from sturkmen72:upd_tutorials #26849 from sturkmen72:apng-writeanimation #26... **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. +#ifndef OPENCV_HAL_RVV_FILTER_HPP_INCLUDED +#define OPENCV_HAL_RVV_FILTER_HPP_INCLUDED + +#include "../../imgproc/include/opencv2/imgproc/hal/interface.h" +#include <riscv_vector.h> + +struct cvhalFilter2D; + +namespace cv { namespace cv_hal_rvv { ```
Feel free to resolve it in 4.x.
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/filter.hpp **Change Type:** added **Context:** PR #27045: 5.x merge 4.x - No related changes in extra and contrib #26441 from sturkmen72:upd_tutorials #26849 from sturkmen72:apng-writeanimation #26... **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. +#ifndef OPENCV_HAL_RVV_FILTER_HPP_INCLUDED +#define OPENCV_HAL_RVV_FILTER_HPP_INCLUDED + +#include "../../imgproc/include/opencv2/imgproc/hal/interface.h" +#include <riscv_vector.h> + +struct cvhalFilter2D; + +namespace cv { namespace cv_hal_rvv { ```
I will resolve it later.
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/calib3d/src/stereosgbm.cpp **Change Type:** modified **Context:** PR #26996: fix Logical defect in FilterSpecklesImpl **Code Changes:** ```diff @@ -2345,21 +2345,33 @@ void filterSpecklesImpl(cv::Mat& img, int newVal, int maxSpeckleSize, int maxDif using namespace cv; int width = img.cols, height = img.rows, npixels = width*height; - size_t bufSize = npixels*(int)(sizeof(Point2s) + sizeof(int) + sizeof(uchar)); + // space allocation for: + // labels : npixels * sizeof(int) + // wbuf : npixels * sizeof(Point2s) + // rtype : (npixels + 1) * sizeof(uchar) + size_t bufSize = npixels * sizeof(int) // for labels ```
I propose to get rid of braces in the first case, and add a comment to each sum part to mark corresponding buffer name.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/pyramids.hpp **Change Type:** added **Context:** PR #26958: Add RISC-V HAL implementation for cv::pyrDown and cv::pyrUp **Code Changes:** ```diff @@ -0,0 +1,719 @@ +// 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_PYRAMIDS_HPP_INCLUDED +#define OPENCV_HAL_RVV_PYRAMIDS_HPP_INCLUDED + +#include <riscv_vector.h> + +namespace cv { namespace cv_hal_rvv { namespace pyramids { ```
Let's avoid `CV_Assert` too. Just return NOT_IMPLEMENTED in this case. Here and in other places.
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/pyramids.hpp **Change Type:** added **Context:** PR #26958: Add RISC-V HAL implementation for cv::pyrDown and cv::pyrUp **Review Line:** 515 **Code Changes:** ```diff + } + int width0 = std::min((src_width-PD_SZ/2-1)/2 + 1, dst_width); + + for (int x = 0; x <= PD_SZ+1; x++) + { + int sx0 = borderInterpolate(x - PD_SZ/2, src_width, borderType)*cn; + int sx1 = borderInterpolate(x + width0*2 - PD_SZ/2, src_width, borderType)*cn; + for (int k = 0; k < cn; k++) + { + tabL[x*cn + k] = sx0 + k; + tabR[x*cn + k] = sx1 + k; ```
Not sure what to do with `borderInterpolate`. Perhaps it should be implemented here as well (maybe in limited version only for acceptable border modes).
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/pyramids.hpp **Change Type:** added **Context:** PR #26958: Add RISC-V HAL implementation for cv::pyrDown and cv::pyrUp **Review Line:** 515 **Code Changes:** ```diff + } + int width0 = std::min((src_width-PD_SZ/2-1)/2 + 1, dst_width); + + for (int x = 0; x <= PD_SZ+1; x++) + { + int sx0 = borderInterpolate(x - PD_SZ/2, src_width, borderType)*cn; + int sx1 = borderInterpolate(x + width0*2 - PD_SZ/2, src_width, borderType)*cn; + for (int k = 0; k < cn; k++) + { + tabL[x*cn + k] = sx0 + k; + tabR[x*cn + k] = sx1 + k; ```
Carotene(ARM HAL) copied this function from ::cv into its self namespace, I will follow this.
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/src/norm.simd.hpp **Change Type:** added **Context:** PR #26885: core: vectorize cv::normalize / cv::norm **Code Changes:** ```diff @@ -0,0 +1,676 @@ +// 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" + +#if CV_RVV +#include "norm.rvv1p0.hpp" +#endif ```
This is introduced to workaround failed tests on ci of rvv node. The RVV CI node is getting some accuracy issues on the normL2 with double only. But it works fine on real hardware. Could it be some qemu bugs?
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/src/norm.simd.hpp **Change Type:** added **Context:** PR #26885: core: vectorize cv::normalize / cv::norm **Code Changes:** ```diff @@ -0,0 +1,676 @@ +// 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" + +#if CV_RVV +#include "norm.rvv1p0.hpp" +#endif ```
This is introduce to workaround failed tests on ci of rvv node. The RVV CI node is getting some accuracy issues on the normL1 with double only. But it works fine on real hardware. Could it be some qemu bugs?
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/src/norm.simd.hpp **Change Type:** added **Context:** PR #26885: core: vectorize cv::normalize / cv::norm **Code Changes:** ```diff @@ -0,0 +1,676 @@ +// 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" + +#if CV_RVV +#include "norm.rvv1p0.hpp" +#endif ```
This is introduced to workaround failed tests on ci of rvv node. The RVV CI node is getting weird some accuracy issues on the normL2 with double. But it works fine on real hardware. Could it be some qemu bugs?
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/src/norm.simd.hpp **Change Type:** added **Context:** PR #26885: core: vectorize cv::normalize / cv::norm **Code Changes:** ```diff @@ -0,0 +1,676 @@ +// 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" + +#if CV_RVV +#include "norm.rvv1p0.hpp" +#endif ```
This is introduced to workaround failed tests on ci of rvv node. The RVV CI node is getting weird some accuracy issues on the normL1 with double. But it works fine on real hardware. Could it be some qemu bugs?
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/norm.dispatch.cpp **Change Type:** renamed **Context:** PR #26885: core: vectorize cv::normalize / cv::norm **Code Changes:** ```diff @@ -7,6 +7,9 @@ #include "opencl_kernels_core.hpp" #include "stat.hpp" +#include "norm.simd.hpp" +#include "norm.simd_declarations.hpp" + /****************************************************************************************\ * norm * \****************************************************************************************/ ```
All ifs may be squeezed to single call. `if( normType == NORM_L2 )` is needed for sqrt only.
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/src/norm.dispatch.cpp **Change Type:** renamed **Context:** PR #26885: core: vectorize cv::normalize / cv::norm **Code Changes:** ```diff @@ -7,6 +7,9 @@ #include "opencl_kernels_core.hpp" #include "stat.hpp" +#include "norm.simd.hpp" +#include "norm.simd_declarations.hpp" + /****************************************************************************************\ * norm * \****************************************************************************************/ ```
For norm inf, `result` needs to be `float` while others are `double`. Fixed in the latest commit.
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_hal_core.cpp **Change Type:** modified **Context:** PR #26887: invSqrt SIMD_SCALABLE implementation & HAL tests refactoring - Enable CV_SIMD_SCALABLE for invSqrt. * Banana Pi BF3 (SpacemiT K1) RISC-V * ... **Code Changes:** ```diff @@ -42,168 +42,163 @@ namespace opencv_test { namespace { -enum +enum HALFunc { HAL_EXP = 0, HAL_LOG = 1, - HAL_SQRT = 2 ```
I propose to refactor the test to parameterized test. The loop is not needed and GTest names them in logs and highlights failures.
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_hal_core.cpp **Change Type:** modified **Context:** PR #26887: invSqrt SIMD_SCALABLE implementation & HAL tests refactoring - Enable CV_SIMD_SCALABLE for invSqrt. * Banana Pi BF3 (SpacemiT K1) RISC-V * ... **Code Changes:** ```diff @@ -42,168 +42,163 @@ namespace opencv_test { namespace { -enum +enum HALFunc { HAL_EXP = 0, HAL_LOG = 1, - HAL_SQRT = 2 ```
This test is weak because it tests explicit HAL call and the same HAL call at https://github.com/opencv/opencv/blob/8e65075c1e6810c3ffbf38093f4e5fc167d76ea7/modules/core/src/matrix_decomp.cpp#L187
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_hal_core.cpp **Change Type:** modified **Context:** PR #26887: invSqrt SIMD_SCALABLE implementation & HAL tests refactoring - Enable CV_SIMD_SCALABLE for invSqrt. * Banana Pi BF3 (SpacemiT K1) RISC-V * ... **Code Changes:** ```diff @@ -42,168 +42,163 @@ namespace opencv_test { namespace { -enum +enum HALFunc { HAL_EXP = 0, HAL_LOG = 1, - HAL_SQRT = 2 ```
typo? `std::get<2>(GetParam());`
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_hal_core.cpp **Change Type:** modified **Context:** PR #26887: invSqrt SIMD_SCALABLE implementation & HAL tests refactoring - Enable CV_SIMD_SCALABLE for invSqrt. * Banana Pi BF3 (SpacemiT K1) RISC-V * ... **Code Changes:** ```diff @@ -42,168 +42,163 @@ namespace opencv_test { namespace { -enum +enum HALFunc { HAL_EXP = 0, HAL_LOG = 1, - HAL_SQRT = 2 ```
`throw SkipTestException("message");` It's equivalent to your code, but marks the test as skipped in report and logs.
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_hal_core.cpp **Change Type:** modified **Context:** PR #26887: invSqrt SIMD_SCALABLE implementation & HAL tests refactoring - Enable CV_SIMD_SCALABLE for invSqrt. * Banana Pi BF3 (SpacemiT K1) RISC-V * ... **Code Changes:** ```diff @@ -42,168 +42,163 @@ namespace opencv_test { namespace { -enum +enum HALFunc { HAL_EXP = 0, HAL_LOG = 1, - HAL_SQRT = 2 ```
I propose to invert the ground truth calculation: generate A and x with randu, calculate b with multiplication, use A and b for test and x as ground truth.
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/test/test_hal_core.cpp **Change Type:** modified **Context:** PR #26887: invSqrt SIMD_SCALABLE implementation & HAL tests refactoring - Enable CV_SIMD_SCALABLE for invSqrt. * Banana Pi BF3 (SpacemiT K1) RISC-V * ... **Code Changes:** ```diff @@ -42,168 +42,163 @@ namespace opencv_test { namespace { -enum +enum HALFunc { HAL_EXP = 0, HAL_LOG = 1, - HAL_SQRT = 2 ```
Please remove commented 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/core/test/test_hal_core.cpp **Change Type:** modified **Context:** PR #26887: invSqrt SIMD_SCALABLE implementation & HAL tests refactoring - Enable CV_SIMD_SCALABLE for invSqrt. * Banana Pi BF3 (SpacemiT K1) RISC-V * ... **Code Changes:** ```diff @@ -42,168 +42,163 @@ namespace opencv_test { namespace { -enum +enum HALFunc { HAL_EXP = 0, HAL_LOG = 1, - HAL_SQRT = 2 ```
I've inverted the test but keep comparison between `A * x` and `A * x0` because test `x` vs `x0` gives bigger error on `size=15`: ``` [ RUN ] Core_HAL/mat_decomp.accuracy/7, where GetParam() = (5, Cholesky, 15) /home/d.kurtaev/opencv/modules/core/test/test_hal_core.cpp:189: Failure Expected: (cvtest::norm(x, x0, NORM_INF | NORM_RELATIVE)) <= (eps), actual: 0.03707 vs 1e-05 ```
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_hal_core.cpp **Change Type:** modified **Context:** PR #26887: invSqrt SIMD_SCALABLE implementation & HAL tests refactoring - Enable CV_SIMD_SCALABLE for invSqrt. * Banana Pi BF3 (SpacemiT K1) RISC-V * ... **Code Changes:** ```diff @@ -42,168 +42,163 @@ namespace opencv_test { namespace { -enum +enum HALFunc { HAL_EXP = 0, HAL_LOG = 1, - HAL_SQRT = 2 ```
`a0 * x0` is `b` otherwise `b` is not used.
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 #26915: imgcodecs: fix PNG read on BE platforms (s390x) - Resolves #26913 Related(?): #25715 #26832 **Code Changes:** ```diff @@ -121,16 +121,16 @@ namespace cv { -const uint32_t id_IHDR = 0x52444849; // PNG header -const uint32_t id_acTL = 0x4C546361; // Animation control chunk -const uint32_t id_fcTL = 0x4C546366; // Frame control chunk -const uint32_t id_IDAT = 0x54414449; // first frame and/or default image -const uint32_t id_fdAT = 0x54416466; // Frame data chunk -const uint32_t id_PLTE = 0x45544C50; // The PLTE chunk contains a color palette for indexed-color images ```
since we just made `id` correct in both cases, why change the return here? wouldn't just `return id;` now be ok for both?
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/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #26915: imgcodecs: fix PNG read on BE platforms (s390x) - Resolves #26913 Related(?): #25715 #26832 **Code Changes:** ```diff @@ -121,16 +121,16 @@ namespace cv { -const uint32_t id_IHDR = 0x52444849; // PNG header -const uint32_t id_acTL = 0x4C546361; // Animation control chunk -const uint32_t id_fcTL = 0x4C546366; // Frame control chunk -const uint32_t id_IDAT = 0x54414449; // first frame and/or default image -const uint32_t id_fdAT = 0x54416466; // Frame data chunk -const uint32_t id_PLTE = 0x45544C50; // The PLTE chunk contains a color palette for indexed-color images ```
Yes, it needs further investigation - tests on other platforms fail with other PNG files.
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 #26915: imgcodecs: fix PNG read on BE platforms (s390x) - Resolves #26913 Related(?): #25715 #26832 **Code Changes:** ```diff @@ -121,16 +121,16 @@ namespace cv { -const uint32_t id_IHDR = 0x52444849; // PNG header -const uint32_t id_acTL = 0x4C546361; // Animation control chunk -const uint32_t id_fcTL = 0x4C546366; // Frame control chunk -const uint32_t id_IDAT = 0x54414449; // first frame and/or default image -const uint32_t id_fdAT = 0x54416466; // Frame data chunk -const uint32_t id_PLTE = 0x45544C50; // The PLTE chunk contains a color palette for indexed-color images ```
Actually the proper way is to use: ``` const uint32_t id = png_get_uint_32(size_d + 4); ```
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/calib3d/src/fundam.cpp **Change Type:** modified **Context:** PR #26921: Fix assertion in cv2.sampsonDistance **Code Changes:** ```diff @@ -1224,7 +1224,7 @@ double cv::sampsonDistance(InputArray _pt1, InputArray _pt2, InputArray _F) { CV_INSTRUMENT_REGION(); - CV_Assert(_pt1.type() == CV_64F && _pt2.type() == CV_64F && _F.type() == CV_64F); + CV_Assert(_pt1.depth() == CV_64F && _pt2.depth() == CV_64F && _F.depth() == CV_64F); CV_DbgAssert(_pt1.rows() == 3 && _F.size() == Size(3, 3) && _pt1.rows() == _pt2.rows()); Mat pt1(_pt1.getMat()); ```
Please use Mat::depth() instead of bit magic: https://docs.opencv.org/4.x/d3/d63/classcv_1_1Mat.html#a8da9f853b6f3a29d738572fd1ffc44c0
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/src/grfmt_gif.hpp **Change Type:** modified **Context:** PR #26930: imgcodecs: gif: support Disposal Method **Code Changes:** ```diff @@ -11,14 +11,35 @@ namespace cv { -enum GifOpMode -{ - GRFMT_GIF_Nothing = 0, - GRFMT_GIF_PreviousImage = 1, - GRFMT_GIF_Background = 2, - GRFMT_GIF_Cover = 3 ```
consider using enum GifDisposeMethod { GIF_DISPOSE_NA = 0, GIF_DISPOSE_NONE = 1, GIF_DISPOSE_RESTORE_BACKGROUND = 2, GIF_DISPOSE_RESTORE_PREVIOUS = 3, };
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_gif.cpp **Change Type:** modified **Context:** PR #26930: imgcodecs: gif: support Disposal Method **Code Changes:** ```diff @@ -24,7 +24,6 @@ GifDecoder::GifDecoder() { hasRead = false; hasTransparentColor = false; transparentColor = 0; - opMode = GRFMT_GIF_Nothing; top = 0, left = 0, width = 0, height = 0; depth = 8; idx = 0; @@ -66,6 +65,8 @@ bool GifDecoder::readHeader() { for (int i = 0; i < 3 * globalColorTableSize; i++) { ```
`uchar flag = GifDisposeMethod::GIF_DISPOSE_RESTORE_PREVIOUS << 2;`
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_gif.cpp **Change Type:** modified **Context:** PR #26930: imgcodecs: gif: support Disposal Method **Code Changes:** ```diff @@ -24,7 +24,6 @@ GifDecoder::GifDecoder() { hasRead = false; hasTransparentColor = false; transparentColor = 0; - opMode = GRFMT_GIF_Nothing; top = 0, left = 0, width = 0, height = 0; depth = 8; idx = 0; @@ -66,6 +65,8 @@ bool GifDecoder::readHeader() { for (int i = 0; i < 3 * globalColorTableSize; i++) { ```
I'm sorry I changed it to use new enum, but I missed to use restoreToPrevious method. I fixed it.
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_gif.cpp **Change Type:** modified **Context:** PR #26930: imgcodecs: gif: support Disposal Method **Code Changes:** ```diff @@ -24,7 +24,6 @@ GifDecoder::GifDecoder() { hasRead = false; hasTransparentColor = false; transparentColor = 0; - opMode = GRFMT_GIF_Nothing; top = 0, left = 0, width = 0, height = 0; depth = 8; idx = 0; @@ -66,6 +65,8 @@ bool GifDecoder::readHeader() { for (int i = 0; i < 3 * globalColorTableSize; i++) { ```
M.b. stupid question: why do you use flag values 0,1,2, and then shift left / shift right them during IO? The flag values may be shifted here once. Also please replace & 0x3 with some meaningful constant name like `GIF_DISPOSE_FLAG_MASK`.
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_gif.cpp **Change Type:** modified **Context:** PR #26930: imgcodecs: gif: support Disposal Method **Code Changes:** ```diff @@ -24,7 +24,6 @@ GifDecoder::GifDecoder() { hasRead = false; hasTransparentColor = false; transparentColor = 0; - opMode = GRFMT_GIF_Nothing; top = 0, left = 0, width = 0, height = 0; depth = 8; idx = 0; @@ -66,6 +65,8 @@ bool GifDecoder::readHeader() { for (int i = 0; i < 3 * globalColorTableSize; i++) { ```
The out-of-bound check looks strange. Need to check if it's possible and it's not a bug/broken input. We should not silently ignore input issues.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_gif.cpp **Change Type:** modified **Context:** PR #26930: imgcodecs: gif: support Disposal Method **Review Line:** 373 **Code Changes:** ```diff +// See https://github.com/opencv/opencv/issues/26924 +TEST(Imgcodecs_Gif, decode_disposal_method) +{ + const string root = cvtest::TS::ptr()->get_data_path(); + const string filename = root + "gifsuite/disposalMethod.gif"; + cv::Animation anim; + bool ret = false; + EXPECT_NO_THROW(ret = imreadanimation(filename, anim, cv::IMREAD_UNCHANGED)); + EXPECT_TRUE(ret); + ```
Looks like it's a new file. Please create PR to opencv_extra repo with the same branch name.
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_gif.cpp **Change Type:** modified **Context:** PR #26930: imgcodecs: gif: support Disposal Method **Review Line:** 373 **Code Changes:** ```diff +// See https://github.com/opencv/opencv/issues/26924 +TEST(Imgcodecs_Gif, decode_disposal_method) +{ + const string root = cvtest::TS::ptr()->get_data_path(); + const string filename = root + "gifsuite/disposalMethod.gif"; + cv::Animation anim; + bool ret = false; + EXPECT_NO_THROW(ret = imreadanimation(filename, anim, cv::IMREAD_UNCHANGED)); + EXPECT_TRUE(ret); + ```
I'm sorry I created branch which has same name this patch so its test is passed, but I forget to create PR. Please could you merge this pull request ? https://github.com/opencv/opencv_extra/pull/1239
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/features2d/test/test_fast.cpp **Change Type:** modified **Context:** PR #26907: Migrate remaning OpenVX integrations to OpenVX HAL (features2d) **Code Changes:** ```diff @@ -118,8 +118,8 @@ void CV_FastTest::run( int ) read( fs["exp_kps2"], exp_kps2, Mat() ); fs.release(); - if ( exp_kps1.size != kps1.size || 0 != cvtest::norm(exp_kps1, kps1, NORM_L2) || - exp_kps2.size != kps2.size || 0 != cvtest::norm(exp_kps2, kps2, NORM_L2)) + if ( exp_kps1.size != kps1.size || 0 != cvtest::norm(exp_kps1, kps1, NORM_L2) || + exp_kps2.size != kps2.size || 0 != cvtest::norm(exp_kps2, kps2, NORM_L2)) { ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH); ```
Maybe `ASSERT_TRUE` would be better in this case? Here and on line 163 (`ASSERT_GT`).
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/src/imgwarp.cpp **Change Type:** modified **Context:** PR #26914: removal of deprecated functions in imgproc **Review Line:** 3990 **Code Changes:** ```diff @@ -1432,150 +1432,6 @@ static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, Input return k.run(2, globalThreads, NULL, false); } -#if 0 -/** -@deprecated with old version of cv::linearPolar -*/ -static bool ocl_linearPolar(InputArray _src, OutputArray _dst, - Point2f center, double maxRadius, int flags) -{ - UMat src_with_border; // don't scope this variable (it holds image data) - - UMat mapx, mapy, r, cp_sp; - UMat src = _src.getUMat(); ```
Please presume the API in 4.x, but remove in 5.x. Backward compatibility is important.
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_imgwarp.cpp **Change Type:** modified **Context:** PR #26914: removal of deprecated functions in imgproc **Review Line:** 1116 **Code Changes:** ```diff @@ -1034,87 +1034,6 @@ TEST(Imgproc_Remap, DISABLED_memleak) } } -//** @deprecated */ -TEST(Imgproc_linearPolar, identity) -{ - const int N = 33; - Mat in(N, N, CV_8UC3, Scalar(255, 0, 0)); - in(cv::Rect(N/3, N/3, N/3, N/3)).setTo(Scalar::all(255)); - cv::blur(in, in, Size(5, 5)); - cv::blur(in, in, Size(5, 5)); - - Mat src = in.clone(); - Mat dst; ```
I propose to not remove test till the API is there in 4.x.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/src/imgwarp.cpp **Change Type:** modified **Context:** PR #26914: removal of deprecated functions in imgproc **Review Line:** 3990 **Code Changes:** ```diff @@ -1432,150 +1432,6 @@ static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, Input return k.run(2, globalThreads, NULL, false); } -#if 0 -/** -@deprecated with old version of cv::linearPolar -*/ -static bool ocl_linearPolar(InputArray _src, OutputArray _dst, - Point2f center, double maxRadius, int flags) -{ - UMat src_with_border; // don't scope this variable (it holds image data) - - UMat mapx, mapy, r, cp_sp; - UMat src = _src.getUMat(); ```
I closed the PR in the `4.x` branch of OpenCV (#26909) and made the relevant changes in the `5.x` branch. I hope that's fine.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/src/imgwarp.cpp **Change Type:** modified **Context:** PR #26914: removal of deprecated functions in imgproc **Review Line:** 3990 **Code Changes:** ```diff @@ -1432,150 +1432,6 @@ static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, Input return k.run(2, globalThreads, NULL, false); } -#if 0 -/** -@deprecated with old version of cv::linearPolar -*/ -static bool ocl_linearPolar(InputArray _src, OutputArray _dst, - Point2f center, double maxRadius, int flags) -{ - UMat src_with_border; // don't scope this variable (it holds image data) - - UMat mapx, mapy, r, cp_sp; - UMat src = _src.getUMat(); ```
Please remove the function from header file too.
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_imgwarp.cpp **Change Type:** modified **Context:** PR #26914: removal of deprecated functions in imgproc **Code Changes:** ```diff @@ -1034,87 +1034,6 @@ TEST(Imgproc_Remap, DISABLED_memleak) } } -//** @deprecated */ -TEST(Imgproc_linearPolar, identity) -{ - const int N = 33; - Mat in(N, N, CV_8UC3, Scalar(255, 0, 0)); - in(cv::Rect(N/3, N/3, N/3, N/3)).setTo(Scalar::all(255)); ```
The test should be either removed or updated to call `warpPolar`.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/src/imgwarp.cpp **Change Type:** modified **Context:** PR #26914: removal of deprecated functions in imgproc **Review Line:** 1467 **Code Changes:** ```diff @@ -1432,150 +1432,6 @@ static bool ocl_remap(InputArray _src, OutputArray _dst, InputArray _map1, Input return k.run(2, globalThreads, NULL, false); } -#if 0 -/** -@deprecated with old version of cv::linearPolar -*/ -static bool ocl_linearPolar(InputArray _src, OutputArray _dst, - Point2f center, double maxRadius, int flags) -{ - UMat src_with_border; // don't scope this variable (it holds image data) - - UMat mapx, mapy, r, cp_sp; - UMat src = _src.getUMat(); ```
Corresponding `*.cl` files should be removed too.
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_imgwarp.cpp **Change Type:** modified **Context:** PR #26914: removal of deprecated functions in imgproc **Code Changes:** ```diff @@ -1034,87 +1034,6 @@ TEST(Imgproc_Remap, DISABLED_memleak) } } -//** @deprecated */ -TEST(Imgproc_linearPolar, identity) -{ - const int N = 33; - Mat in(N, N, CV_8UC3, Scalar(255, 0, 0)); - in(cv::Rect(N/3, N/3, N/3, N/3)).setTo(Scalar::all(255)); ```
There is Imgproc_warpPolar.identity test. It implements the same procedure, but with the new API. So, the test may be removed without coverage loss.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/video/misc/java/test/TrackerCreateTest.java **Change Type:** modified **Context:** PR #26875: Added trackers factory with pre-loaded dnn models **Review Line:** 63 **Code Changes:** ```diff public void testCreateTrackerGOTURN() { + Net net; + try { + String protoFile = new File(testDataPath, "dnn/gsoc2016-goturn/goturn.prototxt").toString(); + String weightsFile = new File(modelsDataPath, "dnn/gsoc2016-goturn/goturn.caffemodel").toString(); + net = Dnn.readNetFromCaffe(protoFile, weightsFile); + } catch (CvException e) { + return; + } + Tracker tracker = TrackerGOTURN.create(net); + assert(tracker != null); ```
GOTURN files can be located in separate folders - weights in OPENCV_DNN_TEST_DATA_PATH, prototxt in OPENCV_TEST_DATA_PATH.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/video/misc/java/test/TrackerCreateTest.java **Change Type:** modified **Context:** PR #26875: Added trackers factory with pre-loaded dnn models **Review Line:** 65 **Code Changes:** ```diff + try { + String protoFile = new File(testDataPath, "dnn/gsoc2016-goturn/goturn.prototxt").toString(); + String weightsFile = new File(modelsDataPath, "dnn/gsoc2016-goturn/goturn.caffemodel").toString(); + net = Dnn.readNetFromCaffe(protoFile, weightsFile); + } catch (CvException e) { + return; + } + Tracker tracker = TrackerGOTURN.create(net); + assert(tracker != null); + } + ```
Maybe `throw new TestSkipException();`?
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/video/misc/java/test/TrackerCreateTest.java **Change Type:** modified **Context:** PR #26875: Added trackers factory with pre-loaded dnn models **Review Line:** 63 **Code Changes:** ```diff public void testCreateTrackerGOTURN() { + Net net; + try { + String protoFile = new File(testDataPath, "dnn/gsoc2016-goturn/goturn.prototxt").toString(); + String weightsFile = new File(modelsDataPath, "dnn/gsoc2016-goturn/goturn.caffemodel").toString(); + net = Dnn.readNetFromCaffe(protoFile, weightsFile); + } catch (CvException e) { + return; + } + Tracker tracker = TrackerGOTURN.create(net); + assert(tracker != null); ```
I fixed data search logic and introduced `modelsDataPath` to find files correctly.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVFindLibsPerf.cmake **Change Type:** modified **Context:** PR #26917: Switch to static instance of FastCV **Code Changes:** ```diff @@ -181,7 +181,14 @@ endif(WITH_KLEIDICV) if(WITH_FASTCV) if((EXISTS ${FastCV_INCLUDE_PATH}) AND (EXISTS ${FastCV_LIB_PATH})) message(STATUS "Use external FastCV ${FastCV_INCLUDE_PATH}, ${FastCV_LIB_PATH}") - set(HAVE_FASTCV TRUE CACHE BOOL "FastCV status") + find_library(FASTCV_LIBRARY NAMES "fastcv" + PATHS "${FastCV_LIB_PATH}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + mark_as_advanced(FASTCV_LIBRARY) + if (FASTCV_LIBRARY) + set(HAVE_FASTCV TRUE CACHE BOOL "FastCV status") ```
I believe we don't need special `NOTFOUND` handling - it should be built into the `if` [command](https://cmake.org/cmake/help/latest/command/if.html): > True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number (including floating point numbers). False if the constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, the empty string, or ends in the suffix -NOTFOUND.
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_io.cpp **Change Type:** modified **Context:** PR #26883: Remove code duplication from test for FileStorage Base64 **Code Changes:** ```diff @@ -611,28 +611,20 @@ static void test_filestorage_basic(int write_flags, const char* suffix_name, boo { /* init */ /* a normal mat u8 */ - _2d_out_u8 = cv::Mat(10, 20, CV_8UC3, cv::Scalar(1U, 2U, 127U)); - for (int i = 0; i < _2d_out_u8.rows; ++i) - for (int j = 0; j < _2d_out_u8.cols; ++j) - _2d_out_u8.at<cv::Vec3b>(i, j)[1] = (i + j) % 256; + _2d_out_u8 = Mat(10, 20, CV_8UC3); + cv::randu(_2d_out_u8, 0U, 255U); ```
`EXPECT_MAT_NEAR(_2d_in_u8, _2d_out_u8, 0)` or `EXPECT_MAT_N_DIFF(_2d_in_u8, _2d_out_u8, 0)` or `EXPECT_PRED_FORMAT2(cvtest::MatComparator(0, 0), _2d_in_u8, _2d_out_u8);` should be enough here. The in and out matrices should be bit exact, right?
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_io.cpp **Change Type:** modified **Context:** PR #26883: Remove code duplication from test for FileStorage Base64 **Code Changes:** ```diff @@ -611,28 +611,20 @@ static void test_filestorage_basic(int write_flags, const char* suffix_name, boo { /* init */ /* a normal mat u8 */ - _2d_out_u8 = cv::Mat(10, 20, CV_8UC3, cv::Scalar(1U, 2U, 127U)); - for (int i = 0; i < _2d_out_u8.rows; ++i) - for (int j = 0; j < _2d_out_u8.cols; ++j) - _2d_out_u8.at<cv::Vec3b>(i, j)[1] = (i + j) % 256; + _2d_out_u8 = Mat(10, 20, CV_8UC3); + cv::randu(_2d_out_u8, 0U, 255U); ```
it may be replaced with cv::randu output, right?
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/test/test_io.cpp **Change Type:** modified **Context:** PR #26883: Remove code duplication from test for FileStorage Base64 **Code Changes:** ```diff @@ -611,28 +611,20 @@ static void test_filestorage_basic(int write_flags, const char* suffix_name, boo { /* init */ /* a normal mat u8 */ - _2d_out_u8 = cv::Mat(10, 20, CV_8UC3, cv::Scalar(1U, 2U, 127U)); - for (int i = 0; i < _2d_out_u8.rows; ++i) - for (int j = 0; j < _2d_out_u8.cols; ++j) - _2d_out_u8.at<cv::Vec3b>(i, j)[1] = (i + j) % 256; + _2d_out_u8 = Mat(10, 20, CV_8UC3); + cv::randu(_2d_out_u8, 0U, 255U); ```
Extra function is not needed at all: ``` cv::Mat _2d_out_u8(rows, cols, type, scalar); // scalar is not needed here most probably cv::randu(_2d_out_u8, min, max); ```` See https://docs.opencv.org/4.x/d2/de8/group__core__array.html#ga1ba1026dca0807b27057ba6a49d258c0
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/split.hpp **Change Type:** added **Context:** PR #26884: [HAL] split8u RVV 1.0 **Code Changes:** ```diff @@ -0,0 +1,93 @@ +// 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_SPLIT_HPP_INCLUDED +#define OPENCV_HAL_RVV_SPLIT_HPP_INCLUDED + +#include <riscv_vector.h> + +namespace cv { namespace cv_hal_rvv { ```
Is it for particular version of Clang?
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/split.hpp **Change Type:** added **Context:** PR #26884: [HAL] split8u RVV 1.0 **Code Changes:** ```diff @@ -0,0 +1,93 @@ +// 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_SPLIT_HPP_INCLUDED +#define OPENCV_HAL_RVV_SPLIT_HPP_INCLUDED + +#include <riscv_vector.h> + +namespace cv { namespace cv_hal_rvv { ```
The same question
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/split.hpp **Change Type:** added **Context:** PR #26884: [HAL] split8u RVV 1.0 **Code Changes:** ```diff @@ -0,0 +1,93 @@ +// 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_SPLIT_HPP_INCLUDED +#define OPENCV_HAL_RVV_SPLIT_HPP_INCLUDED + +#include <riscv_vector.h> + +namespace cv { namespace cv_hal_rvv { ```
idk i copied it from merge.hpp
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/mean.dispatch.cpp **Change Type:** modified **Context:** PR #26895: Use HAL for cv::mean function too **Code Changes:** ```diff @@ -130,13 +130,29 @@ Scalar mean(InputArray _src, InputArray _mask) CV_Assert( mask.empty() || mask.type() == CV_8U ); int k, cn = src.channels(), depth = src.depth(); - Scalar s; + Scalar s = Scalar::all(0.0); + + CV_Assert( cn <= 4 ); CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_mean(src, mask, s), s) ```
Is it possible to use CALL_HAL_RET macro here and below?
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/mean.dispatch.cpp **Change Type:** modified **Context:** PR #26895: Use HAL for cv::mean function too **Code Changes:** ```diff @@ -130,13 +130,29 @@ Scalar mean(InputArray _src, InputArray _mask) CV_Assert( mask.empty() || mask.type() == CV_8U ); int k, cn = src.channels(), depth = src.depth(); - Scalar s; + Scalar s = Scalar::all(0.0); + + CV_Assert( cn <= 4 ); CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_mean(src, mask, s), s) ```
The macro expects, that the return value is the last HAL function parameter. It's not applicable here.
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/mean.dispatch.cpp **Change Type:** modified **Context:** PR #26895: Use HAL for cv::mean function too **Code Changes:** ```diff @@ -130,13 +130,29 @@ Scalar mean(InputArray _src, InputArray _mask) CV_Assert( mask.empty() || mask.type() == CV_8U ); int k, cn = src.channels(), depth = src.depth(); - Scalar s; + Scalar s = Scalar::all(0.0); + + CV_Assert( cn <= 4 ); CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_mean(src, mask, s), s) ```
Perhaps we should add a new macro which doesn't pass `retval` to HAL function: ```.cpp // name TBD #define CALL_HAL_RET2(name, fun, retval, ...) \ int res = __CV_EXPAND(fun(__VA_ARGS__)); \ if (res == CV_HAL_ERROR_OK) \ return retval; \ else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \ CV_Error_(cv::Error::StsInternal, \ ("HAL implementation " CVAUX_STR(name) " ==> " CVAUX_STR(fun) " returned %d (0x%08x)", res, res)); ``` Then old macros could be redefined as follows: ```.cpp #define CALL_HAL_RET(name, fun, retval, ...) \ CALL_HAL_RET2(name, fun, retval, __VA_ARGS__, &retval) #define CALL_HAL(name, fun, ...) \ CALL_HAL_RET2(name, fun, ,__VA_ARGS__) ```
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/mean.dispatch.cpp **Change Type:** modified **Context:** PR #26895: Use HAL for cv::mean function too **Review Line:** 139 **Code Changes:** ```diff + + CV_Assert( cn <= 4 ); CV_IPP_RUN(IPP_VERSION_X100 >= 700, ipp_mean(src, mask, s), s) + if (src.isContinuous() && mask.isContinuous()) + { + CALL_HAL_RET2(meanStdDev, cv_hal_meanStdDev, s, src.data, 0, (int)src.total(), 1, src.type(), + &s[0], nullptr /*stddev*/, mask.data, 0); + } + else ```
Usually we put HAL call before IPP.
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/atan.hpp **Change Type:** added **Context:** PR #26853: Add RISC-V HAL implementation for fastAtan32f/fastAtan64f **Review Line:** 19 **Code Changes:** ```diff +#include <cfloat> + +namespace cv::cv_hal_rvv { + +namespace detail { +// ref: mathfuncs_core.simd.hpp +static constexpr float pi = CV_PI; +static constexpr float atan2_p1 = 0.9997878412794807F * (180 / pi); +static constexpr float atan2_p3 = -0.3258083974640975F * (180 / pi); +static constexpr float atan2_p5 = 0.1555786518463281F * (180 / pi); +static constexpr float atan2_p7 = -0.04432655554792128F * (180 / pi); ```
Could you add reference to the computation method, name, formula, whatever to identify the approach? Constants meaning and other arithmetic details will be more obvious with such details.
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/atan.hpp **Change Type:** added **Context:** PR #26853: Add RISC-V HAL implementation for fastAtan32f/fastAtan64f **Review Line:** 19 **Code Changes:** ```diff +#include <cfloat> + +namespace cv::cv_hal_rvv { + +namespace detail { +// ref: mathfuncs_core.simd.hpp +static constexpr float pi = CV_PI; +static constexpr float atan2_p1 = 0.9997878412794807F * (180 / pi); +static constexpr float atan2_p3 = -0.3258083974640975F * (180 / pi); +static constexpr float atan2_p5 = 0.1555786518463281F * (180 / pi); +static constexpr float atan2_p7 = -0.04432655554792128F * (180 / pi); ```
This implementation didn't introduce any new math approach, the constants were simply polynomial coefficients copied from https://github.com/opencv/opencv/blob/08a24ba2cf5007a2639035cc9661e18f3637223e/modules/core/src/mathfuncs_core.simd.hpp#L36-L39 Presumably it's a 7th degree polynomial approximation for Arctan(x) where x in [0, 1], the optimal coefficients can be evaluated using [Remez algorithm](https://en.wikipedia.org/wiki/Remez_algorithm) I guess? Should I add this in my code comment, or add them to `mathfuncs_core.simd.hpp` ```suggestion // ref: mathfuncs_core.simd.hpp, 7th degree polynomial form Remez algorithm? ```
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/inpainting.cpp **Change Type:** added **Context:** PR #26736: Added lama inpainting onnx model sample **Review Line:** 17 **Code Changes:** ```diff + + ./example_dnn_inpainting + The system will ask you to draw the mask on area to be inpainted + + You can download lama inpainting model using: + `python download_models.py lama` + + References: + Github: https://github.com/advimman/lama + ONNX model: https://huggingface.co/Carve/LaMa-ONNX/blob/main/lama_fp32.onnx + ```
I propose to add reference to the original model and how it was converted, if it's not onnx or simplification was applied.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/inpainting.cpp **Change Type:** added **Context:** PR #26736: Added lama inpainting onnx model sample **Code Changes:** ```diff @@ -0,0 +1,230 @@ +/* +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. + +This sample inpaints the masked area in the given image. + +Copyright (C) 2025, Bigvision LLC. + ```
{ formatting is different.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/inpainting.cpp **Change Type:** added **Context:** PR #26736: Added lama inpainting onnx model sample **Code Changes:** ```diff @@ -0,0 +1,230 @@ +/* +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. + +This sample inpaints the masked area in the given image. + +Copyright (C) 2025, Bigvision LLC. + ```
I propose to print hot keys at the very beginning to make them more obvious.
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/inpainting.cpp **Change Type:** added **Context:** PR #26736: Added lama inpainting onnx model sample **Review Line:** 13 **Code Changes:** ```diff +Copyright (C) 2025, Bigvision LLC. + +How to use: + Sample command to run: + + ./example_dnn_inpainting + The system will ask you to draw the mask on area to be inpainted + + You can download lama inpainting model using: + `python download_models.py lama` + ```
the comment should describe how to provide custom input, e.g. `./example_dnn_inpainting [--input=<image_name>]`
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/inpainting.cpp **Change Type:** added **Context:** PR #26736: Added lama inpainting onnx model sample **Code Changes:** ```diff @@ -0,0 +1,230 @@ +/* +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. + +This sample inpaints the masked area in the given image. + +Copyright (C) 2025, Bigvision LLC. + ```
there should be a loop: until user presses 'escape', he/she should be able to draw another mask on the same original image.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/inpainting.cpp **Change Type:** added **Context:** PR #26736: Added lama inpainting onnx model sample **Review Line:** 1 **Code Changes:** ```diff @@ -0,0 +1,230 @@ +/* +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. + +This sample inpaints the masked area in the given image. ```
OpenCV license should be inserted before BigVision copyright in order to avoid any confusion
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_io.cpp **Change Type:** modified **Context:** PR #26846: Fix bug with int64 support for FileStorage **Code Changes:** ```diff @@ -2003,6 +2003,64 @@ TEST(Core_InputOutput, FileStorage_invalid_attribute_value_regression_25946) ASSERT_EQ(0, std::remove(fileName.c_str())); } +// see https://github.com/opencv/opencv/issues/26829 +TEST(Core_InputOutput, FileStorage_int64_26829) +{ + String content = + "%YAML:1.0\n" + "String1: string1\n" ```
pleas use `tempfile()` call for file name. Not all platforms allow file i/o in current directory.
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/core/test/test_io.cpp **Change Type:** modified **Context:** PR #26846: Fix bug with int64 support for FileStorage **Review Line:** 2061 **Code Changes:** ```diff + fs["Int64Min"] >> value; + EXPECT_EQ(value, INT64_MIN); + + fs["Int64Max"] >> value; + EXPECT_EQ(value, INT64_MAX); + } +} + template <typename T> T fsWriteRead(const T& expectedValue, const char* ext) { ```
The file is not removed. Actually you can use in-memory representation of FileStorage to exclude file io from pipeline. See https://docs.opencv.org/4.x/da/d56/classcv_1_1FileStorage.html#a973e41cb75ef6230412a567723b7482dabdde7670c9c7e472f8445932ea7cbbf7
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_gif.cpp **Change Type:** modified **Context:** PR #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE **Code Changes:** ```diff @@ -14,7 +14,7 @@ namespace cv ////////////////////////////////////////////////////////////////////// GifDecoder::GifDecoder() { m_signature = R"(GIF)"; - m_type = CV_8UC4; + m_type = CV_8UC3; bgColor = -1; m_buf_supported = true; globalColorTableSize = 0; @@ -172,12 +172,17 @@ bool GifDecoder::readData(Mat &img) { ```
It's error. I propose to include amount of channels to error message in printf style like https://github.com/opencv/opencv/blob/c21d0ad9d08d364542bb4a6eb971ee3051ccba63/modules/imgcodecs/src/grfmt_jpeg.cpp#L771
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_gif.cpp **Change Type:** modified **Context:** PR #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE **Code Changes:** ```diff @@ -241,17 +241,17 @@ TEST(Imgcodecs_Gif, read_gif_special){ const string gif_filename2 = root + "gifsuite/special2.gif"; const string png_filename2 = root + "gifsuite/special2.png"; cv::Mat gif_img1; - ASSERT_NO_THROW(gif_img1 = cv::imread(gif_filename1,IMREAD_UNCHANGED)); + ASSERT_NO_THROW(gif_img1 = cv::imread(gif_filename1,IMREAD_COLOR)); ASSERT_FALSE(gif_img1.empty()); cv::Mat png_img1; - ASSERT_NO_THROW(png_img1 = cv::imread(png_filename1,IMREAD_UNCHANGED)); + ASSERT_NO_THROW(png_img1 = cv::imread(png_filename1,IMREAD_COLOR)); ```
the color conversion is not needed, if you use imread without 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_gif.cpp **Change Type:** modified **Context:** PR #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE **Code Changes:** ```diff @@ -241,17 +241,17 @@ TEST(Imgcodecs_Gif, read_gif_special){ const string gif_filename2 = root + "gifsuite/special2.gif"; const string png_filename2 = root + "gifsuite/special2.png"; cv::Mat gif_img1; - ASSERT_NO_THROW(gif_img1 = cv::imread(gif_filename1,IMREAD_UNCHANGED)); + ASSERT_NO_THROW(gif_img1 = cv::imread(gif_filename1,IMREAD_COLOR)); ASSERT_FALSE(gif_img1.empty()); cv::Mat png_img1; - ASSERT_NO_THROW(png_img1 = cv::imread(png_filename1,IMREAD_UNCHANGED)); + ASSERT_NO_THROW(png_img1 = cv::imread(png_filename1,IMREAD_COLOR)); ```
'special1.png' and `special2.png` have alpha channel, but ‘special1.gif' and `special2.png` do not. Having different arguments to imread() for each image type would have obscured the purpose of the test, so I modified it so that all imread()s use the same arguments `cv::IMREAD_COLOR`.
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 #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE **Code Changes:** ```diff @@ -413,13 +413,13 @@ can be saved using this function, with these exceptions: - With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved. - With JPEG XL encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U) and 32-bit float(CV_32F) images can be saved. - JPEG XL images with an alpha channel can be saved using this function. - To do this, create 8-bit (or 16-bit, 32-bit float) 4-channel image BGRA, where the alpha channel goes last. - Fully transparent pixels should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535/1.0. + To achieve this, create an 8-bit 4-channel (CV_8UC4) / 16-bit 4-channel (CV_16UC4) / 32-bit float 4-channel (CV_32FC4) BGRA image, ensuring the alpha channel is the last component. + Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255/65535/1.0. - With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved. - With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved. ```
8-bit single-channel images (CV_8UC1) are not supported by the GIF specification due to its limitation to indexed color formats.
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/imgcodecs/include/opencv2/imgcodecs.hpp **Change Type:** modified **Context:** PR #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE **Code Changes:** ```diff @@ -413,13 +413,13 @@ can be saved using this function, with these exceptions: - With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved. - With JPEG XL encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U) and 32-bit float(CV_32F) images can be saved. - JPEG XL images with an alpha channel can be saved using this function. - To do this, create 8-bit (or 16-bit, 32-bit float) 4-channel image BGRA, where the alpha channel goes last. - Fully transparent pixels should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535/1.0. + To achieve this, create an 8-bit 4-channel (CV_8UC4) / 16-bit 4-channel (CV_16UC4) / 32-bit float 4-channel (CV_32FC4) BGRA image, ensuring the alpha channel is the last component. + Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255/65535/1.0. - With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved. - With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved. ```
note : i support the idea of getting help from AI about documentation improvements. The GIF encoder supports saving 8-bit unsigned (CV_8U) images. GIF images with an alpha channel can be saved using this function. To achieve this, create an 8-bit 4-channel (CV_8UC4) BGRA image, ensuring the alpha channel is the last component. Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255. 8-bit single-channel images (CV_8UC1) are not supported due to GIF's limitation to indexed color formats.
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/imgcodecs/include/opencv2/imgcodecs.hpp **Change Type:** modified **Context:** PR #26859: imgcodecs:gif: support IMREAD_UNCHANGED and IMREAD_GRAYSCALE **Code Changes:** ```diff @@ -413,13 +413,13 @@ can be saved using this function, with these exceptions: - With JPEG 2000 encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved. - With JPEG XL encoder, 8-bit unsigned (CV_8U), 16-bit unsigned (CV_16U) and 32-bit float(CV_32F) images can be saved. - JPEG XL images with an alpha channel can be saved using this function. - To do this, create 8-bit (or 16-bit, 32-bit float) 4-channel image BGRA, where the alpha channel goes last. - Fully transparent pixels should have alpha set to 0, fully opaque pixels should have alpha set to 255/65535/1.0. + To achieve this, create an 8-bit 4-channel (CV_8UC4) / 16-bit 4-channel (CV_16UC4) / 32-bit float 4-channel (CV_32FC4) BGRA image, ensuring the alpha channel is the last component. + Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255/65535/1.0. - With PAM encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved. - With PNG encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved. ```
updated document preview is here. https://pullrequest.opencv.org/buildbot/export/pr/26859/docs/d4/da8/group__imgcodecs.html#ga8ac397bd09e48851665edbe12aa28f25
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 #26854: Fix oss-fuzz bugs 391934081 and 392318892 **Code Changes:** ```diff @@ -325,15 +325,6 @@ bool PngDecoder::readHeader() bop = chunk.p[33]; } - if (id == id_bKGD) - { - // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD - m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]); - m_animation.bgcolor[1] = png_get_uint_16(&chunk.p[10]); - m_animation.bgcolor[2] = png_get_uint_16(&chunk.p[12]); ```
It should be BGR by default, right?
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/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #26854: Fix oss-fuzz bugs 391934081 and 392318892 **Code Changes:** ```diff @@ -325,15 +325,6 @@ bool PngDecoder::readHeader() bop = chunk.p[33]; } - if (id == id_bKGD) - { - // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD - m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]); - m_animation.bgcolor[1] = png_get_uint_16(&chunk.p[10]); - m_animation.bgcolor[2] = png_get_uint_16(&chunk.p[12]); ```
> It should be BGR by default, right? i think RGB is OK as far as i test before. to other applications opens the file.
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/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #26854: Fix oss-fuzz bugs 391934081 and 392318892 **Code Changes:** ```diff @@ -325,15 +325,6 @@ bool PngDecoder::readHeader() bop = chunk.p[33]; } - if (id == id_bKGD) - { - // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD - m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]); - m_animation.bgcolor[1] = png_get_uint_16(&chunk.p[10]); - m_animation.bgcolor[2] = png_get_uint_16(&chunk.p[12]); ```
related test is also expect RGB
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 #26854: Fix oss-fuzz bugs 391934081 and 392318892 **Code Changes:** ```diff @@ -325,15 +325,6 @@ bool PngDecoder::readHeader() bop = chunk.p[33]; } - if (id == id_bKGD) - { - // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD - m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]); - m_animation.bgcolor[1] = png_get_uint_16(&chunk.p[10]); - m_animation.bgcolor[2] = png_get_uint_16(&chunk.p[12]); ```
OpenCV uses BGR everywhere by default, including colors on drawing. We should align the implementation then.
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/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #26854: Fix oss-fuzz bugs 391934081 and 392318892 **Code Changes:** ```diff @@ -325,15 +325,6 @@ bool PngDecoder::readHeader() bop = chunk.p[33]; } - if (id == id_bKGD) - { - // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD - m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]); - m_animation.bgcolor[1] = png_get_uint_16(&chunk.p[10]); - m_animation.bgcolor[2] = png_get_uint_16(&chunk.p[12]); ```
Right, that is what the doc says anyway
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/photo/test/test_denoising.cpp **Change Type:** modified **Context:** PR #26831: added 16-bit support to fastNlMeansDenoising and updated tests **Code Changes:** ```diff @@ -165,4 +165,33 @@ TEST(Photo_Denoising, speed) printf("execution time: %gms\n", t*1000./getTickFrequency()); } +// Related issue : https://github.com/opencv/opencv/issues/26582 +TEST(Photo_DenoisingGrayscaleMulti16bitL1, regression) +{ + const int imgs_count = 3; + string folder = string(cvtest::TS::ptr()->get_data_path()) + "denoising/"; + ```
Please use cv::PSNR instead: https://docs.opencv.org/4.x/d2/de8/group__core__array.html#ga3119e3ea73010a6f810bb05aa36ac8d6
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVFindAVIF.cmake **Change Type:** modified **Context:** PR #26762: Fixed AVIF linkage on Windows **Code Changes:** ```diff @@ -19,7 +19,7 @@ if(TARGET avif) MARK_AS_ADVANCED(AVIF_LIBRARY) SET(AVIF_FOUND TRUE) - GET_TARGET_PROPERTY(AVIF_LIBRARY avif LOCATION) + SET(AVIF_LIBRARY avif) GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR1 avif INCLUDE_DIRECTORIES) GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR2 avif INTERFACE_INCLUDE_DIRECTORIES) set(AVIF_INCLUDE_DIR) ```
Is this variable really necessary? I suppose all `INTERFACE_LINK_LIBRARIES` from `avif` target would be automatically linked by cmake. Perhaps we don't need to read target properties at all.
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/OpenCVFindAVIF.cmake **Change Type:** modified **Context:** PR #26762: Fixed AVIF linkage on Windows **Code Changes:** ```diff @@ -19,7 +19,7 @@ if(TARGET avif) MARK_AS_ADVANCED(AVIF_LIBRARY) SET(AVIF_FOUND TRUE) - GET_TARGET_PROPERTY(AVIF_LIBRARY avif LOCATION) + SET(AVIF_LIBRARY avif) GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR1 avif INCLUDE_DIRECTORIES) GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR2 avif INTERFACE_INCLUDE_DIRECTORIES) set(AVIF_INCLUDE_DIR) ```
the difference was only in cmake output. now for shared and static lib output is like `AVIF: avif (ver 1.1.1)`
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 #26851: fix related the issue 22551 **Code Changes:** ```diff @@ -126,9 +126,10 @@ const uint32_t id_acTL = 0x4C546361; // Animation control chunk const uint32_t id_fcTL = 0x4C546366; // Frame control chunk const uint32_t id_IDAT = 0x54414449; // first frame and/or default image const uint32_t id_fdAT = 0x54416466; // Frame data chunk -const uint32_t id_PLTE = 0x45544C50; -const uint32_t id_bKGD = 0x44474B62; -const uint32_t id_tRNS = 0x534E5274; +const uint32_t id_PLTE = 0x45544C50; // The PLTE chunk contains a color palette for indexed-color images +const uint32_t id_bKGD = 0x44474B62; // The bKGD chunk specifies a default background color for the image +const uint32_t id_tRNS = 0x534E5274; // The tRNS chunk provides transparency information ```
Please just move id_tExt to the line above and respect the alphabetical order. Thx. This PNG_USER_CHUNK_MALLOC_MAX could also be an env variable that the user can change.
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 #26851: fix related the issue 22551 **Code Changes:** ```diff @@ -126,9 +126,10 @@ const uint32_t id_acTL = 0x4C546361; // Animation control chunk const uint32_t id_fcTL = 0x4C546366; // Frame control chunk const uint32_t id_IDAT = 0x54414449; // first frame and/or default image const uint32_t id_fdAT = 0x54416466; // Frame data chunk -const uint32_t id_PLTE = 0x45544C50; -const uint32_t id_bKGD = 0x44474B62; -const uint32_t id_tRNS = 0x534E5274; +const uint32_t id_PLTE = 0x45544C50; // The PLTE chunk contains a color palette for indexed-color images +const uint32_t id_bKGD = 0x44474B62; // The bKGD chunk specifies a default background color for the image +const uint32_t id_tRNS = 0x534E5274; // The tRNS chunk provides transparency information ```
> Please just move id_tExt to the line above and respect the alphabetical order. Thx. This PNG_USER_CHUNK_MALLOC_MAX could also be an env variable that the user can change. done.
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_jpegxl.cpp **Change Type:** modified **Context:** PR #26844: imgcodecs: jpegxl: imdecode() directly read from memory **Code Changes:** ```diff @@ -28,13 +28,15 @@ static void cbRGBAtoGRAY_32F(void *opaque, size_t x, size_t y, size_t num_pixels /////////////////////// JpegXLDecoder /////////////////// -JpegXLDecoder::JpegXLDecoder() : m_f(nullptr, &fclose) +JpegXLDecoder::JpegXLDecoder() : m_f(nullptr, &fclose), + m_read_buffer(16384,0) // 16KB chunks { m_signature = "\xFF\x0A"; m_decoder = nullptr; ```
If I understood correctly, The m_read_buffer is resized only once here ant it's size is always 16k. The `m_read_buffer` is used in ::read() only. M.b. it's better to make it local variable there. If you need the buffer shared between readHeader and readData then it makes sense to initialize the buffer in decoder constructor.
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 #26835: Corrections on bKGD chunk writing and reading in PNG **Code Changes:** ```diff @@ -327,11 +327,10 @@ bool PngDecoder::readHeader() if (id == id_bKGD) { // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD - int bgcolor = png_get_uint_32(&chunk.p[8]); - m_animation.bgcolor[3] = (bgcolor >> 24) & 0xFF; - m_animation.bgcolor[2] = (bgcolor >> 16) & 0xFF; - m_animation.bgcolor[1] = (bgcolor >> 8) & 0xFF; - m_animation.bgcolor[0] = bgcolor & 0xFF; + m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]); ```
You should use png_get_uint_16
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 #26835: Corrections on bKGD chunk writing and reading in PNG **Code Changes:** ```diff @@ -327,11 +327,10 @@ bool PngDecoder::readHeader() if (id == id_bKGD) { // The spec is actually more complex: http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD - int bgcolor = png_get_uint_32(&chunk.p[8]); - m_animation.bgcolor[3] = (bgcolor >> 24) & 0xFF; - m_animation.bgcolor[2] = (bgcolor >> 16) & 0xFF; - m_animation.bgcolor[1] = (bgcolor >> 8) & 0xFF; - m_animation.bgcolor[0] = bgcolor & 0xFF; + m_animation.bgcolor[0] = png_get_uint_16(&chunk.p[8]); ```
Actually, let's follow the spec: `size != 8 + 1 && size != 8 + 2 && size != 8 + 6`
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 #26835: Corrections on bKGD chunk writing and reading in PNG **Review Line:** 726 **Code Changes:** ```diff + // 8=HDR+size, (1, 2 or 6)=size of bKGD chunk, 4=CRC // The spec is actually more complex: // http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD - // TODO: we only check that 4 bytes can be read from &chunk.p[8]. Fix. - if (size < 8 + 4) + if (size != 8 + 1 + 4 && size != 8 + 2 + 4 && size != 8 + 6 + 4) return 0; } else if (id != id_fdAT && id != id_IDAT && id != id_IEND && id != id_PLTE && id != id_tRNS) { if (size > PNG_USER_CHUNK_MALLOC_MAX) @@ -1533,13 +1531,13 @@ bool PngEncoder::writeanimation(const Animation& animation, const std::vector<in if (palsize > 0) ```
Thx, I had forgotten the CRC !
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_decode_encode.cpp **Change Type:** added **Context:** PR #26872: Performance tests for image encoders and decoders and code cleanup **Review Line:** 70 **Code Changes:** ```diff + +PERF_TEST_P(Decode, bgr, testing::ValuesIn(exts)) +{ + String filename = getDataPath("perf/1920x1080.png"); + + Mat src = imread(filename); + EXPECT_FALSE(src.empty()) << "Cannot open test image perf/1920x1080.png"; + vector<uchar> buf; + EXPECT_TRUE(imencode(GetParam(), src, buf)); + + TEST_CYCLE() imdecode(buf, IMREAD_UNCHANGED); ```
`EXPECT_FALSE(src.empty()) << Cannot open test image perf/1920x1080.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/perf/perf_decode_encode.cpp **Change Type:** added **Context:** PR #26872: Performance tests for image encoders and decoders and code cleanup **Review Line:** 84 **Code Changes:** ```diff + +PERF_TEST_P(Decode, rgb, testing::ValuesIn(exts)) +{ + String filename = getDataPath("perf/1920x1080.png"); + + Mat src = imread(filename); + EXPECT_FALSE(src.empty()) << "Cannot open test image perf/1920x1080.png"; + vector<uchar> buf; + EXPECT_TRUE(imencode(GetParam(), src, buf)); + + TEST_CYCLE() imdecode(buf, IMREAD_COLOR_RGB); ```
`EXPECT_FALSE(src.empty()) << Cannot open test image perf/1920x1080.png;`
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_decode_encode.cpp **Change Type:** added **Context:** PR #26872: Performance tests for image encoders and decoders and code cleanup **Code Changes:** ```diff @@ -0,0 +1,131 @@ +// 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 +{ + ```
Add sanity check if the file read correctly.
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/norm.cpp **Change Type:** modified **Context:** PR #26804: Add RISC-V HAL implementation for cv::norm and cv::normalize **Review Line:** 630 **Code Changes:** ```diff Mat src = _src.getMat(), mask = _mask.getMat(); + int depth = src.depth(), cn = src.channels(); + if( src.dims <= 2 ) + { + double result; + CALL_HAL_RET(norm, cv_hal_norm, result, src.data, src.step, mask.data, mask.step, src.cols, src.rows, src.type(), normType); + } + else if( src.isContinuous() && mask.isContinuous() ) + { + double result; + CALL_HAL_RET(norm, cv_hal_norm, result, src.data, 0, mask.data, 0, (int)src.total(), 1, src.type(), normType); ```
Usually we have HAL call before IPP branch (and after OCL).
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/norm.cpp **Change Type:** modified **Context:** PR #26804: Add RISC-V HAL implementation for cv::norm and cv::normalize **Review Line:** 1127 **Code Changes:** ```diff + Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); + int depth = src1.depth(), cn = src1.channels(); + if( src1.dims <= 2 ) + { + double result; + CALL_HAL_RET(normDiff, cv_hal_normDiff, result, src1.data, src1.step, src2.data, src2.step, mask.data, mask.step, src1.cols, src1.rows, src1.type(), normType); + } + else if( src1.isContinuous() && src2.isContinuous() && mask.isContinuous() ) + { + double result; + CALL_HAL_RET(normDiff, cv_hal_normDiff, result, src1.data, 0, src2.data, 0, mask.data, 0, (int)src1.total(), 1, src1.type(), normType); ```
Usually we have HAL call before IPP branch (and after OCL).
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/norm.cpp **Change Type:** modified **Context:** PR #26804: Add RISC-V HAL implementation for cv::norm and cv::normalize **Review Line:** 1127 **Code Changes:** ```diff + Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat(); + int depth = src1.depth(), cn = src1.channels(); + if( src1.dims <= 2 ) + { + double result; + CALL_HAL_RET(normDiff, cv_hal_normDiff, result, src1.data, src1.step, src2.data, src2.step, mask.data, mask.step, src1.cols, src1.rows, src1.type(), normType); + } + else if( src1.isContinuous() && src2.isContinuous() && mask.isContinuous() ) + { + double result; + CALL_HAL_RET(normDiff, cv_hal_normDiff, result, src1.data, 0, src2.data, 0, mask.data, 0, (int)src1.total(), 1, src1.type(), normType); ```
Fixed. `ipp_norm` supports CV_RELATIVE, so I have to modify HAL implement to move CALL_HAL before IPP.
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 #26789: Add RISC-V HAL implementation for minMaxIdx **Review Line:** 912 **Code Changes:** ```diff @@ -911,8 +911,26 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, int depth, double* minVal, double* maxVal, int* minIdx, int* maxIdx, uchar* mask) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +/** + @brief Finds the global minimum and maximum in an array. + @param src_data Source image + @param src_step Source image ```
It breaks existing HAL implementations.
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/hal_replacement.hpp **Change Type:** modified **Context:** PR #26789: Add RISC-V HAL implementation for minMaxIdx **Review Line:** 912 **Code Changes:** ```diff @@ -911,8 +911,26 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, int depth, double* minVal, double* maxVal, int* minIdx, int* maxIdx, uchar* mask) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +/** + @brief Finds the global minimum and maximum in an array. + @param src_data Source image + @param src_step Source image ```
Should I create a new HAL interface, or just simply remove these lines below? https://github.com/opencv/opencv/blob/133fda3c56bc7199de86c94f1522d56d7253bc6a/modules/core/src/minmax.cpp#L1515-L1519 Without `mask_step` argument, it is impossible to implement the HAL when mask is not continuous.
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/hal_replacement.hpp **Change Type:** modified **Context:** PR #26789: Add RISC-V HAL implementation for minMaxIdx **Review Line:** 912 **Code Changes:** ```diff @@ -911,8 +911,26 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, int depth, double* minVal, double* maxVal, int* minIdx, int* maxIdx, uchar* mask) { return CV_HAL_ERROR_NOT_IMPLEMENTED; } +/** + @brief Finds the global minimum and maximum in an array. + @param src_data Source image + @param src_step Source image ```
I have tried to keep the ABI by creating a new interface.
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:** added **Context:** PR #26789: Add RISC-V HAL implementation for minMaxIdx **Code Changes:** ```diff @@ -0,0 +1,335 @@ +// 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_MINMAXIDX_HPP_INCLUDED +#define OPENCV_HAL_RVV_MINMAXIDX_HPP_INCLUDED + +#include <riscv_vector.h> + +namespace cv { namespace cv_hal_rvv { ```
In general it is hard to debug multi-line macros. C++ template-based approach is preferable.
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:** 3rdparty/ippicv/ippicv.cmake **Change Type:** modified **Context:** PR #26463: Update IPP integration - Please merge together with https://github.com/opencv/opencv_3rdparty/pull/88 Supported IPP version was updated to ... **Review Line:** 5 **Code Changes:** ```diff @@ -2,7 +2,7 @@ function(download_ippicv root_var) set(${root_var} "" PARENT_SCOPE) # Commit SHA in the opencv_3rdparty repo - set(IPPICV_COMMIT "7f55c0c26be418d494615afca15218566775c725") + set(IPPICV_COMMIT "d1cbea44d326eb0421fedcdd16de4630fd8c7ed0") # Define actual ICV versions if(APPLE) set(IPPICV_COMMIT "0cc4aa06bf2bef4b05d237c69a5a96b9cd0cb85a") @@ -14,19 +14,21 @@ function(download_ippicv root_var) set(OPENCV_ICV_PLATFORM "linux") ```
- [ ] Shouldn't it be different for x86 and x86_64 as only x86_64 ICV packages are available since IPP 2022.0.0?
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/src/filter.hpp **Change Type:** modified **Context:** PR #26850: Update includes in filter.hpp **Review Line:** 47 **Code Changes:** ```diff @@ -43,6 +43,9 @@ #ifndef OPENCV_IMGPROC_FILTER_HPP #define OPENCV_IMGPROC_FILTER_HPP +#include <opencv2/core.hpp> +#include <vector> + namespace cv { #ifdef HAVE_OPENCL ```
please add space before namespace.
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/videoio/src/cap_android_camera.cpp **Change Type:** modified **Context:** PR #26837: Zoom functionality for Android native camera capture **Review Line:** 433 **Code Changes:** ```diff { @@ -437,6 +430,12 @@ class AndroidCameraCapture : public IVideoCapture return submitRequest(ACaptureRequest_setEntry_i32, ACAMERA_SENSOR_SENSITIVITY, sensitivity); } return false; + case CAP_PROP_ZOOM: + if (isOpened() && zoomRange.isValid()) { + zoomRatio = zoomRange.clamp(static_cast<float>(value)); + return submitRequest(ACaptureRequest_setEntry_float, ACAMERA_CONTROL_ZOOM_RATIO, zoomRatio); + } + return true; ```
I propose to document the option for Android in https://github.com/opencv/opencv/blob/ab77e1cfc87d7908c09fa4d11cbeaac9e4c663fb/modules/videoio/include/opencv2/videoio.hpp#L171.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/include/opencv2/imgproc.hpp **Change Type:** modified **Context:** PR #26836: Add cv::THRESH_DRYRUN flag to get adaptive threshold values without thresholding **Code Changes:** ```diff @@ -329,7 +329,8 @@ enum ThresholdTypes { THRESH_TOZERO_INV = 4, //!< \f[\texttt{dst} (x,y) = \fork{0}{if \(\texttt{src}(x,y) > \texttt{thresh}\)}{\texttt{src}(x,y)}{otherwise}\f] THRESH_MASK = 7, THRESH_OTSU = 8, //!< flag, use Otsu algorithm to choose the optimal threshold value - THRESH_TRIANGLE = 16 //!< flag, use Triangle algorithm to choose the optimal threshold value + THRESH_TRIANGLE = 16, //!< flag, use Triangle algorithm to choose the optimal threshold value + THRESH_DRYRUN = 128 //!< flag, compute threshold only (useful for OTSU/TRIANGLE) but does not actually run thresholding }; //! adaptive threshold algorithm ```
The name is very controversial. I propose `THRESH_DRYRUN` or something similar.
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/ocl/test_imgproc.cpp **Change Type:** modified **Context:** PR #26836: Add cv::THRESH_DRYRUN flag to get adaptive threshold values without thresholding **Code Changes:** ```diff @@ -386,6 +386,40 @@ OCL_TEST_P(Threshold, Mat) } } +struct Threshold_Dryrun : + public ImgprocTestBase +{ + int thresholdType; + + virtual void SetUp() ```
Dryrun in naming too.