instruction
stringclasses
9 values
input
stringlengths
279
5.47k
output
stringlengths
6
9.58k
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/src/phasecorr.cpp **Change Type:** modified **Context:** PR #27368: imgproc: vectorize cv::createHanningWindow **Code Changes:** ```diff @@ -38,6 +38,7 @@ #include "precomp.hpp" #include <vector> +#include "opencv2/core/hal/intrin.hpp" namespace cv { @@ -614,16 +615,45 @@ void cv::createHanningWindow(OutputArray _dst, cv::Size winSize, int type) double* const wc = _wc.data(); ```
What if drop the condition and just use scalar tail for it? IMHO it should fix small performance degradation on arm.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/deblurring.cpp **Change Type:** added **Context:** PR #27349: Added DNN based deblurring samples **Code Changes:** ```diff @@ -0,0 +1,136 @@ +/* +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 deblurs the given blurry image. + +Copyright (C) 2025, Bigvision LLC. + ```
You can get rid of the conversion, if merge channels in proper order.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/dnn/deblurring.cpp **Change Type:** added **Context:** PR #27349: Added DNN based deblurring samples **Code Changes:** ```diff @@ -0,0 +1,136 @@ +/* +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 deblurs the given blurry image. + +Copyright (C) 2025, Bigvision LLC. + ```
``` vector<Mat> channels = { Mat(output_transposed.size[1], output_transposed.size[2], CV_32F, output_transposed.ptr<float>(0)), Mat(output_transposed.size[1], output_transposed.size[2], CV_32F, output_transposed.ptr<float>(1)), Mat(output_transposed.size[1], output_transposed.size[2], CV_32F, output_transposed.ptr<float>(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_webp.cpp **Change Type:** modified **Context:** PR #27457: fix for the issue #27456 **Code Changes:** ```diff @@ -155,14 +155,16 @@ bool WebPDecoder::readHeader() webp_data.size = data.total(); WebPAnimDecoderOptions dec_options; - WebPAnimDecoderOptionsInit(&dec_options); + if (!WebPAnimDecoderOptionsInit(&dec_options)) + CV_Error(Error::StsInternal, "Failed to initialize animated WebP decoding options"); dec_options.color_mode = m_use_rgb ? MODE_RGBA : MODE_BGRA; anim_decoder.reset(WebPAnimDecoderNew(&webp_data, &dec_options)); ```
That encode is actually useless right?
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/ccm/color.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,391 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "color.hpp" ```
Modern copyright header
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/photo/src/ccm/distance.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,80 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef __OPENCV_CCM_DISTANCE_HPP__ ```
Should we move it to public API?
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
use ColorSpace
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
use ColorSpace
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
use LinearizationType
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
setLinearization
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
please rename it to computeColorCorrectionMatrix() to avoid confusion with another "ccm" - "color correction model", make it return matrix: ``` CV_WRAP Mat compute(); ```
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
rename to `CV_WRAP Mat getColorCorrectionMatrix() const;`
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
probably rename to ``` CV_WRAP void correctImage(InputArray src, OutputArray dst, bool islinear = false); ```
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/photo/include/opencv2/photo/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
==> `CV_WRAP ColorCorrectionModel(const Mat& src, const Mat& colors, COLOR_SPACE ref_cs, const Mat& colored);`
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
==> `CV_WRAP ColorCorrectionModel(const Mat& src, const Mat& colors, COLOR_SPACE ref_cs);`
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
``` CV_WRAP Mat getSrcLinearRGB() const; CV_WRAP Mat getRefLinearRGB() const; ```
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/photo/include/opencv2/photo/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
We use all capital letters for constant names.
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/photo/include/opencv2/photo/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
The same note about capital letters, e.g. `COLOR_SPACE_AppleRGB` -> `COLOR_SPACE_APPLE_RGB`
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
please use `int` for `constcolor`. Unfortunately not all bindings generators support enums 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/photo/include/opencv2/photo/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
Also please use InputArray here and bellow. It allows to add non-cpu branches in future without API change.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/photo/include/opencv2/photo/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
InputArray, OutputArray?
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
`const &` is redundant here. Please use just `double gamma`.
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/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
The same here and bellow.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/photo/perf/perf_ccm.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Review Line:** 20 **Code Changes:** ```diff +{ + string path = cvtest::findDataFile("cv/mcc/mcc_ccm_test.yml"); + FileStorage fs(path, FileStorage::READ); + Mat chartsRGB; + fs["chartsRGB"] >> chartsRGB; + fs.release(); + ASSERT_FALSE(chartsRGB.empty()) << "chartsRGB is empty after loading from: " << path; + + cv::ccm::ColorCorrectionModel model( + chartsRGB.col(1).clone().reshape(3, chartsRGB.rows/3) / 255.0, + cv::ccm::COLORCHECKER_MACBETH ```
`ASSERT_FALSE(chartsRGB.empty());`
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/test/test_precomp.hpp **Change Type:** modified **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -1,11 +1,15 @@ // 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_TEST_PRECOMP_HPP__ -#define __OPENCV_TEST_PRECOMP_HPP__ +#ifndef OPENCV_PHOTO_TEST_PRECOMP_HPP +#define OPENCV_PHOTO_TEST_PRECOMP_HPP #include "opencv2/ts.hpp" ```
using namespace is very bad practice. It affects everything, even, if the header is not included directly.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/color_correction_model.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,224 @@ +//! [tutorial] +#include <opencv2/core.hpp> +#include <opencv2/highgui.hpp> +#include <opencv2/imgcodecs.hpp> +#include <opencv2/imgproc.hpp> +#include <opencv2/photo.hpp> +#include <opencv2/objdetect.hpp> +#include <opencv2/dnn.hpp> +#include <iostream> ```
Please use FileStorage and read/write methods for the model.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/python/color_correction_model.py **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,185 @@ +import cv2 as cv +import numpy as np +import argparse +import sys +import os +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) +from dnn.common import * + +def get_args_parser(func_args): ```
Please add couple of python tests. They are executed by CI automatically.
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/ccm/utils.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Review Line:** 39 **Code Changes:** ```diff +/** @brief multiple the function used to compute an array with n channels + mulipied by ccm. + @param xyz the input array, type of Mat. + @param ccm the ccm matrix to make color correction. + */ +Mat multiple(const Mat& xyz, const Mat& ccm); + +/** @brief multiple the function used to get the mask of saturated colors, + colors between low and up will be choosed. + @param src the input array, type of Mat. + @param low the threshold to choose saturated colors ```
Most probably the function may be replaced with cv::transform https://docs.opencv.org/4.x/d2/de8/group__core__array.html#ga393164aa54bb9169ce0a8cc44e08ff22
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/src/ccm/utils.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Review Line:** 32 **Code Changes:** ```diff + +/** @brief maskCopyTo a function to delete unsatisfied elementwise. + @param src the input array, type of Mat. + @param mask operation mask that used to choose satisfided elementwise. + */ +Mat maskCopyTo(const Mat& src, const Mat& mask); + +/** @brief multiple the function used to compute an array with n channels + mulipied by ccm. + @param xyz the input array, type of Mat. + @param ccm the ccm matrix to make color correction. ```
there is Mat.copyTo() with mask support instead of it.
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/ccm/utils.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,113 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "utils.hpp" ```
inRange should be enough instead of it: https://docs.opencv.org/4.x/d2/de8/group__core__array.html#ga48af0ab51e36436c5d04340e036ce981
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/python/color_correction_model.py **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,185 @@ +import cv2 as cv +import numpy as np +import argparse +import sys +import os +sys.path.append(os.path.join(os.path.dirname(__file__), "..")) +from dnn.common import * + +def get_args_parser(func_args): ```
Which location should the test be added? Inside ccm directory or in modules/python/tests ?
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/ccm/ccm.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Review Line:** 15 **Code Changes:** ```diff +#include "linearize.hpp" +#include <cmath> +namespace cv { +namespace ccm { + +class ColorCorrectionModel::Impl +{ +public: + Mat src; + + Color ref = Color(); ```
Space line before class.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** doc/tutorials/photo/ccm/color_correction_model.markdown **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,53 @@ +Color Correction Model{#tutorial_ccm_color_correction_model} +=========================== + +Introduction +---- + +The purpose of color correction is to adjust the color response of input and output devices to a known state. The device being calibrated is sometimes called the calibration source; the color space used as the standard is sometimes called the calibration target. Color calibration has been used in many industries, such as television production, games, photography, engineering, chemistry, medicine, etc. Due to the manufacturing process of the input and output equipment, the channel response has nonlinear distortion. In order to correct the picture output of the equipment, it is nessary to calibrate the captured color and the actual color. + +In this tutorial you will learn how to use the 'Color Correction Model' to do a color correction in a image. ```
It makes sense to add reference to anym, but not list all variants here. It may change in time, but we always forget about text.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/color_correction_model.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,224 @@ +//! [tutorial] +#include <opencv2/core.hpp> +#include <opencv2/highgui.hpp> +#include <opencv2/imgcodecs.hpp> +#include <opencv2/imgproc.hpp> +#include <opencv2/photo.hpp> +#include <opencv2/objdetect.hpp> +#include <opencv2/dnn.hpp> +#include <iostream> ```
There is a mistake here: `--input=--ccm_file`
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/color_correction_model.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,224 @@ +//! [tutorial] +#include <opencv2/core.hpp> +#include <opencv2/highgui.hpp> +#include <opencv2/imgcodecs.hpp> +#include <opencv2/imgproc.hpp> +#include <opencv2/photo.hpp> +#include <opencv2/objdetect.hpp> +#include <opencv2/dnn.hpp> +#include <iostream> ```
I would say that if + verbose error message is preferable here. Just exception with assert condition is cryptic for user.
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/photo/test/test_ccm.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,302 @@ +// 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 "test_precomp.hpp" + +namespace opencv_test +{ +namespace ```
FileStorage supports in-memory operations. You can get just strings and compare without disc i/o.
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/ccm/utils.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,113 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "utils.hpp" ```
Why not just cvtColor?
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/ccm/utils.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Review Line:** 111 **Code Changes:** ```diff + Mat mask; + inRange(src, lower_bound, upper_bound, mask); + mask /= 255; + + return mask; +} +} +} // namespace cv::ccm ```
normalize with NORM_MIN_MAX does the same: https://docs.opencv.org/5.x/d2/de8/group__core__array.html#ga87eef7ee3970f86906d69a92cbf064bd
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/src/ccm/linearize.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,260 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef __OPENCV_CCM_LINEARIZE_HPP__ ```
empty line is redundant.
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/src/ccm/color.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,108 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef __OPENCV_CCM_COLOR_HPP__ ```
IO object should be passed by reference. I do not see why we need a copy each time.
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/ccm/color.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,391 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "color.hpp" ```
just `history.find`? It's std::map and the key value may appear only once, if it's there.
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/ccm/color.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,391 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "color.hpp" ```
``` if(save) { std::shared_ptr<Color> color = std::make_shared<Color>(ops.run(colors), other); history[other] = color; return *color; } else { return Color(ops.run(colors), other); } ```
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/photo/perf/perf_ccm.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,103 @@ +// 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" +#include "opencv2/photo.hpp" + +namespace opencv_test { +namespace { ```
It makes sense to use some popular image size line 1920x1080, or, better, make a parameterized test and benchmark several popular resolutions.
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/ccm/color.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,391 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "color.hpp" ```
`std::shared_ptr` is redundant here. You can just return `Color` object and store it as ColorCorrectionModel::Impl field.
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/ccm/ccm.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,557 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "opencv2/photo.hpp" ```
`dst` is bad name. There are many clashes with method parameter name.
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/ccm/ccm.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,557 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "opencv2/photo.hpp" ```
Also shared_ptr looks redundant here.
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/photo/src/ccm/ccm.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,557 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "opencv2/photo.hpp" ```
There is `cv::mixChannels` channels to reach the same result faster without extra allocations: https://docs.opencv.org/5.x/d2/de8/group__core__array.html#ga51d768c270a1cdd3497255017c4504be
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/ccm/ccm.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,557 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "opencv2/photo.hpp" ```
No need to spit cv::Mat by channels for it. cv::sum supports channels: https://docs.opencv.org/5.x/d2/de8/group__core__array.html#ga716e10a2dd9e228e4d3c95818f106722
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/photo/src/ccm/utils.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,113 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "utils.hpp" ```
I propose to convert Gamma correction to public function with InputArray and OutputArray. It's useful independently from the pipeline and also may be significantly optimized with universal intrinsics.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/photo/src/ccm/utils.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Review Line:** 16 **Code Changes:** ```diff +namespace cv { +namespace ccm { + +void gammaCorrection(InputArray _src, OutputArray _dst, double gamma) +{ + Mat src = _src.getMat(); + CV_Assert(gamma > 0); + + double maxVal; + int depth = src.depth(); + switch (depth) ```
please add CV_Assert with input type checks at least. The function is public API now and should handle invalid input correctly.
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/photo/src/ccm/ccm.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,557 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "opencv2/photo.hpp" ```
You add even more operations with memory. simgle mixChannels without split and merge can do it.
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/ccm/ccm.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,557 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "opencv2/photo.hpp" ```
The code with ccm0 and coeffs looks very cryptic. I proposr to create ccm0 with proper shape with zeros , e.g. cv::Mat::zeros() and then set non-zero values for it. It's less amount of code, but there is no strange resize/reshape and `shape/3` values.
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/ccm/utils.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,145 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef __OPENCV_CCM_UTILS_HPP__ ```
It should go to make ccm header to be included into documentation and bindings. Please CV_EXPORTS_W to generate Java and Python bindings for it too.
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/ccm/utils.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Review Line:** 111 **Code Changes:** ```diff + Mat mask; + inRange(src, lower_bound, upper_bound, mask); + mask /= 255; + + return mask; +} +} +} // namespace cv::ccm ```
The function needs the mask as an output of values in upper bound and lower bound. I don't think this can be replaced
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/ccm/operations.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Review Line:** 50 **Code Changes:** ```diff +{ + ops.insert(ops.end(), other.ops.begin(), other.ops.end()); + return *this; +}; + +Mat Operations::run(Mat abc) +{ + Operation hd; + for (auto& op : ops) + { + if (op.linear) ```
I tried it, but it cannot be replaced by Mat&
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/include/opencv2/photo/ccm.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,322 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#ifndef OPENCV_PHOTO_CCM_HPP ```
`\n` is not needed here and other documentation strings.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/photo/perf/perf_ccm.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Review Line:** 41 **Code Changes:** ```diff +PERF_TEST(CV_ccm_perf_720_1280, correctImage) +{ + string path = cvtest::findDataFile("cv/mcc/mcc_ccm_test.yml"); + FileStorage fs(path, FileStorage::READ); + Mat chartsRGB; + fs["chartsRGB"] >> chartsRGB; + fs.release(); + ASSERT_FALSE(chartsRGB.empty()) << "chartsRGB is empty after loading from: " << path; + + cv::ccm::ColorCorrectionModel model( + chartsRGB.col(1).clone().reshape(3, chartsRGB.rows/3) / 255.0, ```
`ASSERT_FALSE(chartsRGB.empty());` here and bellow.
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/color_correction_model.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,224 @@ +//! [tutorial] +#include <opencv2/core.hpp> +#include <opencv2/highgui.hpp> +#include <opencv2/imgcodecs.hpp> +#include <opencv2/imgproc.hpp> +#include <opencv2/photo.hpp> +#include <opencv2/objdetect.hpp> +#include <opencv2/dnn.hpp> +#include <iostream> ```
I propose to Move BRG/RGB logic into model with a flag (default to bgr). All OpenCV functions are designed for BGR. The flag allows to make optimizations without API change.
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/ccm/linearize.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Code Changes:** ```diff @@ -0,0 +1,284 @@ +// 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. +// +// Author: Longbu Wang <wanglongbu@huawei.com.com> +// Jinheng Zhang <zhangjinheng1@huawei.com> +// Chenqi Shan <shanchenqi@huawei.com> + +#include "linearize.hpp" ```
`make_shared<>`
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/ccm/utils.cpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Review Line:** 16 **Code Changes:** ```diff +namespace cv { +namespace ccm { + +void gammaCorrection(InputArray _src, OutputArray _dst, double gamma) +{ + Mat src = _src.getMat(); + CV_Assert(gamma > 0); + + double maxVal; + int depth = src.depth(); + switch (depth) ```
It's still relevant.
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/src/ccm/utils.hpp **Change Type:** added **Context:** PR #27051: Adding color correction module to photo module from opencv_contrib **Review Line:** 39 **Code Changes:** ```diff +/** @brief multiple the function used to compute an array with n channels + mulipied by ccm. + @param xyz the input array, type of Mat. + @param ccm the ccm matrix to make color correction. + */ +Mat multiple(const Mat& xyz, const Mat& ccm); + +/** @brief multiple the function used to get the mask of saturated colors, + colors between low and up will be choosed. + @param src the input array, type of Mat. + @param low the threshold to choose saturated colors ```
Still relevant.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/objdetect/include/opencv2/objdetect.hpp **Change Type:** modified **Context:** PR #24426: Consider QRCode ECI encoding **Code Changes:** ```diff @@ -729,7 +729,8 @@ class CV_EXPORTS_W QRCodeEncoder { }; enum ECIEncodings { - ECI_UTF8 = 26 + ECI_SHIFT_JIS = 20, + ECI_UTF8 = 26, }; /** @brief QR code encoder parameters. */ ```
This enum confuses a bit
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/objdetect/include/opencv2/objdetect.hpp **Change Type:** modified **Context:** PR #24426: Consider QRCode ECI encoding **Code Changes:** ```diff @@ -729,7 +729,8 @@ class CV_EXPORTS_W QRCodeEncoder { }; enum ECIEncodings { - ECI_UTF8 = 26 + ECI_SHIFT_JIS = 20, + ECI_UTF8 = 26, }; /** @brief QR code encoder parameters. */ ```
m.b. latest frame or latest detectAndDecode call.
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.cpp **Change Type:** modified **Context:** PR #24426: Consider QRCode ECI encoding **Code Changes:** ```diff @@ -963,6 +963,7 @@ struct ImplContour : public GraphicalCodeDetector::Impl double epsX, epsY; mutable vector<vector<Point2f>> alignmentMarkers; mutable vector<Point2f> updateQrCorners; + mutable vector<QRCodeEncoder::ECIEncodings> encodings; bool useAlignmentMarkers = true; bool detect(InputArray in, OutputArray points) const override; @@ -978,6 +979,8 @@ struct ImplContour : public GraphicalCodeDetector::Impl String decodeCurved(InputArray in, InputArray points, OutputArray straight_qrcode); ```
why not just int for codeIdx + assert? Unsigned types is a pain for Java.
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/objdetect/misc/java/gen_dict.json **Change Type:** added **Context:** PR #24426: Consider QRCode ECI encoding **Code Changes:** ```diff @@ -0,0 +1,68 @@ +{ + "ManualFuncs" : { + "QRCodeEncoder" : { + "QRCodeEncoder" : { + "j_code" : [ + "\n", + "/** Generates QR code from input string.", + "@param encoded_info Input bytes to encode.", + "@param qrcode Generated QR code.", ```
The comments are not related.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/objdetect/include/opencv2/objdetect/graphical_code_detector.hpp **Change Type:** modified **Context:** PR #24426: Consider QRCode ECI encoding **Code Changes:** ```diff @@ -73,6 +73,17 @@ class CV_EXPORTS_W_SIMPLE GraphicalCodeDetector { */ CV_WRAP bool detectAndDecodeMulti(InputArray img, CV_OUT std::vector<std::string>& decoded_info, OutputArray points = noArray(), OutputArrayOfArrays straight_code = noArray()) const; + +#ifdef OPENCV_BINDINGS_PARSER + CV_WRAP_AS(detectAndDecodeBytes) NativeByteArray detectAndDecode(InputArray img, OutputArray points = noArray(), + OutputArray straight_code = noArray()) const; + CV_WRAP_AS(decodeBytes) NativeByteArray decode(InputArray img, InputArray points, OutputArray straight_code = noArray()) const; + CV_WRAP_AS(decodeBytesMulti) bool decodeMulti(InputArray img, InputArray points, CV_OUT std::vector<NativeByteArray>& decoded_info, ```
Java bindings use just cv::Mat for it. There is MatOfBytes specialization. M.b. reuse it too?
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/objdetect/include/opencv2/objdetect/graphical_code_detector.hpp **Change Type:** modified **Context:** PR #24426: Consider QRCode ECI encoding **Code Changes:** ```diff @@ -73,6 +73,17 @@ class CV_EXPORTS_W_SIMPLE GraphicalCodeDetector { */ CV_WRAP bool detectAndDecodeMulti(InputArray img, CV_OUT std::vector<std::string>& decoded_info, OutputArray points = noArray(), OutputArrayOfArrays straight_code = noArray()) const; + +#ifdef OPENCV_BINDINGS_PARSER + CV_WRAP_AS(detectAndDecodeBytes) NativeByteArray detectAndDecode(InputArray img, OutputArray points = noArray(), + OutputArray straight_code = noArray()) const; + CV_WRAP_AS(decodeBytes) NativeByteArray decode(InputArray img, InputArray points, OutputArray straight_code = noArray()) const; + CV_WRAP_AS(decodeBytesMulti) bool decodeMulti(InputArray img, InputArray points, CV_OUT std::vector<NativeByteArray>& decoded_info, ```
In such way user should call an extra method: ```java MatOfByte output = detector.detectAndDecodeBytes(qrcode); new String(output.toArray(), "Shift_JIS")); ```
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/objdetect/src/qrcode.cpp **Change Type:** modified **Context:** PR #24426: Consider QRCode ECI encoding **Code Changes:** ```diff @@ -963,6 +963,7 @@ struct ImplContour : public GraphicalCodeDetector::Impl double epsX, epsY; mutable vector<vector<Point2f>> alignmentMarkers; mutable vector<Point2f> updateQrCorners; + mutable vector<QRCodeEncoder::ECIEncodings> encodings; bool useAlignmentMarkers = true; bool detect(InputArray in, OutputArray points) const override; @@ -978,6 +979,8 @@ struct ImplContour : public GraphicalCodeDetector::Impl String decodeCurved(InputArray in, InputArray points, OutputArray straight_qrcode); ```
It makes resize/reserve `encodings` vector first to reduce reallocs.
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/java/generator/android-21/java/org/opencv/android/JavaCamera2View.java **Change Type:** modified **Context:** PR #27419: Fixed Android setCameraIndex issue. **Code Changes:** ```diff @@ -96,8 +96,10 @@ protected boolean selectCamera() { Log.e(LOGTAG, "Error: camera isn't detected."); return false; } + boolean chosen = false; // remember whether the camera ID is set. if (mCameraIndex == CameraBridgeViewBase.CAMERA_ID_ANY) { mCameraID = camList[0]; + chosen = true; } else { for (String cameraID : camList) { ```
`chosen`
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/videoio/misc/java/test/VideoCaptureTest.java **Change Type:** modified **Context:** PR #27421: Cover all seek directions in VideoCapture Java test **Code Changes:** ```diff @@ -123,6 +123,10 @@ public long seek(long offset, int origin) { if (origin == 0) f.seek(offset); + else if (origin == 1) + f.seek(f.getFilePointer() + offset); + else if (origin == 2) + f.seek(f.length() + offset); return f.getFilePointer(); } ```
`(0, SEEK_END)` should point to `f.length()` not `f.length() - 1`
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/dnn/CMakeLists.txt **Change Type:** modified **Context:** PR #27428: Cmake protobuf_generate_cpp deprecated use protobuf_generate **Code Changes:** ```diff @@ -115,8 +115,22 @@ if(HAVE_PROTOBUF) if(PROTOBUF_UPDATE_FILES) file(GLOB proto_files "${CMAKE_CURRENT_LIST_DIR}/src/tensorflow/*.proto" "${CMAKE_CURRENT_LIST_DIR}/src/caffe/opencv-caffe.proto" "${CMAKE_CURRENT_LIST_DIR}/src/onnx/opencv-onnx.proto") - set(PROTOBUF_GENERATE_CPP_APPEND_PATH ON) # required for tensorflow - protobuf_generate_cpp(fw_srcs fw_hdrs ${proto_files}) + if(CMAKE_VERSION VERSION_LESS "3.13.0") + set(PROTOBUF_GENERATE_CPP_APPEND_PATH ON) # required for tensorflow + protobuf_generate_cpp(fw_srcs fw_hdrs ${proto_files}) + else() ```
> protobuf_generate Added in version 3.13. It breaks build with older CMake. I propose to add CMake version check and presume the old branch for old CMake.
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:** hal/ipp/include/ipp_hal_core.hpp **Change Type:** modified **Context:** PR #27354: Update IPP integration - Please merge together with https://github.com/opencv/opencv_3rdparty/pull/96 Supported IPP version was updated to ... **Review Line:** 20 **Code Changes:** ```diff @@ -17,15 +17,18 @@ int ipp_hal_minMaxIdxMaskStep(const uchar* src_data, size_t src_step, int width, #undef cv_hal_minMaxIdxMaskStep #define cv_hal_minMaxIdxMaskStep ipp_hal_minMaxIdxMaskStep -#define IPP_DISABLE_NORM_8U 1 // accuracy difference in perf test sanity check +#if (IPP_VERSION_X100 == 202200) +# define IPP_DISABLE_NORM_8U 1 // accuracy difference in perf test sanity check +# else +# define IPP_DISABLE_NORM_8U 0 +#endif ```
There is still old versions (e.g. Apple Mac, Linux 32-bit) Also there are generic IPP releases, which may behave in different way and may have these "old" issues. Could you please add version check instead (with using of `HAVE_IPP_ICV` if necessary)?
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:** hal/ipp/include/ipp_hal_core.hpp **Change Type:** modified **Context:** PR #27354: Update IPP integration - Please merge together with https://github.com/opencv/opencv_3rdparty/pull/96 Supported IPP version was updated to ... **Review Line:** 20 **Code Changes:** ```diff @@ -17,15 +17,18 @@ int ipp_hal_minMaxIdxMaskStep(const uchar* src_data, size_t src_step, int width, #undef cv_hal_minMaxIdxMaskStep #define cv_hal_minMaxIdxMaskStep ipp_hal_minMaxIdxMaskStep -#define IPP_DISABLE_NORM_8U 1 // accuracy difference in perf test sanity check +#if (IPP_VERSION_X100 == 202200) +# define IPP_DISABLE_NORM_8U 1 // accuracy difference in perf test sanity check +# else +# define IPP_DISABLE_NORM_8U 0 +#endif ```
I've returned it, but comparison with only one version, because the issue appeared only in the previous update, which is already was done for 64-bit Linux and Windows only.
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/distransform.cpp **Change Type:** modified **Context:** PR #24535: Handle huge images in IPP distanceTransform **Code Changes:** ```diff @@ -817,14 +817,15 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe Size size = src.size(); int border = maskSize == CV_DIST_MASK_3 ? 1 : 2; - Mat temp( size.height + border*2, size.width + border*2, CV_32SC1 ); + Mat temp; if( !need_labels ) { if( maskSize == CV_DIST_MASK_3 ) ```
Need to check how it worked with ROI dst before.
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/distransform.cpp **Change Type:** modified **Context:** PR #24535: Handle huge images in IPP distanceTransform **Code Changes:** ```diff @@ -817,14 +817,15 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe Size size = src.size(); int border = maskSize == CV_DIST_MASK_3 ? 1 : 2; - Mat temp( size.height + border*2, size.width + border*2, CV_32SC1 ); + Mat temp; if( !need_labels ) { if( maskSize == CV_DIST_MASK_3 ) ```
probably related to this discussion: https://github.com/opencv/opencv/issues/12018. Changed check to INT_MAX overflow
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/distransform.cpp **Change Type:** modified **Context:** PR #24535: Handle huge images in IPP distanceTransform **Code Changes:** ```diff @@ -817,14 +817,15 @@ void cv::distanceTransform( InputArray _src, OutputArray _dst, OutputArray _labe Size size = src.size(); int border = maskSize == CV_DIST_MASK_3 ? 1 : 2; - Mat temp( size.height + border*2, size.width + border*2, CV_32SC1 ); + Mat temp; if( !need_labels ) { if( maskSize == CV_DIST_MASK_3 ) ```
the right link about `isContinuous()` mess: #11505
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/videoio/src/cap_ffmpeg_impl.hpp **Change Type:** modified **Context:** PR #27153: fix #26276: cv::VideoWriter fails writing colorless images **Code Changes:** ```diff @@ -2525,11 +2525,13 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int // check parameters if (input_pix_fmt == AV_PIX_FMT_BGR24) { if (cn != 3) { + CV_LOG_WARNING(NULL, "write frame skipped - expected 3 channels but got " << cn); return false; } } else if (input_pix_fmt == AV_PIX_FMT_GRAY8 || input_pix_fmt == AV_PIX_FMT_GRAY16LE) { if (cn != 1) { ```
In case of `encode_video = False` we should accept only raw bytes arrays. So we should have CV_8UC1 data type only. Expected layout is 1xN or Nx1. This change must be reverted.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/videoio/src/cap_ffmpeg_impl.hpp **Change Type:** modified **Context:** PR #27153: fix #26276: cv::VideoWriter fails writing colorless images **Code Changes:** ```diff @@ -2525,11 +2525,13 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int // check parameters if (input_pix_fmt == AV_PIX_FMT_BGR24) { if (cn != 3) { + CV_LOG_WARNING(NULL, "write frame skipped - expected 3 channels but got " << cn); return false; } } else if (input_pix_fmt == AV_PIX_FMT_GRAY8 || input_pix_fmt == AV_PIX_FMT_GRAY16LE) { if (cn != 1) { ```
> inputMat ... inputMat "In-place" ops should not be used in general (causes extra `.clone()` call).
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/videoio/src/cap_ffmpeg_impl.hpp **Change Type:** modified **Context:** PR #27153: fix #26276: cv::VideoWriter fails writing colorless images **Code Changes:** ```diff @@ -2525,11 +2525,13 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int // check parameters if (input_pix_fmt == AV_PIX_FMT_BGR24) { if (cn != 3) { + CV_LOG_WARNING(NULL, "write frame skipped - expected 3 channels but got " << cn); return false; } } else if (input_pix_fmt == AV_PIX_FMT_GRAY8 || input_pix_fmt == AV_PIX_FMT_GRAY16LE) { if (cn != 1) { ```
What is about other cases? 16UC3?
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/videoio/src/cap_ffmpeg_impl.hpp **Change Type:** modified **Context:** PR #27153: fix #26276: cv::VideoWriter fails writing colorless images **Code Changes:** ```diff @@ -2525,11 +2525,13 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int // check parameters if (input_pix_fmt == AV_PIX_FMT_BGR24) { if (cn != 3) { + CV_LOG_WARNING(NULL, "write frame skipped - expected 3 channels but got " << cn); return false; } } else if (input_pix_fmt == AV_PIX_FMT_GRAY8 || input_pix_fmt == AV_PIX_FMT_GRAY16LE) { if (cn != 1) { ```
Good point. I had focused only on the explicitly supported types (CV_8UC1, CV_16UC1, CV_8UC3) and overlooked the possibility of unsupported inputs like CV_16UC3. I’ll address this as well.
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_ffmpeg_impl.hpp **Change Type:** modified **Context:** PR #27153: fix #26276: cv::VideoWriter fails writing colorless images **Code Changes:** ```diff @@ -2525,11 +2525,13 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int // check parameters if (input_pix_fmt == AV_PIX_FMT_BGR24) { if (cn != 3) { + CV_LOG_WARNING(NULL, "write frame skipped - expected 3 channels but got " << cn); return false; } } else if (input_pix_fmt == AV_PIX_FMT_GRAY8 || input_pix_fmt == AV_PIX_FMT_GRAY16LE) { if (cn != 1) { ```
This is a part of external API (`cap_ffmpeg_legacy_api.hpp`), we can't just change parameters meaning.
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_ffmpeg_impl.hpp **Change Type:** modified **Context:** PR #27153: fix #26276: cv::VideoWriter fails writing colorless images **Code Changes:** ```diff @@ -2525,11 +2525,13 @@ bool CvVideoWriter_FFMPEG::writeFrame( const unsigned char* data, int step, int // check parameters if (input_pix_fmt == AV_PIX_FMT_BGR24) { if (cn != 3) { + CV_LOG_WARNING(NULL, "write frame skipped - expected 3 channels but got " << cn); return false; } } else if (input_pix_fmt == AV_PIX_FMT_GRAY8 || input_pix_fmt == AV_PIX_FMT_GRAY16LE) { if (cn != 1) { ```
I completely missed that detail... As its part of external API, I'm going to revert it back to using the number of channels
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 #27362: Fix empty ND-array construction **Review Line:** 1466 **Code Changes:** ```diff + EXPECT_LE(mat_nd.total(), 1u); + EXPECT_FALSE(mat_nd.empty()); +#endif + EXPECT_EQ(mat.total(), 0u); + EXPECT_TRUE(mat.empty()); +} + TEST(Core_InputArray, empty) { vector<vector<Point> > data; ```
suggest to add some checks to the test: ``` TEST(Core_Mat, empty) { // Should not crash. uint8_t data[2] = {0, 1}; cv::Mat mat_nd(/*ndims=*/0, /*sizes=*/nullptr, CV_8UC1, /*data=*/data); cv::Mat1b mat(0, 0, /*data=*/data, /*steps=*/1); EXPECT_EQ(mat_nd.dims, 0); EXPECT_EQ(mat.dims, 2); EXPECT_LE(mat_nd.total(), 1u); // 0 for 4.x, 1 for 5.x EXPECT_EQ(mat.total(), 0u); EXPECT_TRUE(mat.empty()); // mat_nd.empty() should return true for 4.x and false for 5.x } ```
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 #27362: Fix empty ND-array construction **Review Line:** 318 **Code Changes:** ```diff @@ -315,7 +315,7 @@ void finalizeHdr(Mat& m) m.rows = m.cols = -1; if(m.u) m.datastart = m.data = m.u->data; - if( m.data ) + if( m.data && d > 0 ) { m.datalimit = m.datastart + m.size[0]*m.step[0]; if( m.size[0] > 0 ) @@ -328,7 +328,7 @@ void finalizeHdr(Mat& m) m.dataend = m.datalimit; ```
adding `d > 0` is fine. I'd also suggest to modify the else branch: ``` else m.dataend = m.datalimit = 0; ``` to ``` else m.dataend = m.datalimit = m.data; ``` that will make behaviour of both constructors of an empty matrix more consistent.
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 #27362: Fix empty ND-array construction **Review Line:** 1466 **Code Changes:** ```diff + EXPECT_LE(mat_nd.total(), 1u); + EXPECT_FALSE(mat_nd.empty()); +#endif + EXPECT_EQ(mat.total(), 0u); + EXPECT_TRUE(mat.empty()); +} + TEST(Core_InputArray, empty) { vector<vector<Point> > data; ```
> // 0 for 4.x, 1 for 5.x Do we really to introduce support in OpenCV 4.x for functionality which has different behavior in OpenCV 5.x.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** doc/tutorials/dnn/dnn_openvino/dnn_openvino.markdown **Change Type:** modified **Context:** PR #27363: Feature: Add OpenVINO NPU support **Code Changes:** ```diff @@ -26,3 +26,14 @@ There are 2 approaches how to get OpenCV: - Build OpenCV from source code against specific version of OpenVINO. This approach solves the limitations mentioned above. The instruction how to follow both approaches is provided in [OpenCV wiki](https://github.com/opencv/opencv/wiki/BuildOpenCV4OpenVINO). + +## Supported targets + +OpenVINO backend (DNN_BACKEND_INFERENCE_ENGINE) supports the following [targets](https://docs.opencv.org/4.x/d6/d0f/group__dnn.html#ga709af7692ba29788182cf573531b0ff5): + +- **DNN_TARGET_CPU:** Runs on the CPU, no additional dependencies required. ```
Try use `&reg;` instead of ®
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** doc/tutorials/dnn/dnn_openvino/dnn_openvino.markdown **Change Type:** modified **Context:** PR #27363: Feature: Add OpenVINO NPU support **Code Changes:** ```diff @@ -26,3 +26,14 @@ There are 2 approaches how to get OpenCV: - Build OpenCV from source code against specific version of OpenVINO. This approach solves the limitations mentioned above. The instruction how to follow both approaches is provided in [OpenCV wiki](https://github.com/opencv/opencv/wiki/BuildOpenCV4OpenVINO). + +## Supported targets + +OpenVINO backend (DNN_BACKEND_INFERENCE_ENGINE) supports the following [targets](https://docs.opencv.org/4.x/d6/d0f/group__dnn.html#ga709af7692ba29788182cf573531b0ff5): + +- **DNN_TARGET_CPU:** Runs on the CPU, no additional dependencies required. ```
fixed for &trade; too
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/test/test_fitellipse.cpp **Change Type:** modified **Context:** PR #26299: Add getClosestEllipsePoints() function to get the closest point on an ellipse **Code Changes:** ```diff @@ -113,4 +113,197 @@ TEST(Imgproc_FitEllipse_HorizontalLine, accuracy) { EXPECT_NEAR(el.angle, 90, 0.1); } +template<typename T> +static float get_ellipse_fitting_error(const std::vector<T>& points, const Mat& closest_points) { + float mse = 0.0f; + for (int i = 0; i < static_cast<int>(points.size()); i++) + { + Point2f pt_err = Point2f(static_cast<float>(points[i].x), static_cast<float>(points[i].y)) - closest_points.at<Point2f>(i); ```
Check correctness
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/shapedescr.cpp **Change Type:** modified **Context:** PR #26299: Add getClosestEllipsePoints() function to get the closest point on an ellipse **Code Changes:** ```diff @@ -877,6 +877,121 @@ cv::RotatedRect cv::fitEllipseDirect( InputArray _points ) return box; } +namespace cv +{ +// @misc{Chatfield2017, +// author = {Chatfield, Carl}, +// title = {A Simple Method for Distance to Ellipse}, +// year = {2017}, ```
Keep using Matx instead of Mat, since Matx is instantly allocated on stack and for Matx there is also overloaded '*' opereator. Here you basically initialize quite big structure Mat and allocate the Mat data in heap for each single point, which is very bad.
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_subdivision2d.cpp **Change Type:** modified **Context:** PR #27149: Fix #25696: Solved the problem in Subdiv2D, empty delaunay triangulation **Code Changes:** ```diff @@ -50,4 +50,18 @@ TEST(Imgproc_Subdiv2D_getTriangleList, regression_5788) EXPECT_EQ(trig_cnt, 105); } +TEST(Imgproc_Subdiv2D, issue_25696) { + std::vector<cv::Point2f> points{ + {0, 0}, {40, 40}, {84, 104}, {86, 108} + }; + + cv::Rect subdivRect{cv::Point{-10, -10}, cv::Point{96, 118}}; ```
CI Warning: ``` warning: comparison of integers of different signs: 'const unsigned long' and 'const int' [-Wsign-compare] ``` Also GTest macro signature says that expected value should go first.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/core/include/opencv2/core/hal/intrin_legacy_ops.h **Change Type:** added **Context:** PR #27327: Restored legacy intrinsics operators in a separate header - resolves #27267 * New header with removed universal intrinsics operator overloa... **Review Line:** 22 **Code Changes:** ```diff +#warning "Operators might conflict with built-in functions on RISC-V platform" +#endif + +#if defined(CV_VERSION) && CV_VERSION_MAJOR == 4 && CV_VERSION_MINOR < 11 +#warning "Older versions of OpenCV (<4.11) already have Universal Intrinscs operators" +#endif + + +namespace cv { namespace hal { + +#define BIN_OP(OP, FUN) \ ```
It is only since OpenCV 4.11 the Universal Intrinscs operators have been removed? I don't understand, I had to [fix some code](https://github.com/lagadic/visp/commit/9ed0300507e13dddd83fd62a799f5039025ea44e) since OpenCV 4.9 release. https://github.com/opencv/opencv/pull/24371
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/calib3d/src/solvepnp.cpp **Change Type:** modified **Context:** PR #27311: Added warning if projected axes are out of camera frame in drawAxes **Review Line:** 123 **Code Changes:** ```diff + allIn &= imageRect.contains(imagePoints[i]); + } + + if (!allIn) + { + CV_LOG_WARNING(NULL, "Some of projected axes endpoints are out of frame. The drawn axes may be not relaible."); + } + // draw axes lines line(image, imagePoints[0], imagePoints[1], Scalar(0, 0, 255), thickness); line(image, imagePoints[0], imagePoints[2], Scalar(0, 255, 0), thickness); ```
> relaible Small typo. I am not a native english speaker, my proposition: &#8594; "Some of the projected axes endpoints are outside of the image bounds. The drawn axes may not be reliable with strong lens distortion ." (accurate / correct instead?) <details> <summary>off topic</summary> <s> --- I would add in the message something like this: - "You may want to pass a zero-distortion coefficient vector to avoid this issue." (or NULL?) This should be the simplest workaround since most likely `drawFrameAxes` would be used for debugging / display purposes (no need for accurate display in my opinion). --- Maybe another approach would be? - `projectPoints` without distortion - clip the coordinates inside the image rectangle - add distortion - draw the frame axes</s> </details>
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/calib3d/src/solvepnp.cpp **Change Type:** modified **Context:** PR #27311: Added warning if projected axes are out of camera frame in drawAxes **Review Line:** 123 **Code Changes:** ```diff + allIn &= imageRect.contains(imagePoints[i]); + } + + if (!allIn) + { + CV_LOG_WARNING(NULL, "Some of projected axes endpoints are out of frame. The drawn axes may be not relaible."); + } + // draw axes lines line(image, imagePoints[0], imagePoints[1], Scalar(0, 0, 255), thickness); line(image, imagePoints[0], imagePoints[2], Scalar(0, 255, 0), thickness); ```
> "You may want to pass a zero-distortion coefficient vector to avoid this issue." (or NULL?) It generates incorrect result for cameras with visible distortion. Axes will be shifted from expected location.
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/gapi/CMakeLists.txt **Change Type:** modified **Context:** PR #27355: Check MS Media Foundation availability in G-API too **Review Line:** 384 **Code Changes:** ```diff @@ -380,6 +380,15 @@ if(WIN32) ocv_target_link_libraries(${the_module} PRIVATE wsock32 ws2_32) endif() +ocv_option(OPENCV_GAPI_MSMF "Build G-API with MS Media Foundation support" HAVE_MSMF) +if(HAVE_MSMF AND OPENCV_GAPI_MSMF) + if(TARGET opencv_test_gapi) + ocv_target_compile_definitions(opencv_test_gapi PRIVATE -DHAVE_GAPI_MSMF) + endif() + ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_GAPI_MSMF) + ocv_target_link_libraries(${the_module} PRIVATE ocv.3rdparty.msmf) ```
OPENCV_GAPU_MSMF OPENCV_GAPI_MSMF typo
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/gapi/CMakeLists.txt **Change Type:** modified **Context:** PR #27355: Check MS Media Foundation availability in G-API too **Review Line:** 384 **Code Changes:** ```diff @@ -380,6 +380,15 @@ if(WIN32) ocv_target_link_libraries(${the_module} PRIVATE wsock32 ws2_32) endif() +ocv_option(OPENCV_GAPI_MSMF "Build G-API with MS Media Foundation support" HAVE_MSMF) +if(HAVE_MSMF AND OPENCV_GAPI_MSMF) + if(TARGET opencv_test_gapi) + ocv_target_compile_definitions(opencv_test_gapi PRIVATE -DHAVE_GAPI_MSMF) + endif() + ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_GAPI_MSMF) + ocv_target_link_libraries(${the_module} PRIVATE ocv.3rdparty.msmf) ```
`TARGET ocv.3rdparty.msmf` should be used instead of `HAVE_MSMF`.
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/gapi/CMakeLists.txt **Change Type:** modified **Context:** PR #27355: Check MS Media Foundation availability in G-API too **Review Line:** 389 **Code Changes:** ```diff +if(HAVE_MSMF AND OPENCV_GAPI_MSMF) + if(TARGET opencv_test_gapi) + ocv_target_compile_definitions(opencv_test_gapi PRIVATE -DHAVE_GAPI_MSMF) + endif() + ocv_target_compile_definitions(${the_module} PRIVATE -DHAVE_GAPI_MSMF) + ocv_target_link_libraries(${the_module} PRIVATE ocv.3rdparty.msmf) +endif() + if(HAVE_DIRECTML) ocv_target_compile_definitions(${the_module} PRIVATE HAVE_DIRECTML=1) endif() ```
`HAVE_MSMF` already comes with target `ocv.3rdparty.msmf`
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_math.cpp **Change Type:** modified **Context:** PR #27331: Add tests for solveCubic **Review Line:** 2539 **Code Changes:** ```diff + EXPECT_NEAR(roots[0], 1., 1e-8); + EXPECT_NEAR(roots[1], 2., 1e-8); + if (num_roots == 3) + { + EXPECT_NEAR(roots[2], 2., 1e-8); + } + } + + { + const std::vector<double> coeffs{2., -12., 22., -12.}; + std::vector<double> roots; ```
I would expect deterministic behavour on amount of solutions on all platforms. Is not 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_math.cpp **Change Type:** modified **Context:** PR #27331: Add tests for solveCubic **Review Line:** 2585 **Code Changes:** ```diff + EXPECT_NEAR(roots[0], 1., 1e-8); + EXPECT_NEAR(roots[1], 2., 1e-8); + if (num_roots == 3) + { + EXPECT_NEAR(roots[2], 2., 1e-8); + } + } + + { + const std::vector<double> coeffs{-6., 11., -6.}; + std::vector<double> roots; ```
The same issue.
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_math.cpp **Change Type:** modified **Context:** PR #27331: Add tests for solveCubic **Review Line:** 2539 **Code Changes:** ```diff + EXPECT_NEAR(roots[0], 1., 1e-8); + EXPECT_NEAR(roots[1], 2., 1e-8); + if (num_roots == 3) + { + EXPECT_NEAR(roots[2], 2., 1e-8); + } + } + + { + const std::vector<double> coeffs{2., -12., 22., -12.}; + std::vector<double> roots; ```
The test is about: ``` 2 * x^3 - 10 * x^2 + 16 * x - 8 = 2 * (x - 1) * (x - 2)^2 = 0 ``` So, it has `2` roots - `1` and `2` (with multiplicity equal to `2`). But on some platforms due to round-off error implementation says that it has `3` roots - `1`, `2 + eps1` and `2 + eps2` (so, it gives `2` roots almost equal to `2` but considers them different). Considering that this is a numerical algorithm, both answers are adequate and not so different P.S. Implementation does not take round-off error into account at all (it always compare doubles with equality sign (without any tolerances)). Taking round-off error into account may lead to a very strong change in behavior in some cases (e.g., change like https://github.com/pi-squared/opencv/commit/665c45e47cde437bad4b549b875f53e0b7a8f631 will lead to that some cubic equations now will be assumed as quadratic (and roots can change dramatically)) There is no winning option here - so that in all cases the implementation will behave as expected (in some cases small coefficient will mean round-off error and that it is equal to zero, in another - that it is small non-zero coefficient)
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** hal/riscv-rvv/src/imgproc/histogram.cpp **Change Type:** modified **Context:** PR #27332: hal/imgproc: add hal for calcHist and implement in hal/riscv-rvv **Review Line:** 268 **Code Changes:** ```diff + } + } + p0 += step0; + } + } + } + + if (accumulate) { + cvt32s32f_add32f(ihist+1, hist_data, hist_size); + } else { + std::memset(hist_data, 0, sizeof(float)*hist_size); ```
It makes sense to return not_implemented for other depth. Just in case of new types support in 5.x.