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_avif.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Code Changes:**
```diff
@@ -11,6 +11,7 @@
#include <memory>
#include <opencv2/core/utils/configuration.private.hpp>
+#include <opencv2/core/utils/logger.hpp>
#include "opencv2/imgproc.hpp"
#include "grfmt_avif.hpp"
@@ -242,6 +243,8 @@ bool AvifDecoder::readData(Mat &img) {
return false;
``` | Looks like timestamps are used differently in writemulti and writeanimation. If I got correctly, timestamps contains frame duration rather then timestamp. In this case, `timestamp` should not be incremented, but set equal to 10 once outside the loop. Also I recommends something like 33ms (fps). |
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_avif.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Code Changes:**
```diff
@@ -11,6 +11,7 @@
#include <memory>
#include <opencv2/core/utils/configuration.private.hpp>
+#include <opencv2/core/utils/logger.hpp>
#include "opencv2/imgproc.hpp"
#include "grfmt_avif.hpp"
@@ -242,6 +243,8 @@ bool AvifDecoder::readData(Mat &img) {
return false;
``` | i removed the line `timestamp += 10;` |
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 #25608: Animated WebP and AVIF Support
**Code Changes:**
```diff
@@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags {
//! @} imgcodecs_flags
+/** @brief Represents an animation with multiple frames.
+The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP).
+It provides support for looping, background color settings, frame timing, and frame storage.
+*/
+struct CV_EXPORTS_W_SIMPLE Animation
+{
``` | Let it be BGRA as everywhere in OpenCV. |
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 #25608: Animated WebP and AVIF Support
**Code Changes:**
```diff
@@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags {
//! @} imgcodecs_flags
+/** @brief Represents an animation with multiple frames.
+The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP).
+It provides support for looping, background color settings, frame timing, and frame storage.
+*/
+struct CV_EXPORTS_W_SIMPLE Animation
+{
``` | Also you can use cv::Scalar. |
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_base.hpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Code Changes:**
```diff
@@ -133,6 +133,8 @@ class BaseImageDecoder {
*/
virtual bool checkSignature(const String& signature) const;
+ const Animation& animation() const { return m_animation; };
+
/**
* @brief Create and return a new instance of the derived image decoder.
* @return A new ImageDecoder object.
@@ -151,6 +153,7 @@ class BaseImageDecoder {
``` | That should be a `Animation&`. Maybe a `const Animation&` if it compiles. |
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_avif.cpp
**Change Type:** modified
**Context:** PR #25608: Animated WebP and AVIF Support
**Code Changes:**
```diff
@@ -11,6 +11,7 @@
#include <memory>
#include <opencv2/core/utils/configuration.private.hpp>
+#include <opencv2/core/utils/logger.hpp>
#include "opencv2/imgproc.hpp"
#include "grfmt_avif.hpp"
@@ -242,6 +243,8 @@ bool AvifDecoder::readData(Mat &img) {
return false;
``` | move this line to above avifEncoderAddImage because avifEncoderAddImage expects a duration, not a timestamp. |
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/src/opengl.cpp
**Change Type:** modified
**Context:** PR #26281: Rewrote OpenCL-OpenGL-interop device discovery routine without extensions and with Apple support
**Review Line:** 1671
**Code Changes:**
```diff
- {
- // query platform extension: presence of "cl_khr_gl_sharing" extension is required
- {
- AutoBuffer<char> extensionStr;
+ try {
+ devices = new cl_device_id[devCnt];
- size_t extensionSize;
- status = clGetPlatformInfo(platforms[i], CL_PLATFORM_EXTENSIONS, 0, NULL, &extensionSize);
- if (status == CL_SUCCESS)
- {
``` | Let's use `std::vector<>` or `cv::AutoBuffer` for locals to prevent leaks. |
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/core/src/opengl.cpp
**Change Type:** modified
**Context:** PR #26281: Rewrote OpenCL-OpenGL-interop device discovery routine without extensions and with Apple support
**Review Line:** 1688
**Code Changes:**
```diff
+ if(extensionSize > 0)
+ {
+ char* extensions = nullptr;
+
+ try {
+ extensions = new char[extensionSize];
+
+ status = clGetDeviceInfo(devices[j], CL_DEVICE_EXTENSIONS, extensionSize, extensions, &extensionSize);
+ if (status != CL_SUCCESS)
+ continue;
+ } catch(...) {
``` | The same on memory management. |
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/opengl.cpp
**Change Type:** modified
**Context:** PR #26281: Rewrote OpenCL-OpenGL-interop device discovery routine without extensions and with Apple support
**Review Line:** 1724
**Code Changes:**
```diff
+ oldPos = spacePos + 1;
+ spacePos = devString.find(' ', oldPos);
+ } while (spacePos == oldPos);
+ }
+ }
+ }
+ } catch(...) {
+ CV_Error(cv::Error::OpenCLInitError, "OpenCL: Exception thrown during device information gathering");
+ if(devices != nullptr) {
+ delete[] devices;
+ }
``` | Let's extract extension search as dedicated static function. It should make the code more readable. |
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_jpegxl.cpp
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Code Changes:**
```diff
@@ -0,0 +1,420 @@
+// 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 "grfmt_jpegxl.hpp"
+
+#ifdef HAVE_JPEGXL
+
+#include <jxl/encode_cxx.h>
``` | please use modern copyright header like in https://github.com/opencv/opencv/blob/4.x/modules/dnn/src/backend.cpp |
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_jpegxl.cpp
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Code Changes:**
```diff
@@ -0,0 +1,420 @@
+// 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 "grfmt_jpegxl.hpp"
+
+#ifdef HAVE_JPEGXL
+
+#include <jxl/encode_cxx.h>
``` | OpenCV supports IMREAD_COLOR_RGB flag to get RGB without conversion. |
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_jpegxl.cpp
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Code Changes:**
```diff
@@ -0,0 +1,420 @@
+// 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 "grfmt_jpegxl.hpp"
+
+#ifdef HAVE_JPEGXL
+
+#include <jxl/encode_cxx.h>
``` | I propose to use `num_worker_threads = cv::getNumThreads()` to make it manageable outside. See https://docs.opencv.org/4.x/db/de0/group__core__utils.html#ga2db334ec41d98da3129ef4a2342fc4d4 |
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_jpegxl.cpp
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Code Changes:**
```diff
@@ -0,0 +1,420 @@
+// 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 "grfmt_jpegxl.hpp"
+
+#ifdef HAVE_JPEGXL
+
+#include <jxl/encode_cxx.h>
``` | OpenCV's `imread` is exception safe. Please use CV_LOG_WARNING and analogs and return satus instead of exception. |
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_jpegxl.cpp
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Code Changes:**
```diff
@@ -0,0 +1,420 @@
+// 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 "grfmt_jpegxl.hpp"
+
+#ifdef HAVE_JPEGXL
+
+#include <jxl/encode_cxx.h>
``` | cv::getNumThreads(). |
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_jpegxl.cpp
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Code Changes:**
```diff
@@ -0,0 +1,420 @@
+// 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 "grfmt_jpegxl.hpp"
+
+#ifdef HAVE_JPEGXL
+
+#include <jxl/encode_cxx.h>
``` | Can you pls elaborate? An example? |
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/OpenCVFindJPEGXL.cmake
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Review Line:** 52
**Code Changes:**
```diff
+#]=======================================================================]
+
+if(NOT OPENCV_SKIP_JPEGXL_FIND_PACKAGE)
+find_package(PkgConfig QUIET)
+if (PkgConfig_FOUND)
+ pkg_check_modules(PC_JPEGXL QUIET jxl)
+ set(JPEGXL_COMPILE_OPTIONS ${PC_JPEGXL_CFLAGS_OTHER})
+ set(JPEGXL_VERSION ${PC_JPEGXL_VERSION})
+endif ()
+find_path(JPEGXL_INCLUDE_DIR
+ NAMES jxl/decode.h
``` | I tried building standalone libjxl and it uses `libjxl` name for pkg-config, so this line fails to find it. I understand that this file is taken from another project, but perhaps we could tune it slightly for our needs. Another thing in my opinion is that it mixes pkg-config and separate `find_*` calls, it could result in mixing incompatible library versions - some found by pkg-config, others from system root. Maybe it would be better to add two blocks: ```.cmake # 1. try pkg-config pkg_check_modules(...) if(FOUND) # create targets using pc # success end() # 2. manual detection find_path(...) find_library(...) ... if(..all components were found...) # create targets using found components # success endif() ``` |
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 #26379: Add jxl (JPEG XL) codec support
**Code Changes:**
```diff
@@ -306,6 +306,9 @@ OCV_OPTION(WITH_OPENJPEG "Include JPEG2K support (OpenJPEG)" ON
OCV_OPTION(WITH_JPEG "Include JPEG support" ON
VISIBLE_IF TRUE
VERIFY HAVE_JPEG)
+OCV_OPTION(WITH_JPEGXL "Include JPEG XL support" OFF
+ VISIBLE_IF TRUE
+ VERIFY HAVE_JPEGXL)
OCV_OPTION(WITH_WEBP "Include WebP support" ON
VISIBLE_IF NOT WINRT
VERIFY HAVE_WEBP)
``` | Maybe we should turn it OFF by default for some time to stabilize this integration. |
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_jpegxl.cpp
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Review Line:** 214
**Code Changes:**
```diff
+ }
+ if (!pimg)
+ return true;
+ break;
+ }
+ case JXL_DEC_FULL_IMAGE: {
+ // Image is ready
+ if (m_convert != -1)
+ cv::cvtColor(*pimg, *pimg, m_convert);
+ break;
+ }
``` | Is it possible that this event will occure before `JXL_DEC_BASIC_INFO`? I didn't find this guarantee in the libjxl documentation. |
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/OpenCVFindJPEGXL.cmake
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Review Line:** 50
**Code Changes:**
```diff
+ this should be passed to target_compile_options(), if the
+ target is not used for linking
+#]=======================================================================]
+
+if(NOT OPENCV_SKIP_JPEGXL_FIND_PACKAGE)
+find_package(PkgConfig QUIET)
+if (PkgConfig_FOUND)
+ pkg_check_modules(PC_JPEGXL QUIET jxl)
+ set(JPEGXL_COMPILE_OPTIONS ${PC_JPEGXL_CFLAGS_OTHER})
+ set(JPEGXL_VERSION ${PC_JPEGXL_VERSION})
+endif ()
``` | There is the same call in the root cmake-file: https://github.com/opencv/opencv/blob/6873bdee70528ba6101bd5f4091b5f5302ee70c9/CMakeLists.txt#L710 We don't need to repeat it here. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/src/grfmt_jpegxl.cpp
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Review Line:** 118
**Code Changes:**
```diff
+
+ // Create image if needed
+ if (m_type != -1 && pimg) {
+ pimg->create(m_height, m_width, m_type);
+ if (!pimg->isContinuous())
+ return false;
+ if (JXL_DEC_SUCCESS != JxlDecoderSetImageOutBuffer(m_decoder.get(),
+ &m_format,
+ pimg->ptr<uint8_t>(),
+ pimg->total() * pimg->elemSize())) {
+ return false;
``` | Log warning at least. |
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_jpegxl.cpp
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Review Line:** 37
**Code Changes:**
```diff
+ break;
+ default:
+ case CV_8U:
+ col = cv::Scalar(124, 76, 42, 192);
+ th = 3; // = 255 / 100 (1%);
+ break;
+ }
+
+ // If increasing distanceParam, threshold should be increased.
+ th *= (distanceParam >= 25) ? 5 : ( distanceParam > 2 ) ? 3 : (distanceParam == 2) ? 2: 1;
+
``` | Add assert to default branch. |
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_jpegxl.cpp
**Change Type:** added
**Context:** PR #26379: Add jxl (JPEG XL) codec support
**Review Line:** 85
**Code Changes:**
```diff
+ break;
+ default:
+ case CV_8U:
+ col = cv::Scalar(124, 76, 42, 192);
+ th = 3; // = 255 / 100 (1%);
+ break;
+ }
+
+ // If increasing distanceParam, threshold should be increased.
+ th *= (distanceParam >= 25) ? 5 : ( distanceParam > 2 ) ? 3 : (distanceParam == 2) ? 2: 1;
+
``` | Add assert to default branch. |
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_mat.cpp
**Change Type:** modified
**Context:** PR #26254: Added extra tests for reshape
**Review Line:** 2687
**Code Changes:**
```diff
+ EXPECT_EQ(m.total(), v.size());
+
+ int sz[] = {(int)v.size()};
+ Mat m1 = m.reshape(0, 1, sz);
+ EXPECT_EQ(m1.dims, 1);
+ EXPECT_EQ(m1.type(), CV_32S);
+ EXPECT_EQ(m1.ptr<int>(), &v[0]);
+ EXPECT_EQ(m1.rows, 1);
+ EXPECT_EQ(m1.total(), v.size());
+
+ int sz3d[] = {2, -1, 3};
``` | Signature for `_EQ` is `ASSERT_EQ(expected_reference, actual_result);`. Correct order of parameters are required to emit valid error messages. Reference: https://github.com/opencv/opencv/blob/4.0.0/modules/ts/include/opencv2/ts/ts_gtest.h#L8196-L8200 ``` GTEST_API_ AssertionResult EqFailure(const char* expected_expression, const char* actual_expression, const std::string& expected_value, const std::string& actual_value, bool ignoring_case); ``` |
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_mat.cpp
**Change Type:** modified
**Context:** PR #26254: Added extra tests for reshape
**Code Changes:**
```diff
@@ -2669,4 +2669,219 @@ TEST(Mat, regression_26322)
EXPECT_EQ(0, (int)mat3.total());
}
+TEST(Mat, reshape_1d)
+{
+ std::vector<int> v = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ int newrows = 2;
+ Mat m = Mat(v).reshape(0, newrows);
+
``` | It should be just 2, but not `newrows`. They are not correlated. |
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_mat.cpp
**Change Type:** modified
**Context:** PR #26254: Added extra tests for reshape
**Code Changes:**
```diff
@@ -2669,4 +2669,219 @@ TEST(Mat, regression_26322)
EXPECT_EQ(0, (int)mat3.total());
}
+TEST(Mat, reshape_1d)
+{
+ std::vector<int> v = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ int newrows = 2;
+ Mat m = Mat(v).reshape(0, newrows);
+
``` | The same newrows -> 2. |
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/umatrix.cpp
**Change Type:** modified
**Context:** PR #26254: Added extra tests for reshape
**Code Changes:**
```diff
@@ -1063,9 +1063,6 @@ UMat UMat::reshape(int new_cn, int new_rows) const
CV_Error( cv::Error::BadStep,
"The matrix is not continuous, thus its number of rows can not be changed" );
- if( (unsigned)new_rows > (unsigned)total_size )
- CV_Error( cv::Error::StsOutOfRange, "Bad new number of rows" );
-
total_width = total_size / new_rows;
if( total_width * new_rows != total_size )
``` | should it be a part of dst.create()? |
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/matrix.cpp
**Change Type:** modified
**Context:** PR #26254: Added extra tests for reshape
**Review Line:** 1743
**Code Changes:**
```diff
- if( new_rows > 0 )
- {
- int sz[] = { new_rows, (int)(total()*cn/new_rows) };
- return reshape(new_cn, 2, sz);
- }
+ CV_Assert( new_rows > 0 );
+ int sz[] = { new_rows, (int)(total()*cn/new_rows) };
+ return reshape(new_cn, 2, sz);
}
- CV_Assert( dims <= 2 );
``` | Looks like the assert is redundant here. if (new_rows == 0) leads to return. |
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/matrix.cpp
**Change Type:** modified
**Context:** PR #26254: Added extra tests for reshape
**Review Line:** 1743
**Code Changes:**
```diff
- if( new_rows > 0 )
- {
- int sz[] = { new_rows, (int)(total()*cn/new_rows) };
- return reshape(new_cn, 2, sz);
- }
+ CV_Assert( new_rows > 0 );
+ int sz[] = { new_rows, (int)(total()*cn/new_rows) };
+ return reshape(new_cn, 2, sz);
}
- CV_Assert( dims <= 2 );
``` | what about `new_rows < 0` case? we should handle 'bad args' somehow |
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/umatrix.cpp
**Change Type:** modified
**Context:** PR #26254: Added extra tests for reshape
**Code Changes:**
```diff
@@ -1063,9 +1063,6 @@ UMat UMat::reshape(int new_cn, int new_rows) const
CV_Error( cv::Error::BadStep,
"The matrix is not continuous, thus its number of rows can not be changed" );
- if( (unsigned)new_rows > (unsigned)total_size )
- CV_Error( cv::Error::StsOutOfRange, "Bad new number of rows" );
-
total_width = total_size / new_rows;
if( total_width * new_rows != total_size )
``` | please, look more carefully. This is called _after_ release(), not after create(). I found that empty matrix is not copied correctly, type is replaced with 'CV_8U', which is wrong in general. This code fixes it. |
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 #26446: Empty Mat in FileStorage
**Code Changes:**
```diff
@@ -2018,7 +2018,25 @@ T fsWriteRead(const T& expectedValue, const char* ext)
return value;
}
+void testExactMat(const Mat& src, const char* ext)
+{
+ bool srcIsEmpty = src.empty();
+ Mat dst = fsWriteRead(src, ext);
+ EXPECT_EQ(dst.empty(), srcIsEmpty);
+ EXPECT_EQ(src.dims, dst.dims);
``` | We do not have 1d Mat support in 4.x. 2+d 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/base.hpp
**Change Type:** modified
**Context:** PR #26101: C-API cleanup: moved cvErrorStr to new interface, minor ts changes - Merge with opencv/opencv_contrib#3786 **Note:** `toString` might be to...
**Code Changes:**
```diff
@@ -60,72 +60,6 @@
namespace cv
{
-//! @addtogroup core_utils
-//! @{
-
-namespace Error {
-//! error codes
-enum Code {
``` | `int` -> `Code` at least to enable C++ ADL without explicit namespace. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/ts/src/ts.cpp
**Change Type:** modified
**Context:** PR #26101: C-API cleanup: moved cvErrorStr to new interface, minor ts changes - Merge with opencv/opencv_contrib#3786 **Note:** `toString` might be to...
**Review Line:** 545
**Code Changes:**
```diff
@@ -544,7 +542,7 @@ static int tsErrorCallback( int status, const char* func_name, const char* err_m
{
TS* ts = (TS*)data;
const char* delim = std::string(err_msg).find('\n') == std::string::npos ? "" : "\n";
- ts->printf(TS::LOG, "OpenCV Error:\n\t%s (%s%s) in %s, file %s, line %d\n", cvErrorStr(status), delim, err_msg, func_name[0] != 0 ? func_name : "unknown function", file_name, line);
+ ts->printf(TS::LOG, "OpenCV Error:\n\t%d (%s%s) in %s, file %s, line %d\n", status, delim, err_msg, func_name[0] != 0 ? func_name : "unknown function", file_name, line);
return 0;
}
@@ -638,7 +636,6 @@ void TS::update_context( BaseTest* test, int test_case_idx, bool update_ts_conte
current_test_info.test = test;
``` | Note: used numeric code here instead of string |
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/dnn_utils.cpp
**Change Type:** modified
**Context:** PR #26127: Faster implementation of blobFromImages for cpu nchw output
**Code Changes:**
```diff
@@ -126,6 +126,111 @@ Mat blobFromImagesWithParams(InputArrayOfArrays images, const Image2BlobParams&
return blob;
}
+template<typename Tinp, typename Tout>
+void blobFromImagesNCHWImpl(const std::vector<Mat>& images, Mat& blob_, const Image2BlobParams& param)
+{
+ int w = images[0].cols;
+ int h = images[0].rows;
+ int wh = w * h;
``` | ```CV_BadDepth``` -> ```Error::BadDepth``` |
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/dnn_utils.cpp
**Change Type:** modified
**Context:** PR #26127: Faster implementation of blobFromImages for cpu nchw output
**Code Changes:**
```diff
@@ -126,6 +126,111 @@ Mat blobFromImagesWithParams(InputArrayOfArrays images, const Image2BlobParams&
return blob;
}
+template<typename Tinp, typename Tout>
+void blobFromImagesNCHWImpl(const std::vector<Mat>& images, Mat& blob_, const Image2BlobParams& param)
+{
+ int w = images[0].cols;
+ int h = images[0].rows;
+ int wh = w * h;
``` | ```CV_StsNotImplemented ``` -> ```Error::StsNotImplemented``` |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/qrcode_encoder.cpp
**Change Type:** modified
**Context:** PR #26532: objdetect: fix invalid vector access in QR de/encoder
**Code Changes:**
```diff
@@ -711,17 +711,17 @@ void QRCodeEncoderImpl::padBitStream()
else if (pad_num <= 4)
{
int payload_size = (int)payload.size();
- writeDecNumber(0, payload_size, payload);
+ payload.insert(payload.end(), payload_size, 0);
}
else
{
- writeDecNumber(0, 4, payload);
``` | Error should be raise instead of providing of wrong result. Need to modify check on the line 1328 with current `CV_Assert(idx < data.size());` |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/qrcode_encoder.cpp
**Change Type:** modified
**Context:** PR #26532: objdetect: fix invalid vector access in QR de/encoder
**Code Changes:**
```diff
@@ -711,17 +711,17 @@ void QRCodeEncoderImpl::padBitStream()
else if (pad_num <= 4)
{
int payload_size = (int)payload.size();
- writeDecNumber(0, payload_size, payload);
+ payload.insert(payload.end(), payload_size, 0);
}
else
{
- writeDecNumber(0, 4, payload);
``` | I propose assert here instead of condition. |
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/qrcode_encoder.cpp
**Change Type:** modified
**Context:** PR #26532: objdetect: fix invalid vector access in QR de/encoder
**Code Changes:**
```diff
@@ -711,17 +711,17 @@ void QRCodeEncoderImpl::padBitStream()
else if (pad_num <= 4)
{
int payload_size = (int)payload.size();
- writeDecNumber(0, payload_size, payload);
+ payload.insert(payload.end(), payload_size, 0);
}
else
{
- writeDecNumber(0, 4, payload);
``` | Just here is nit enough. `while` loop above has the same issue with buffer access. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/objdetect/src/qrcode_encoder.cpp
**Change Type:** modified
**Context:** PR #26532: objdetect: fix invalid vector access in QR de/encoder
**Code Changes:**
```diff
@@ -711,17 +711,17 @@ void QRCodeEncoderImpl::padBitStream()
else if (pad_num <= 4)
{
int payload_size = (int)payload.size();
- writeDecNumber(0, payload_size, payload);
+ payload.insert(payload.end(), payload_size, 0);
}
else
{
- writeDecNumber(0, 4, payload);
``` | If we add assertion here, our tests will fail because there are cases where more bits are being read. We need to fix these cases first. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/videoio/src/cap_v4l.cpp
**Change Type:** modified
**Context:** PR #25500: V4l default image size
**Review Line:** 1010
**Code Changes:**
```diff
CV_LOG_DEBUG(NULL, "VIDEOIO(V4L2:" << _deviceName << "): opening...");
FirstCapture = true;
- width = DEFAULT_V4L_WIDTH;
- height = DEFAULT_V4L_HEIGHT;
+ width = utils::getConfigurationParameterSizeT("OPENCV_VIDEOIO_V4L_DEFAULT_WIDTH", DEFAULT_V4L_WIDTH);
+ height = utils::getConfigurationParameterSizeT("OPENCV_VIDEOIO_V4L_DEFAULT_HEIGHT", DEFAULT_V4L_HEIGHT);
width_set = height_set = 0;
bufferSize = DEFAULT_V4L_BUFFERS;
fps = DEFAULT_V4L_FPS;
``` | What is about `const VideoCaptureParameters& params` approach? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/videoio/src/cap_v4l.cpp
**Change Type:** modified
**Context:** PR #25500: V4l default image size
**Review Line:** 1010
**Code Changes:**
```diff
CV_LOG_DEBUG(NULL, "VIDEOIO(V4L2:" << _deviceName << "): opening...");
FirstCapture = true;
- width = DEFAULT_V4L_WIDTH;
- height = DEFAULT_V4L_HEIGHT;
+ width = utils::getConfigurationParameterSizeT("OPENCV_VIDEOIO_V4L_DEFAULT_WIDTH", DEFAULT_V4L_WIDTH);
+ height = utils::getConfigurationParameterSizeT("OPENCV_VIDEOIO_V4L_DEFAULT_HEIGHT", DEFAULT_V4L_HEIGHT);
width_set = height_set = 0;
bufferSize = DEFAULT_V4L_BUFFERS;
fps = DEFAULT_V4L_FPS;
``` | Unfortunately it won't work. The VideoCaptureParameters parameter is applied only after the fn_createCaptureCamera_ call. Here is the sequence: - The `createCapture` is called with the `VideoCaptureParameters` - The `createCapture` calls the configured `fn_createCaptureCamera_` function of the capture backend (which is `create_V4L_capture_cam in this case`) and after the call is succeeded sets the VideoCaptureParameters. The problem is this is the `create_V4L_capture_cam` which is failed (inside the `CvCaptureCAM_V4L::initCapture` function) so we have no chance to apply the VideoCaptureParameters. At least without major refactoring of entire factory code. Note that the utils::getConfigurationParameter... approach is already used here for the `normalizePropRange` property so the change will not introduce new approaches. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/js/generator/embindgen.py
**Change Type:** modified
**Context:** PR #26147: js: fix enum generation issues
**Review Line:** 942
**Code Changes:**
```diff
if ns_name.split('.')[0] != 'cv':
continue
+ # TODO CALIB_FIX_FOCAL_LENGTH is defined both in cv:: and cv::fisheye
+ prefix = 'FISHEYE_' if 'fisheye' in ns_name else ''
for name, const in sorted(ns.consts.items()):
+ name = prefix + name
# print("Gen consts: ", name, const)
self.bindings.append(const_template.substitute(js_name=name, value=const))
``` | What if use `namespace_prefix_override` solution like for the functions? Namespace is already appended to the function names, if it's not overridden by config. It's less hacky and more obvious. |
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/js/generator/embindgen.py
**Change Type:** modified
**Context:** PR #26147: js: fix enum generation issues
**Review Line:** 942
**Code Changes:**
```diff
if ns_name.split('.')[0] != 'cv':
continue
+ # TODO CALIB_FIX_FOCAL_LENGTH is defined both in cv:: and cv::fisheye
+ prefix = 'FISHEYE_' if 'fisheye' in ns_name else ''
for name, const in sorted(ns.consts.items()):
+ name = prefix + name
# print("Gen consts: ", name, const)
self.bindings.append(const_template.substitute(js_name=name, value=const))
``` | I guess that would work but I don't know how to use it. Should all the enums be added to https://github.com/opencv/opencv/blob/450e741f8d53ff12b4e194c7762adaefb952555a/modules/js/generator/embindgen.py#L989 ? |
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/highgui/src/window_cocoa.mm
**Change Type:** modified
**Context:** PR #26625: Cocoa/highgui: fix leak in cvGetWindowRect_COCOA
**Code Changes:**
```diff
@@ -662,14 +662,16 @@ CvRect cvGetWindowRect_COCOA( const char* name )
{
CV_ERROR( CV_StsNullPtr, "NULL window" );
} else {
- NSRect rect = [window frame];
+ @autoreleasepool {
+ NSRect rect = [window frame];
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6
- NSPoint pt = [window convertRectToScreen:rect].origin;
+ NSPoint pt = [window convertRectToScreen:rect].origin;
``` | The reason I use autorelease pools directly is to maintain consistent coding style. In this file, all 12 instances of autorelease pool is called directly: https://github.com/opencv/opencv/blob/645fd3dffaa50e0b5dd011720048441986640d7e/modules/highgui/src/window_cocoa.mm#L194 https://github.com/opencv/opencv/blob/645fd3dffaa50e0b5dd011720048441986640d7e/modules/highgui/src/window_cocoa.mm#L211 https://github.com/opencv/opencv/blob/645fd3dffaa50e0b5dd011720048441986640d7e/modules/highgui/src/window_cocoa.mm#L223 ... IMO it would be more appropriate to create a new PR to clean up this file. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26621: FastCV-based HAL for OpenCV acceleration 2ndpost-3
**Code Changes:**
```diff
@@ -992,4 +992,59 @@ int fastcv_hal_cvtBGRtoYUVApprox(
fcvStatus status = FASTCV_SUCCESS;
CV_HAL_RETURN(status, hal_BGRtoYUVApprox);
+}
+
+int fastcv_hal_canny(
+ const uchar* src_data,
+ size_t src_step,
+ uchar* dst_data,
``` | 1. Looks like lowThresh and highThresh are redundant. 2. What if, lowThresh=12.999999999? I propose to use check with epsilon. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/videoio/src/cap_android_camera.cpp
**Change Type:** modified
**Context:** PR #26627: Android camera feature enhancements
**Review Line:** 538
**Code Changes:**
```diff
- return status == ACAMERA_OK;
+ return submitRequest(ACaptureRequest_setEntry_i32, ACAMERA_SENSOR_SENSITIVITY, sensitivity);
}
return false;
+ case CAP_PROP_ANDROID_DEVICE_TORCH:
+ flashMode = (value != 0) ? ACAMERA_FLASH_MODE_TORCH : ACAMERA_FLASH_MODE_OFF;
+ if (isOpened()) {
+ return submitRequest(ACaptureRequest_setEntry_u8, ACAMERA_FLASH_MODE, flashMode);
+ }
+ return true;
default:
``` | There are complains about Samsung devices support here: https://stackoverflow.com/questions/23336907/what-is-the-difference-between-flash-mode-torch-and-flash-mode-on. Could you take a look? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/videoio/src/cap_android_camera.cpp
**Change Type:** modified
**Context:** PR #26627: Android camera feature enhancements
**Review Line:** 777
**Code Changes:**
```diff
+ {
+ ACaptureRequest *request = captureRequest.get();
+
+ return request &&
+ setFn(request, tag, 1, &data) == ACAMERA_OK &&
+ ACameraCaptureSession_setRepeatingRequest(captureSession.get(),
+ GetCaptureCallback(),
+ 1, &request, nullptr) == ACAMERA_OK;
+ }
};
``` | Why do we need it for every ACaptureRequest_setEntryXXX call? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/videoio/src/cap_android_camera.cpp
**Change Type:** modified
**Context:** PR #26627: Android camera feature enhancements
**Review Line:** 603
**Code Changes:**
```diff
@@ -561,7 +600,7 @@ class AndroidCameraCapture : public IVideoCapture
return false;
}
std::shared_ptr<ACameraMetadata> cameraMetadata = std::shared_ptr<ACameraMetadata>(metadata, deleter_ACameraMetadata);
- ACameraMetadata_const_entry entry;
+ ACameraMetadata_const_entry entry = {};
ACameraMetadata_getConstEntry(cameraMetadata.get(), ACAMERA_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, &entry);
double bestScore = std::numeric_limits<double>::max();
@@ -594,25 +633,19 @@ class AndroidCameraCapture : public IVideoCapture
}
``` | The change does nothing. Default constructor was called in old version 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/videoio/src/cap_android_camera.cpp
**Change Type:** modified
**Context:** PR #26627: Android camera feature enhancements
**Review Line:** 538
**Code Changes:**
```diff
- return status == ACAMERA_OK;
+ return submitRequest(ACaptureRequest_setEntry_i32, ACAMERA_SENSOR_SENSITIVITY, sensitivity);
}
return false;
+ case CAP_PROP_ANDROID_DEVICE_TORCH:
+ flashMode = (value != 0) ? ACAMERA_FLASH_MODE_TORCH : ACAMERA_FLASH_MODE_OFF;
+ if (isOpened()) {
+ return submitRequest(ACaptureRequest_setEntry_u8, ACAMERA_FLASH_MODE, flashMode);
+ }
+ return true;
default:
``` | Hmm, I don't know. My primary test device is a SONY. I will try, if FLASH_MODE_ON will work as well. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/videoio/src/cap_android_camera.cpp
**Change Type:** modified
**Context:** PR #26627: Android camera feature enhancements
**Review Line:** 777
**Code Changes:**
```diff
+ {
+ ACaptureRequest *request = captureRequest.get();
+
+ return request &&
+ setFn(request, tag, 1, &data) == ACAMERA_OK &&
+ ACameraCaptureSession_setRepeatingRequest(captureSession.get(),
+ GetCaptureCallback(),
+ 1, &request, nullptr) == ACAMERA_OK;
+ }
};
``` | Yes. It is not sufficient to update the metadata only. Re-submitting the capture request will make the change effective after the current request has finished. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/videoio/src/cap_android_camera.cpp
**Change Type:** modified
**Context:** PR #26627: Android camera feature enhancements
**Review Line:** 603
**Code Changes:**
```diff
@@ -561,7 +600,7 @@ class AndroidCameraCapture : public IVideoCapture
return false;
}
std::shared_ptr<ACameraMetadata> cameraMetadata = std::shared_ptr<ACameraMetadata>(metadata, deleter_ACameraMetadata);
- ACameraMetadata_const_entry entry;
+ ACameraMetadata_const_entry entry = {};
ACameraMetadata_getConstEntry(cameraMetadata.get(), ACAMERA_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, &entry);
double bestScore = std::numeric_limits<double>::max();
@@ -594,25 +633,19 @@ class AndroidCameraCapture : public IVideoCapture
}
``` | ACameraMetadata_const_entry is a POD and doesn't have a user-declared constructor. So it's uninitialized unless we specify the braces. In this particular case the result of the following call to ACameraMetadata_getConstEntry() is not explicitly checked. Instead we rely on the fact, that the member 'count' is zero in case of an error. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/videoio/src/cap_android_camera.cpp
**Change Type:** modified
**Context:** PR #26627: Android camera feature enhancements
**Review Line:** 538
**Code Changes:**
```diff
- return status == ACAMERA_OK;
+ return submitRequest(ACaptureRequest_setEntry_i32, ACAMERA_SENSOR_SENSITIVITY, sensitivity);
}
return false;
+ case CAP_PROP_ANDROID_DEVICE_TORCH:
+ flashMode = (value != 0) ? ACAMERA_FLASH_MODE_TORCH : ACAMERA_FLASH_MODE_OFF;
+ if (isOpened()) {
+ return submitRequest(ACaptureRequest_setEntry_u8, ACAMERA_FLASH_MODE, flashMode);
+ }
+ return true;
default:
``` | Just tested torch with Xiaomi Mi 10 and Samsung Galaxy S10. Both works well. Let's ignore it for now. |
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/videoio/src/cap_android_camera.cpp
**Change Type:** modified
**Context:** PR #26627: Android camera feature enhancements
**Review Line:** 538
**Code Changes:**
```diff
- return status == ACAMERA_OK;
+ return submitRequest(ACaptureRequest_setEntry_i32, ACAMERA_SENSOR_SENSITIVITY, sensitivity);
}
return false;
+ case CAP_PROP_ANDROID_DEVICE_TORCH:
+ flashMode = (value != 0) ? ACAMERA_FLASH_MODE_TORCH : ACAMERA_FLASH_MODE_OFF;
+ if (isOpened()) {
+ return submitRequest(ACaptureRequest_setEntry_u8, ACAMERA_FLASH_MODE, flashMode);
+ }
+ return true;
default:
``` | According to https://developer.android.com/reference/android/hardware/Camera.Parameters FLASH_MODE_ON is part of the old API. Camera2 has FLASH_MODE_OFF, FLASH_MODE_SINGLE and FLASH_MODE_TORCH only. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/photo/src/seamless_cloning_impl.cpp
**Change Type:** modified
**Context:** PR #26511: Add *_WIDE flags to cv::seamlessClone
**Review Line:** 332
**Code Changes:**
```diff
@@ -332,11 +332,13 @@ void Cloning::normalClone(const Mat &destination, const Mat &patch, Mat &binaryM
switch(flag)
{
case NORMAL_CLONE:
+ case NORMAL_CLONE_WIDE:
arrayProduct(patchGradientX, binaryMaskFloat, patchGradientX);
arrayProduct(patchGradientY, binaryMaskFloat, patchGradientY);
``` | The condition is a bit hacky and depends on enum values. I propose to extend "case:" sentences and/or add explicit conditions to make _ALT branch obvious from the code for reader. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/photo/src/seamless_cloning.cpp
**Change Type:** modified
**Context:** PR #26511: Add *_WIDE flags to cv::seamlessClone
**Code Changes:**
```diff
@@ -47,18 +47,17 @@
using namespace std;
using namespace cv;
-static Mat checkMask(InputArray _mask, Size size)
+static Mat checkMask(InputArray mask, Size size)
{
- Mat mask = _mask.getMat();
Mat gray;
- if (mask.channels() > 1)
``` | The `p` parameter does not have default value like `Point p = Point()`. It means that the point is user provided value. I do not think that we sound handle `Point()`, a.k.a. (0,0) as special case. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/photo/src/seamless_cloning.cpp
**Change Type:** modified
**Context:** PR #26511: Add *_WIDE flags to cv::seamlessClone
**Code Changes:**
```diff
@@ -47,18 +47,17 @@
using namespace std;
using namespace cv;
-static Mat checkMask(InputArray _mask, Size size)
+static Mat checkMask(InputArray mask, Size size)
{
- Mat mask = _mask.getMat();
Mat gray;
- if (mask.channels() > 1)
``` | Let's enumerate flag values here to make obvious for core readers. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/photo/src/seamless_cloning.cpp
**Change Type:** modified
**Context:** PR #26511: Add *_WIDE flags to cv::seamlessClone
**Code Changes:**
```diff
@@ -47,18 +47,17 @@
using namespace std;
using namespace cv;
-static Mat checkMask(InputArray _mask, Size size)
+static Mat checkMask(InputArray mask, Size size)
{
- Mat mask = _mask.getMat();
Mat gray;
- if (mask.channels() > 1)
``` | what about using Point(-1,-1) to centralize as special case ? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/photo/src/seamless_cloning.cpp
**Change Type:** modified
**Context:** PR #26511: Add *_WIDE flags to cv::seamlessClone
**Code Changes:**
```diff
@@ -47,18 +47,17 @@
using namespace std;
using namespace cv;
-static Mat checkMask(InputArray _mask, Size size)
+static Mat checkMask(InputArray mask, Size size)
{
- Mat mask = _mask.getMat();
Mat gray;
- if (mask.channels() > 1)
``` | Why do we need special cases in code? User should provide location, shouldn't he/she? |
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/src/seamless_cloning.cpp
**Change Type:** modified
**Context:** PR #26511: Add *_WIDE flags to cv::seamlessClone
**Code Changes:**
```diff
@@ -47,18 +47,17 @@
using namespace std;
using namespace cv;
-static Mat checkMask(InputArray _mask, Size size)
+static Mat checkMask(InputArray mask, Size size)
{
- Mat mask = _mask.getMat();
Mat gray;
- if (mask.channels() > 1)
``` | "In issue #15928, the user reports: >>I had: ``` src.shape = 500,500 src_mask = 500,500 dest.shape = 500,500 h, w = src_mask.shape[:2] ``` >>At this point, I didn't see the need for the required argument `p`, as I expected the function to automatically match the mask. However, since `p` is a required argument, I provided `(w//2, h//2)` for `p` (the center of the mask). But instead of aligning the source image (`src`) into the destination (`dest`), the resulting cloning was shifted up to the center of the screen! It seems like there may have been an issue with how the center point was calculated or used. The user expected the function to align the source (src) based on the mask (src_mask) automatically, but instead, the function seemed to shift the cloning to an unexpected location. Perhaps the logic for finding the center point could be improved or made more intuitive to help avoid confusion in such cases. A clearer method of determining the center, or perhaps some additional documentation on how to properly use the p argument, might help facilitate this process." |
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/src/seamless_cloning.cpp
**Change Type:** modified
**Context:** PR #26511: Add *_WIDE flags to cv::seamlessClone
**Code Changes:**
```diff
@@ -47,18 +47,17 @@
using namespace std;
using namespace cv;
-static Mat checkMask(InputArray _mask, Size size)
+static Mat checkMask(InputArray mask, Size size)
{
- Mat mask = _mask.getMat();
Mat gray;
- if (mask.channels() > 1)
``` | also in the issue the user commented >>I got the expected behaviour by using a rect of thickness 2 ``` h, w = src_mask.shape[:2] # rect of thickness > 1 cv2.rectangle(src_mask,(0,0), (w, h) ,255, 2) # the clone will now aligns from the centre out=cv2.seamlessClone(src, dest, src_mask,(w//2, h//2),flags= cv2.NORMAL_CLONE) ``` a rect of 1 thickness did not work. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/photo/src/seamless_cloning.cpp
**Change Type:** modified
**Context:** PR #26511: Add *_WIDE flags to cv::seamlessClone
**Code Changes:**
```diff
@@ -47,18 +47,17 @@
using namespace std;
using namespace cv;
-static Mat checkMask(InputArray _mask, Size size)
+static Mat checkMask(InputArray mask, Size size)
{
- Mat mask = _mask.getMat();
Mat gray;
- if (mask.channels() > 1)
``` | i will revert this idea if you want. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/photo/src/seamless_cloning.cpp
**Change Type:** modified
**Context:** PR #26511: Add *_WIDE flags to cv::seamlessClone
**Code Changes:**
```diff
@@ -47,18 +47,17 @@
using namespace std;
using namespace cv;
-static Mat checkMask(InputArray _mask, Size size)
+static Mat checkMask(InputArray mask, Size size)
{
- Mat mask = _mask.getMat();
Mat gray;
- if (mask.channels() > 1)
``` | there is related issues on some repos like https://github.com/OpenTalker/SadTalker/issues/542 let me investigate if ``` { p.x = dest.size().width / 2; p.y = dest.size().height / 2; } ``` works perfectly fine for different dimensions |
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/photo/include/opencv2/photo.hpp
**Change Type:** modified
**Context:** PR #26511: Add *_WIDE flags to cv::seamlessClone
**Code Changes:**
```diff
@@ -708,33 +708,74 @@ CV_EXPORTS_W void decolor( InputArray src, OutputArray grayscale, OutputArray co
//! @{
-//! seamlessClone algorithm flags
-enum
+//! Flags for the seamlessClone algorithm
+enum SeamlessCloneFlags
{
- /** The power of the method is fully expressed when inserting objects with complex outlines into a new background*/
``` | I propose to name it not _ALT, but _WIDE to have some meaning in the option name here and in all other places. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/imgcodecs/test/test_png.cpp
**Change Type:** modified
**Context:** PR #26181: Enable PNG exif orientation test
**Code Changes:**
```diff
@@ -109,100 +109,6 @@ TEST(Imgcodecs_Png, read_color_palette_with_alpha)
EXPECT_EQ(img.at<Vec3b>(0, 1), Vec3b(255, 0, 0));
}
-/**
- * Test for check whether reading exif orientation tag was processed successfully or not
- * The test info is the set of 8 images named testExifRotate_{1 to 8}.png
- * The test image is the square 10x10 points divided by four sub-squares:
- * (R corresponds to Red, G to Green, B to Blue, W to white)
- * --------- ---------
``` | The test itself is still disabled. |
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/loadsave.cpp
**Change Type:** modified
**Context:** PR #26181: Enable PNG exif orientation test
**Code Changes:**
```diff
@@ -83,6 +83,9 @@ static Size validateInputImageSize(const Size& size)
static inline int calcType(int type, int flags)
{
+ if ( (flags & (IMREAD_COLOR | IMREAD_ANYCOLOR | IMREAD_ANYDEPTH)) == (IMREAD_COLOR | IMREAD_ANYCOLOR | IMREAD_ANYDEPTH))
+ return type;
+
if( (flags & IMREAD_LOAD_GDAL) != IMREAD_LOAD_GDAL && flags != IMREAD_UNCHANGED )
{
if( (flags & IMREAD_ANYDEPTH) == 0 )
``` | There is [cv::IMREAD_ANYCOLOR](https://docs.opencv.org/4.x/d8/d6a/group__imgcodecs__flags.html#gga61d9b0126a3e57d9277ac48327799c80ab6573b69300c092b61800222fe555953) option. It should presume alpha channel, if it's present in the original image. |
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/loadsave.cpp
**Change Type:** modified
**Context:** PR #26181: Enable PNG exif orientation test
**Code Changes:**
```diff
@@ -83,6 +83,9 @@ static Size validateInputImageSize(const Size& size)
static inline int calcType(int type, int flags)
{
+ if ( (flags & (IMREAD_COLOR | IMREAD_ANYCOLOR | IMREAD_ANYDEPTH)) == (IMREAD_COLOR | IMREAD_ANYCOLOR | IMREAD_ANYDEPTH))
+ return type;
+
if( (flags & IMREAD_LOAD_GDAL) != IMREAD_LOAD_GDAL && flags != IMREAD_UNCHANGED )
{
if( (flags & IMREAD_ANYDEPTH) == 0 )
``` | see the issues #22090 #21695 related cv::IMREAD_ANYCOLOR |
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 #26181: Enable PNG exif orientation test
**Code Changes:**
```diff
@@ -109,100 +109,6 @@ TEST(Imgcodecs_Png, read_color_palette_with_alpha)
EXPECT_EQ(img.at<Vec3b>(0, 1), Vec3b(255, 0, 0));
}
-/**
- * Test for check whether reading exif orientation tag was processed successfully or not
- * The test info is the set of 8 images named testExifRotate_{1 to 8}.png
- * The test image is the square 10x10 points divided by four sub-squares:
- * (R corresponds to Red, G to Green, B to Blue, W to white)
- * --------- ---------
``` | when ``` m_img = imread(filename, IMREAD_ANYCOLOR); ASSERT_FALSE(m_img.empty()); EXPECT_EQ(4, m_img.channels()); ``` **the test fails ** [----------] 8 tests from ExifFiles/Imgcodecs_PNG_Exif [ RUN ] ExifFiles/Imgcodecs_PNG_Exif.exif_orientation/0, where GetParam() = "readwrite/testExifOrientation_1.png" C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(191): error: Expected equality of these values: 4 m_img.channels() Which is: 3 C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(196): error: Expected: (vec4.val[0]) <= (colorThresholdLow), actual: '\xFE' (254) vs 5 C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(198): error: Expected: (vec4.val[2]) >= (colorThresholdHigh), actual: '\0' vs 250 C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(202): error: Expected: (vec4.val[0]) <= (colorThresholdLow), actual: '\xFF' (255) vs 5 C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(203): error: Expected: (vec4.val[1]) >= (colorThresholdHigh), actual: '\0' vs 250 C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(208): error: Expected: (vec4.val[0]) >= (colorThresholdHigh), actual: '\x2' (2) vs 250 C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(209): error: Expected: (vec4.val[1]) <= (colorThresholdLow), actual: '\xFD' (253) vs 5 [ FAILED ] ExifFiles/Imgcodecs_PNG_Exif.exif_orientation/0, where GetParam() = "readwrite/testExifOrientation_1.png" (2 ms) [ RUN ] ExifFiles/Imgcodecs_PNG_Exif.exif_orientation/1, where GetParam() = "readwrite/testExifOrientation_2.png" C:\build\precommit_windows64\4.x\opencv\modules\imgcodecs\test\test_png.cpp(191): error: Expected equality of these values: 4 m_img.channels() Which is: 3 ``` |
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/test/test_exif.cpp
**Change Type:** added
**Context:** PR #26181: Enable PNG exif orientation test
**Review Line:** 52
**Code Changes:**
```diff
+ *
+ * Note:
+ * The flags parameter of the imread function is set as IMREAD_COLOR | IMREAD_ANYCOLOR | IMREAD_ANYDEPTH.
+ * Using this combination is an undocumented trick to load images similarly to the IMREAD_UNCHANGED flag,
+ * preserving the alpha channel (if present) while also applying the orientation.
+ */
+
+typedef testing::TestWithParam<string> Exif;
+
+TEST_P(Exif, exif_orientation)
+{
``` | I propose to add it to documentation. |
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/kleidicv/CMakeLists.txt
**Change Type:** modified
**Context:** PR #26623: Update KleidiCV to version 0.3
**Review Line:** 9
**Code Changes:**
```diff
option(KLEIDICV_ENABLE_SME2 "" OFF) # not compatible with some CLang versions in NDK
include("${KLEIDICV_SOURCE_PATH}/adapters/opencv/CMakeLists.txt")
+ # HACK to suppress adapters/opencv/kleidicv_hal.cpp:343:12: warning: unused function 'from_opencv' [-Wunused-function]
+ target_compile_options( kleidicv_hal PRIVATE
+ $<TARGET_PROPERTY:kleidicv,COMPILE_OPTIONS>
+ "-Wno-old-style-cast" "-Wno-unused-function"
+ )
endif()
-
``` | Need to include through `-isystem` to avoid warnings from these external headers. https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html Example: https://github.com/opencv/opencv/blob/4.10.0/3rdparty/protobuf/CMakeLists.txt#L154 |
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/kleidicv/CMakeLists.txt
**Change Type:** modified
**Context:** PR #26623: Update KleidiCV to version 0.3
**Review Line:** 9
**Code Changes:**
```diff
option(KLEIDICV_ENABLE_SME2 "" OFF) # not compatible with some CLang versions in NDK
include("${KLEIDICV_SOURCE_PATH}/adapters/opencv/CMakeLists.txt")
+ # HACK to suppress adapters/opencv/kleidicv_hal.cpp:343:12: warning: unused function 'from_opencv' [-Wunused-function]
+ target_compile_options( kleidicv_hal PRIVATE
+ $<TARGET_PROPERTY:kleidicv,COMPILE_OPTIONS>
+ "-Wno-old-style-cast" "-Wno-unused-function"
+ )
endif()
-
``` | The issue happens inside cpp file, not header. So the `-isystem` flag is not applicable here. |
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/kleidicv/CMakeLists.txt
**Change Type:** modified
**Context:** PR #26623: Update KleidiCV to version 0.3
**Review Line:** 9
**Code Changes:**
```diff
option(KLEIDICV_ENABLE_SME2 "" OFF) # not compatible with some CLang versions in NDK
include("${KLEIDICV_SOURCE_PATH}/adapters/opencv/CMakeLists.txt")
+ # HACK to suppress adapters/opencv/kleidicv_hal.cpp:343:12: warning: unused function 'from_opencv' [-Wunused-function]
+ target_compile_options( kleidicv_hal PRIVATE
+ $<TARGET_PROPERTY:kleidicv,COMPILE_OPTIONS>
+ "-Wno-old-style-cast" "-Wno-unused-function"
+ )
endif()
-
``` | Why does this widely used approach not work? https://github.com/opencv/opencv/blob/4.10.0/3rdparty/libjpeg-turbo/CMakeLists.txt#L11 |
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/kleidicv/CMakeLists.txt
**Change Type:** modified
**Context:** PR #26623: Update KleidiCV to version 0.3
**Review Line:** 9
**Code Changes:**
```diff
option(KLEIDICV_ENABLE_SME2 "" OFF) # not compatible with some CLang versions in NDK
include("${KLEIDICV_SOURCE_PATH}/adapters/opencv/CMakeLists.txt")
+ # HACK to suppress adapters/opencv/kleidicv_hal.cpp:343:12: warning: unused function 'from_opencv' [-Wunused-function]
+ target_compile_options( kleidicv_hal PRIVATE
+ $<TARGET_PROPERTY:kleidicv,COMPILE_OPTIONS>
+ "-Wno-old-style-cast" "-Wno-unused-function"
+ )
endif()
-
``` | I tried it. Most probably the issue is that the ocv_disable_warning works well inside the cmake "project" scope, but does not outside. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Code Changes:**
```diff
@@ -743,4 +743,253 @@ int fastcv_hal_warpPerspective(
CV_HAL_RETURN_NOT_IMPLEMENTED(cv::format("Src type:%s is not supported", cv::typeToString(src_type).c_str()));
CV_HAL_RETURN(status, hal_warpPerspective);
+}
+
+class FcvPyrLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
``` | I propose to add at least CV_Assert here. Just for the case, if invoker code will be changed incorrectly in future. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Code Changes:**
```diff
@@ -743,4 +743,253 @@ int fastcv_hal_warpPerspective(
CV_HAL_RETURN_NOT_IMPLEMENTED(cv::format("Src type:%s is not supported", cv::typeToString(src_type).c_str()));
CV_HAL_RETURN(status, hal_warpPerspective);
+}
+
+class FcvPyrLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
``` | I propose to add at least CV_Assert here. Just for the case, if invoker code will be changed incorrectly in future. |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Code Changes:**
```diff
@@ -743,4 +743,253 @@ int fastcv_hal_warpPerspective(
CV_HAL_RETURN_NOT_IMPLEMENTED(cv::format("Src type:%s is not supported", cv::typeToString(src_type).c_str()));
CV_HAL_RETURN(status, hal_warpPerspective);
+}
+
+class FcvPyrLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
``` | which param do you think we should add assert? or I can return CV_HAL_ERROR_NOT_IMPLEMENTED |
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Code Changes:**
```diff
@@ -743,4 +743,253 @@ int fastcv_hal_warpPerspective(
CV_HAL_RETURN_NOT_IMPLEMENTED(cv::format("Src type:%s is not supported", cv::typeToString(src_type).c_str()));
CV_HAL_RETURN(status, hal_warpPerspective);
+}
+
+class FcvPyrLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
``` | which param do you think we should add assert? or I can raise some error messages as it already in parallel we can't return CV_HAL_ERROR_NOT_IMPLEMENTED |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Code Changes:**
```diff
@@ -743,4 +743,253 @@ int fastcv_hal_warpPerspective(
CV_HAL_RETURN_NOT_IMPLEMENTED(cv::format("Src type:%s is not supported", cv::typeToString(src_type).c_str()));
CV_HAL_RETURN(status, hal_warpPerspective);
+}
+
+class FcvPyrLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
``` | You can use just `CV_Error()` statement then. The branch should not be reachable in normal configuration. |
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/fastcv/include/fastcv_hal_imgproc.hpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Review Line:** 117
**Code Changes:**
```diff
@@ -20,7 +20,12 @@
#define cv_hal_gaussianBlurBinomial fastcv_hal_gaussianBlurBinomial
#undef cv_hal_warpPerspective
#define cv_hal_warpPerspective fastcv_hal_warpPerspective
-
+#undef cv_hal_pyrdown
+#define cv_hal_pyrdown fastcv_hal_pyrdown
+#undef cv_hal_cvtBGRtoHSV
+#define cv_hal_cvtBGRtoHSV fastcv_hal_cvtBGRtoHSV
+#undef cv_hal_cvtBGRtoYUVApprox
+#define cv_hal_cvtBGRtoYUVApprox fastcv_hal_cvtBGRtoYUVApprox
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Calculate medianBlur filter
/// @param src_data Source image data
@@ -88,33 +93,6 @@ int fastcv_hal_sobel(
``` | Why is it removed? M.b. rebase issue? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Code Changes:**
```diff
@@ -743,4 +743,253 @@ int fastcv_hal_warpPerspective(
CV_HAL_RETURN_NOT_IMPLEMENTED(cv::format("Src type:%s is not supported", cv::typeToString(src_type).c_str()));
CV_HAL_RETURN(status, hal_warpPerspective);
+}
+
+class FcvPyrLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
``` | I propose to use local variable on stack. new is redundant here. Also it's not deleted afterwards. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Code Changes:**
```diff
@@ -743,4 +743,253 @@ int fastcv_hal_warpPerspective(
CV_HAL_RETURN_NOT_IMPLEMENTED(cv::format("Src type:%s is not supported", cv::typeToString(src_type).c_str()));
CV_HAL_RETURN(status, hal_warpPerspective);
+}
+
+class FcvPyrLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
``` | I propose to use local variable on stack. new is redundant here. Also it's not deleted afterwards. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Review Line:** 907
**Code Changes:**
```diff
+ int scn,
+ bool swapBlue,
+ bool isFullRange,
+ bool isHSV)
+{
+ if(width * height > 640 * 480)
+ {
+ CV_HAL_RETURN_NOT_IMPLEMENTED("input size not supported");
+ }
+ if(scn != 3 || depth != CV_8U)
+ {
``` | Are you sure in sign? Does it work for small sizes only? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Code Changes:**
```diff
@@ -743,4 +743,253 @@ int fastcv_hal_warpPerspective(
CV_HAL_RETURN_NOT_IMPLEMENTED(cv::format("Src type:%s is not supported", cv::typeToString(src_type).c_str()));
CV_HAL_RETURN(status, hal_warpPerspective);
+}
+
+class FcvPyrLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
``` | `!isHSV || !isFullRange`? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Code Changes:**
```diff
@@ -743,4 +743,253 @@ int fastcv_hal_warpPerspective(
CV_HAL_RETURN_NOT_IMPLEMENTED(cv::format("Src type:%s is not supported", cv::typeToString(src_type).c_str()));
CV_HAL_RETURN(status, hal_warpPerspective);
+}
+
+class FcvPyrLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
``` | `!swapBlue` |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Code Changes:**
```diff
@@ -743,4 +743,253 @@ int fastcv_hal_warpPerspective(
CV_HAL_RETURN_NOT_IMPLEMENTED(cv::format("Src type:%s is not supported", cv::typeToString(src_type).c_str()));
CV_HAL_RETURN(status, hal_warpPerspective);
+}
+
+class FcvPyrLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
``` | The same for bools. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Code Changes:**
```diff
@@ -743,4 +743,253 @@ int fastcv_hal_warpPerspective(
CV_HAL_RETURN_NOT_IMPLEMENTED(cv::format("Src type:%s is not supported", cv::typeToString(src_type).c_str()));
CV_HAL_RETURN(status, hal_warpPerspective);
+}
+
+class FcvPyrLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
``` | > The same for bools. Added the suggested fixes |
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/fastcv/include/fastcv_hal_imgproc.hpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Review Line:** 117
**Code Changes:**
```diff
@@ -20,7 +20,12 @@
#define cv_hal_gaussianBlurBinomial fastcv_hal_gaussianBlurBinomial
#undef cv_hal_warpPerspective
#define cv_hal_warpPerspective fastcv_hal_warpPerspective
-
+#undef cv_hal_pyrdown
+#define cv_hal_pyrdown fastcv_hal_pyrdown
+#undef cv_hal_cvtBGRtoHSV
+#define cv_hal_cvtBGRtoHSV fastcv_hal_cvtBGRtoHSV
+#undef cv_hal_cvtBGRtoYUVApprox
+#define cv_hal_cvtBGRtoYUVApprox fastcv_hal_cvtBGRtoYUVApprox
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Calculate medianBlur filter
/// @param src_data Source image data
@@ -88,33 +93,6 @@ int fastcv_hal_sobel(
``` | > Why is it removed? M.b. rebase issue? It was added here by mistake, will be added in 3rd PR [opencv/opencv#26621](https://github.com/opencv/opencv/pull/26621) |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26619: FastCV-based HAL for OpenCV acceleration 2ndpost-2
**Review Line:** 907
**Code Changes:**
```diff
+ int scn,
+ bool swapBlue,
+ bool isFullRange,
+ bool isHSV)
+{
+ if(width * height > 640 * 480)
+ {
+ CV_HAL_RETURN_NOT_IMPLEMENTED("input size not supported");
+ }
+ if(scn != 3 || depth != CV_8U)
+ {
``` | > Are you sure in sign? Does it work for small sizes only? Currently yes, we will add more resolutions later on. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26617: FastCV-based HAL for OpenCV acceleration 2ndpost-1
**Code Changes:**
```diff
@@ -34,7 +34,7 @@ int fastcv_hal_medianBlur(
INITIALIZATION_CHECK;
- fcvStatus status;
+ fcvStatus status = FASTCV_SUCCESS;
int fcvFuncType = FCV_MAKETYPE(ksize,depth);
switch (fcvFuncType)
@@ -52,6 +52,101 @@ int fastcv_hal_medianBlur(
``` | Can you get rid of memcopy? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26617: FastCV-based HAL for OpenCV acceleration 2ndpost-1
**Code Changes:**
```diff
@@ -34,7 +34,7 @@ int fastcv_hal_medianBlur(
INITIALIZATION_CHECK;
- fcvStatus status;
+ fcvStatus status = FASTCV_SUCCESS;
int fcvFuncType = FCV_MAKETYPE(ksize,depth);
switch (fcvFuncType)
@@ -52,6 +52,101 @@ int fastcv_hal_medianBlur(
``` | The same question on copy. |
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26617: FastCV-based HAL for OpenCV acceleration 2ndpost-1
**Code Changes:**
```diff
@@ -34,7 +34,7 @@ int fastcv_hal_medianBlur(
INITIALIZATION_CHECK;
- fcvStatus status;
+ fcvStatus status = FASTCV_SUCCESS;
int fcvFuncType = FCV_MAKETYPE(ksize,depth);
switch (fcvFuncType)
@@ -52,6 +52,101 @@ int fastcv_hal_medianBlur(
``` | OK, I got why you need extra buffer and memcpy. Please add comment why you did it into the code. it's not obvious for readers. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26617: FastCV-based HAL for OpenCV acceleration 2ndpost-1
**Code Changes:**
```diff
@@ -34,7 +34,7 @@ int fastcv_hal_medianBlur(
INITIALIZATION_CHECK;
- fcvStatus status;
+ fcvStatus status = FASTCV_SUCCESS;
int fcvFuncType = FCV_MAKETYPE(ksize,depth);
switch (fcvFuncType)
@@ -52,6 +52,101 @@ int fastcv_hal_medianBlur(
``` | The same proposal. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** 3rdparty/fastcv/src/fastcv_hal_imgproc.cpp
**Change Type:** modified
**Context:** PR #26617: FastCV-based HAL for OpenCV acceleration 2ndpost-1
**Code Changes:**
```diff
@@ -34,7 +34,7 @@ int fastcv_hal_medianBlur(
INITIALIZATION_CHECK;
- fcvStatus status;
+ fcvStatus status = FASTCV_SUCCESS;
int fcvFuncType = FCV_MAKETYPE(ksize,depth);
switch (fcvFuncType)
@@ -52,6 +52,101 @@ int fastcv_hal_medianBlur(
``` | when the input is ROI, we need additional lines to on top and bottom to be border, for example ksize is 3, we need 1 more line at top and 1 more line at bottom, the input height for fastcv function will become range.end-range.start+2, we use a tmp var to store this result and use memcpy to copy it back to dst. But now I have removed memcpy and use cv::Mat and copyTo function, will update the code later. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/calib3d/src/calibration.cpp
**Change Type:** modified
**Context:** PR #26490: Switch calibration.cpp to C++
**Code Changes:**
```diff
@@ -58,8 +58,6 @@
namespace cv {
-static const char* cvDistCoeffErr = "Distortion coefficients must be 1x4, 4x1, 1x5, 5x1, 1x8, 8x1, 1x12, 12x1, 1x14 or 14x1 floating-point vector";
-
static void initIntrinsicParams2D( const Mat& objectPoints,
const Mat& imagePoints, const Mat& npoints,
Size imageSize, OutputArray cameraMatrix,
@@ -165,51 +163,39 @@ static void subMatrix(const Mat& src, Mat& dst,
``` | most probably is not needed. |
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/calibration.cpp
**Change Type:** modified
**Context:** PR #26490: Switch calibration.cpp to C++
**Code Changes:**
```diff
@@ -58,8 +58,6 @@
namespace cv {
-static const char* cvDistCoeffErr = "Distortion coefficients must be 1x4, 4x1, 1x5, 5x1, 1x8, 8x1, 1x12, 12x1, 1x14 or 14x1 floating-point vector";
-
static void initIntrinsicParams2D( const Mat& objectPoints,
const Mat& imagePoints, const Mat& npoints,
Size imageSize, OutputArray cameraMatrix,
@@ -165,51 +163,39 @@ static void subMatrix(const Mat& src, Mat& dst,
``` | Indeed: I just wanted to staty close to the 5.x version. I also removed the commented out `cout` code |
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/solvepnp.cpp
**Change Type:** modified
**Context:** PR #19253: Unexpected exception in solvePnPRansac caused by input points
**Code Changes:**
```diff
@@ -311,18 +311,42 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
opoints_inliers.resize(npoints1);
ipoints_inliers.resize(npoints1);
- result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
- distCoeffs, rvec, tvec, useExtrinsicGuess,
- (flags == SOLVEPNP_P3P || flags == SOLVEPNP_AP3P) ? SOLVEPNP_EPNP : flags) ? 1 : -1;
+ try
+ {
+ result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
``` | I believe it is a little bit more complex. When 3D points are not planar, `cvFindExtrinsicCameraParams2` uses DLT algorithm which indeed requires at least 6 points. But with coplanar 3D points, `cvFindExtrinsicCameraParams2` should work with at least 4 points. --- BTW, see here: https://github.com/opencv/opencv/issues/8782 my previous comment about the behavior of `solvePnPRansac` and this PR: https://github.com/opencv/opencv/pull/9086 In my opinion, behavior of `solvePnPRansac` is still not totally clear / intuitive. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/calib3d/src/solvepnp.cpp
**Change Type:** modified
**Context:** PR #19253: Unexpected exception in solvePnPRansac caused by input points
**Code Changes:**
```diff
@@ -311,18 +311,42 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
opoints_inliers.resize(npoints1);
ipoints_inliers.resize(npoints1);
- result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
- distCoeffs, rvec, tvec, useExtrinsicGuess,
- (flags == SOLVEPNP_P3P || flags == SOLVEPNP_AP3P) ? SOLVEPNP_EPNP : flags) ? 1 : -1;
+ try
+ {
+ result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
``` | Ok, then `cvFindExtrinsicCameraParams2` may get good result with 4 points, but may throw Exception with 5 points. I think CV_CheckGE in [`cvFindExtrinsicCameraParams2`](https://github.com/opencv/opencv/blob/863ecded30dcaedff0ece893277411f39bb3c1c6/modules/calib3d/src/calibration.cpp#L1099) is not a good idea. But since it returns void (not bool), throwing Exception may be the only option to inform that the result is bad. As a result, try-catch seems inevitable. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/calib3d/src/solvepnp.cpp
**Change Type:** modified
**Context:** PR #19253: Unexpected exception in solvePnPRansac caused by input points
**Code Changes:**
```diff
@@ -311,18 +311,42 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
opoints_inliers.resize(npoints1);
ipoints_inliers.resize(npoints1);
- result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
- distCoeffs, rvec, tvec, useExtrinsicGuess,
- (flags == SOLVEPNP_P3P || flags == SOLVEPNP_AP3P) ? SOLVEPNP_EPNP : flags) ? 1 : -1;
+ try
+ {
+ result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
``` | > Ok, then `cvFindExtrinsicCameraParams2` may get good result with 4 points, but may throw Exception with 5 points. Not sure to follow correctly. In `cvFindExtrinsicCameraParams2` it checks first if the 3D points are coplanar. For coplanar case, it should never throw exception, except theoretically for degenerate cases like all collinear points but this is not handled/detected. And there are already a check for at least 4 points if `useExtrinsicGuess` is false: https://github.com/opencv/opencv/blob/863ecded30dcaedff0ece893277411f39bb3c1c6/modules/calib3d/src/calibration.cpp#L1014 |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/calib3d/src/solvepnp.cpp
**Change Type:** modified
**Context:** PR #19253: Unexpected exception in solvePnPRansac caused by input points
**Code Changes:**
```diff
@@ -311,18 +311,42 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
opoints_inliers.resize(npoints1);
ipoints_inliers.resize(npoints1);
- result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
- distCoeffs, rvec, tvec, useExtrinsicGuess,
- (flags == SOLVEPNP_P3P || flags == SOLVEPNP_AP3P) ? SOLVEPNP_EPNP : flags) ? 1 : -1;
+ try
+ {
+ result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
``` | `cvFindExtrinsicCameraParams2` does check if the 3D points are coplanar. And if not, it may throw exception. When someone calls `cvFindExtrinsicCameraParams2` directly, he can make sure the input points are more than 4. If he knows that the points may not be coplanar, he can make sure the points are more than 6. In this cases, `cvFindExtrinsicCameraParams2` won't throw exceptions, because the user calls it in the "right" way. However, codes in `solvePnPRansac` does not guarantee that. When the user knows the points used to solve PnP are very likely to be noncoplanar, the only thing he can do is to input as many points as possible (6 at least). But RANSACE procedure (the intermediate calculation) may reduce the points and make them not suitable for `cvFindExtrinsicCameraParams2`. That's why I think Exception here is not supposed to happen. It's NOT the user's fault. To fix this, `solvePnPRansac` should either check the coplanarity before calling `solvePnP`, or call `solvePnP` with try-catch. The former solution may add unnecessary calculation. |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/calib3d/src/solvepnp.cpp
**Change Type:** modified
**Context:** PR #19253: Unexpected exception in solvePnPRansac caused by input points
**Code Changes:**
```diff
@@ -311,18 +311,42 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
opoints_inliers.resize(npoints1);
ipoints_inliers.resize(npoints1);
- result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
- distCoeffs, rvec, tvec, useExtrinsicGuess,
- (flags == SOLVEPNP_P3P || flags == SOLVEPNP_AP3P) ? SOLVEPNP_EPNP : flags) ? 1 : -1;
+ try
+ {
+ result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
``` | Is it needed since it is used in `CV_LOG_DEBUG`? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/calib3d/test/test_solvepnp_ransac.cpp
**Change Type:** modified
**Context:** PR #19253: Unexpected exception in solvePnPRansac caused by input points
**Code Changes:**
```diff
@@ -837,6 +837,43 @@ TEST(Calib3d_SolvePnPRansac, double_support)
EXPECT_LE(cvtest::norm(t, Mat_<double>(tF), NORM_INF), 1e-3);
}
+TEST(Calib3d_SolvePnPRansac, bad_input_points_19253)
+{
+ // with this specific data
+ // when computing the final pose using points in the consensus set with SOLVEPNP_ITERATIVE and solvePnP()
+ // an exception is thrown from solvePnP because there are 5 non-coplanar 3D points and the DLT algorithm needs at least 6 non-coplanar 3D points
+ // with PR #19253 we choose to return true, with the pose estimated from the MSS stage instead of throwing the exception
``` | > 4. / 460.0 Reprojection error is in pixel unit (default value is 8). Wondering if it explains why you only have a consensus set of 5 points? |
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback. | **File:** modules/calib3d/test/test_solvepnp_ransac.cpp
**Change Type:** modified
**Context:** PR #19253: Unexpected exception in solvePnPRansac caused by input points
**Code Changes:**
```diff
@@ -837,6 +837,43 @@ TEST(Calib3d_SolvePnPRansac, double_support)
EXPECT_LE(cvtest::norm(t, Mat_<double>(tF), NORM_INF), 1e-3);
}
+TEST(Calib3d_SolvePnPRansac, bad_input_points_19253)
+{
+ // with this specific data
+ // when computing the final pose using points in the consensus set with SOLVEPNP_ITERATIVE and solvePnP()
+ // an exception is thrown from solvePnP because there are 5 non-coplanar 3D points and the DLT algorithm needs at least 6 non-coplanar 3D points
+ // with PR #19253 we choose to return true, with the pose estimated from the MSS stage instead of throwing the exception
``` | See the buildbot (https://pullrequest.opencv.org/#/summary/opencv) errors. This requires C++11 features. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.