instruction
stringclasses 9
values | input
stringlengths 279
5.47k
| output
stringlengths 6
9.58k
|
|---|---|---|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/integral.hpp
**Change Type:** added
**Context:** PR #27060: [hal_rvv] Add cv::integral implementation and more types of input for test
**Code Changes:**
```diff
@@ -0,0 +1,173 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+// Copyright (C) 2025, Institute of Software, Chinese Academy of Sciences.
+
+#ifndef OPENCV_HAL_RVV_INTEGRAL_HPP_INCLUDED
+#define OPENCV_HAL_RVV_INTEGRAL_HPP_INCLUDED
+
```
|
Do not expose the `struct rvv` into `cv_hal_rvv` namespace, see https://github.com/opencv/opencv/pull/26865#discussion_r1977097854.
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/types.hpp
**Change Type:** modified
**Context:** PR #27060: [hal_rvv] Add cv::integral implementation and more types of input for test
**Review Line:** 705
**Code Changes:**
```diff
+ template <size_t idx> \
+ inline void vset(TWO::VecType v, ONE::VecType val) { \
+ __riscv_vset_v_##TYPE##ONE_LMUL##_##TYPE##TWO_LMUL(v, idx, val); \
+ } \
+ inline TWO::VecType vcreate(ONE::VecType v0, ONE::VecType v1) { \
+ return __riscv_vcreate_v_##TYPE##ONE_LMUL##_##TYPE##TWO_LMUL(v0, v1); \
+ }
+#endif
+
+HAL_RVV_GROUP(RVV_I8M1, RVV_I8M2, i8, m1, m2)
+HAL_RVV_GROUP(RVV_I8M2, RVV_I8M4, i8, m2, m4)
```
|
`vcreate` is not supported in clang 17. Use this instead. ```cpp vuint8m2_t v{}; v = __riscv_vset_v_u8m1_u8m2(v, 0, x); v = __riscv_vset_v_u8m1_u8m2(v, 1, y); ```
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/types.hpp
**Change Type:** modified
**Context:** PR #27060: [hal_rvv] Add cv::integral implementation and more types of input for test
**Review Line:** 705
**Code Changes:**
```diff
+ template <size_t idx> \
+ inline void vset(TWO::VecType v, ONE::VecType val) { \
+ __riscv_vset_v_##TYPE##ONE_LMUL##_##TYPE##TWO_LMUL(v, idx, val); \
+ } \
+ inline TWO::VecType vcreate(ONE::VecType v0, ONE::VecType v1) { \
+ return __riscv_vcreate_v_##TYPE##ONE_LMUL##_##TYPE##TWO_LMUL(v0, v1); \
+ }
+#endif
+
+HAL_RVV_GROUP(RVV_I8M1, RVV_I8M2, i8, m1, m2)
+HAL_RVV_GROUP(RVV_I8M2, RVV_I8M4, i8, m2, m4)
```
|
I prefer both. Note that `__riscv_vset` needs an immediate number for the second argument.
|
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/libtiff/tif_hash_set.c
**Change Type:** modified
**Context:** PR #27343: build: fix more warnings from recent gcc versions after #27337
**Review Line:** 370
**Code Changes:**
```diff
@@ -367,7 +367,7 @@ static bool TIFFHashSetRehash(TIFFHashSet *set)
{
int nNewAllocatedSize = anPrimes[set->nIndiceAllocatedSize];
TIFFList **newTabList =
- (TIFFList **)(calloc(sizeof(TIFFList *), nNewAllocatedSize));
+ (TIFFList **)(calloc(nNewAllocatedSize, sizeof(TIFFList *)));
if (newTabList == NULL)
return false;
#ifdef HASH_DEBUG
```
|
Upstream of libtiff has fixed this: https://gitlab.com/libtiff/libtiff/-/blob/master/libtiff/tif_hash_set.c#L370
|
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/libtiff/tif_hash_set.c
**Change Type:** modified
**Context:** PR #27343: build: fix more warnings from recent gcc versions after #27337
**Review Line:** 149
**Code Changes:**
```diff
@@ -146,7 +146,7 @@ TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc,
set->fnEqualFunc = fnEqualFunc ? fnEqualFunc : TIFFHashSetEqualPointer;
set->fnFreeEltFunc = fnFreeEltFunc;
set->nSize = 0;
- set->tabList = (TIFFList **)(calloc(sizeof(TIFFList *), 53));
+ set->tabList = (TIFFList **)(calloc(53, sizeof(TIFFList *)));
if (set->tabList == NULL)
{
free(set);
@@ -367,7 +367,7 @@ static bool TIFFHashSetRehash(TIFFHashSet *set)
{
```
|
Upstream of libtiff has fixed this: https://gitlab.com/libtiff/libtiff/-/blob/master/libtiff/tif_hash_set.c#L149
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/dnn/src/legacy_backend.hpp
**Change Type:** modified
**Context:** PR #27307: TFLite fixes for Face Blendshapes V2
**Review Line:** 216
**Code Changes:**
```diff
@@ -213,6 +213,7 @@ struct BlobManager
{
reuse(bestBlobPin, lp);
dst = bestBlob.reshape(1, 1).colRange(0, targetTotal).reshape(1, shape);
+ dst.dims = shape.size();
return;
}
}
```
|
Probably, make sense to move to a separate PR?
|
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/core/include/opencv2/core/hal/intrin.hpp
**Change Type:** modified
**Context:** PR #26109: Replace operators with wrapper functions on universal intrinsics backends
**Code Changes:**
```diff
@@ -717,44 +717,70 @@ namespace CV__SIMD_NAMESPACE {
/** @brief SIMD processing state cleanup call */
inline void vx_cleanup() { VXPREFIX(_cleanup)(); }
-#if !CV_SIMD_SCALABLE && !(CV_NEON && !defined(CV_FORCE_SIMD128_CPP))
+#if !CV_SIMD_SCALABLE
// Compatibility layer
-
+#if !(CV_NEON && !defined(CV_FORCE_SIMD128_CPP))
template<typename T> struct VTraits {
```
|
This function causes a compilation error, which recursively calls itself. But it should call the `v_add` function from other backends. This function works well but fails with intrin_cpp.hpp`. ``` In file included from /home/wanli/workspace/opencv_china/opencv/modules/core/test/test_intrin128.simd.hpp:7, from /home/wanli/workspace/opencv_china/opencv/modules/core/test/test_intrin_emulator.cpp:14: /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp: In instantiation of ‘cv::hal_EMULATOR_CPP::simd128_cpp::v_uint8 cv::hal_EMULATOR_CPP::simd128_cpp::v_add(const v_uint8&, const v_uint8&, const Args& ...) [with Args = {}; v_uint8 = cv::hal_EMULATOR_CPP::v_reg<unsigned char, 16>]’: /home/wanli/workspace/opencv_china/opencv/modules/core/test/test_intrin_utils.hpp:491:29: required from ‘opencv_test::hal::intrin128::opt_EMULATOR_CPP::TheTest<R>& opencv_test::hal::intrin128::opt_EMULATOR_CPP::TheTest<R>::test_addsub() [with R = cv::hal_EMULATOR_CPP::v_reg<unsigned char, 16>]’ /home/wanli/workspace/opencv_china/opencv/modules/core/test/test_intrin_utils.hpp:1923:21: required from here /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:732:21: error: no matching function for call to ‘v_add(cv::hal_EMULATOR_CPP::simd128_cpp::v_uint8)’ 732 | return v_add(v_add(f1, f2), vf...); \ | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:735:5: note: in expansion of macro ‘OPENCV_HAL_WRAP_BIN_OP_ADDSUB’ 735 | OPENCV_HAL_WRAP_BIN_OP_ADDSUB(v_uint8) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:731:19: note: candidate: ‘template<class ... Args> cv::hal_EMULATOR_CPP::simd128_cpp::v_uint8 cv::hal_EMULATOR_CPP::simd128_cpp::v_add(const v_uint8&, const v_uint8&, const Args& ...)’ 731 | inline _Tpvec v_add(const _Tpvec& f1, const _Tpvec& f2, const Args&... vf) { \ | ^~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:735:5: note: in expansion of macro ‘OPENCV_HAL_WRAP_BIN_OP_ADDSUB’ 735 | OPENCV_HAL_WRAP_BIN_OP_ADDSUB(v_uint8) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:731:19: note: template argument deduction/substitution failed: 731 | inline _Tpvec v_add(const _Tpvec& f1, const _Tpvec& f2, const Args&... vf) { \ | ^~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:735:5: note: in expansion of macro ‘OPENCV_HAL_WRAP_BIN_OP_ADDSUB’ 735 | OPENCV_HAL_WRAP_BIN_OP_ADDSUB(v_uint8) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:732:21: note: candidate expects at least 2 arguments, 1 provided 732 | return v_add(v_add(f1, f2), vf...); \ | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:735:5: note: in expansion of macro ‘OPENCV_HAL_WRAP_BIN_OP_ADDSUB’ 735 | OPENCV_HAL_WRAP_BIN_OP_ADDSUB(v_uint8) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:247: /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:576:55: note: candidate: ‘template<class _Tp, int n> cv::hal_EMULATOR_CPP::v_reg<_Tp, n> cv::hal_EMULATOR_CPP::v_add(const v_reg<_Tp, n>&, const v_reg<_Tp, n>&)’ 576 | template<typename _Tp, int n> CV_INLINE v_reg<_Tp, n> v_add(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b); | ^~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:576:55: note: template argument deduction/substitution failed: /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:732:21: note: candidate expects 2 arguments, 1 provided 732 | return v_add(v_add(f1, f2), vf...); \ | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin.hpp:735:5: note: in expansion of macro ‘OPENCV_HAL_WRAP_BIN_OP_ADDSUB’ 735 | OPENCV_HAL_WRAP_BIN_OP_ADDSUB(v_uint8) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core.hpp:52, from /home/wanli/workspace/opencv_china/opencv/modules/ts/include/opencv2/ts.hpp:10, from /home/wanli/workspace/opencv_china/opencv/modules/core/test/test_precomp.hpp:9, from /home/wanli/workspace/opencv_china/opencv/modules/core/test/test_intrin_emulator.cpp:4: /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:647:31: note: candidate: ‘template<int n> cv::hal_EMULATOR_CPP::v_reg<unsigned char, n> cv::hal_EMULATOR_CPP::v_add(const v_reg<unsigned char, n>&, const v_reg<unsigned char, n>&)’ 647 | CV__HAL_INTRIN_IMPL_BIN_OP(+, v_add) | ^~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/cvdef.h:79:24: note: in definition of macro ‘__CV_EXPAND’ 79 | #define __CV_EXPAND(x) x | ^ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:618:13: note: in expansion of macro ‘CV__HAL_INTRIN_IMPL_BIN_OP_’ 618 | __CV_EXPAND(macro_name(uchar, __VA_ARGS__)) \ | ^~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:632:1: note: in expansion of macro ‘CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES’ 632 | CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES(macro_name, __VA_ARGS__) \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:645:50: note: in expansion of macro ‘CV__HAL_INTRIN_EXPAND_WITH_ALL_TYPES’ 645 | #define CV__HAL_INTRIN_IMPL_BIN_OP(bin_op, func) CV__HAL_INTRIN_EXPAND_WITH_ALL_TYPES(CV__HAL_INTRIN_IMPL_BIN_OP_, bin_op, func) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:647:1: note: in expansion of macro ‘CV__HAL_INTRIN_IMPL_BIN_OP’ 647 | CV__HAL_INTRIN_IMPL_BIN_OP(+, v_add) | ^~~~~~~~~~~~~~~~~~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:647:31: note: template argument deduction/substitution failed: 647 | CV__HAL_INTRIN_IMPL_BIN_OP(+, v_add) | ^~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/cvdef.h:79:24: note: in definition of macro ‘__CV_EXPAND’ 79 | #define __CV_EXPAND(x) x | ^ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:618:13: note: in expansion of macro ‘CV__HAL_INTRIN_IMPL_BIN_OP_’ 618 | __CV_EXPAND(macro_name(uchar, __VA_ARGS__)) \ | ^~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:632:1: note: in expansion of macro ‘CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES’ 632 | CV__HAL_INTRIN_EXPAND_WITH_INTEGER_TYPES(macro_name, __VA_ARGS__) \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/wanli/workspace/opencv_china/opencv/modules/core/include/opencv2/core/hal/intrin_cpp.hpp:645:50: note: in expansion of macro ‘CV__HAL_INTRIN_EXPAND_WITH_ALL_TYPES’ 645 | #define CV__HAL_INTRIN_IMPL_BIN_OP(bin_op, func) CV__HAL_INTRIN_EXPAND_WITH_ALL_TYPES(CV__HAL_INTRIN_IMPL_BIN_OP_, bin_op, func) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ................. ```
|
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_wasm.hpp
**Change Type:** modified
**Context:** PR #26109: Replace operators with wrapper functions on universal intrinsics backends
**Review Line:** 1697
**Code Changes:**
```diff
}
inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b)
{
@@ -1703,19 +1696,19 @@ inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b)
v_expand(v_absdiff(a, b), l16, h16);
v_expand(l16, l16_l32, l16_h32);
v_expand(h16, h16_l32, h16_h32);
- return v_reduce_sum(l16_l32+l16_h32+h16_l32+h16_h32);
+ return v_reduce_sum(v_add(v_add(l16_l32, l16_h32), v_add(h16_l32, h16_h32)));
}
inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b)
```
|
you can reduce amount of operations here like (a+b) + (c+d).
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/core/test/test_intrin_utils.hpp
**Change Type:** modified
**Context:** PR #27337: build: fix warnings from recent gcc versions
**Code Changes:**
```diff
@@ -24,6 +24,17 @@ void test_hal_intrin_float16();
//==================================================================================================
+#if defined (__GNUC__) && defined(__has_warning)
+ #if __has_warning("-Wmaybe-uninitialized")
+ #define CV_DISABLE_GCC_MAYBE_UNINITIALIZED_WARNINGS
+ #endif
+#endif
+
```
|
Conditions are the same. Is it a typo?
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #27297: imgcodecs: png: add log if first chunk is not IHDR
**Review Line:** 297
**Code Changes:**
```diff
+ {
+ CV_LOG_ERROR(NULL, "CgBI chunk (Apple private) found as the first chunk. IHDR is expected.");
+ return false;
+ }
if (id != id_IHDR)
+ {
+ CV_LOG_ERROR(NULL, "IHDR chunk shall be first. This data may be broken or malformed.");
return false;
+ }
m_is_fcTL_loaded = false;
```
|
chatGPT suggests ``` if (id == id_CgBI) { CV_LOG_ERROR(NULL, "CgBI chunk (Apple private) found as the first chunk. IHDR is expected."); } else { CV_LOG_ERROR(NULL, "IHDR chunk shall be first. This data may be broken or malformed."); } ```
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement
**Code Changes:**
```diff
@@ -13,6 +13,7 @@
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
#else
```
|
I propose to replace it with if..else or more usual `offset = ? : ; j+= offset;`
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement
**Code Changes:**
```diff
@@ -13,6 +13,7 @@
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
#else
```
|
The same remark on condition.
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement
**Code Changes:**
```diff
@@ -13,6 +13,7 @@
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
#else
```
|
This has been modified as well.
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement
**Code Changes:**
```diff
@@ -13,6 +13,7 @@
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
#else
```
|
What if _dst.cols <= 2*nlanes? Just skipped?
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement
**Code Changes:**
```diff
@@ -13,6 +13,7 @@
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
#else
```
|
If you meant to take care of the tail with vectorization, you should take a look at this trick (line 161 to 166): https://github.com/opencv/opencv/blob/cb87f05e4bbae077e266d15b571ed8b23598d265/modules/core/src/convert.simd.hpp#L157-L171
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement
**Code Changes:**
```diff
@@ -13,6 +13,7 @@
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
#else
```
|
this will not be skipped. when cols <= 2* lanes, - limit gets increased after this loop. "limit = size.width" - then it gets done in "for( ; j < limit; j++ )" loop above.
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement
**Code Changes:**
```diff
@@ -13,6 +13,7 @@
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
#else
```
|
I meant to handle the tail with the same main vector path by allowing overwriting in the next row.
|
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/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement
**Code Changes:**
```diff
@@ -13,6 +13,7 @@
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
#else
```
|
Check this: ```.diff diff --git a/modules/imgproc/src/median_blur.simd.hpp b/modules/imgproc/src/median_blur.simd.hpp index 7cc0aa693c..6185f5f9fd 100644 --- a/modules/imgproc/src/median_blur.simd.hpp +++ b/modules/imgproc/src/median_blur.simd.hpp @@ -693,8 +693,15 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m ) #else int nlanes = 1; #endif - for( ; j <= size.width - nlanes - cn; j += nlanes ) + for (; j < size.width - cn; j += nlanes) { + if ( j > size.width - cn - nlanes ) { + if (j == 0 || src == dst) { + break; + } + j = size.width - cn - nlanes; + } + VT p0 = vop.load(row0+j-cn), p1 = vop.load(row0+j), p2 = vop.load(row0+j+cn); VT p3 = vop.load(row1+j-cn), p4 = vop.load(row1+j), p5 = vop.load(row1+j+cn); VT p6 = vop.load(row2+j-cn), p7 = vop.load(row2+j), p8 = vop.load(row2+j+cn); @@ -798,8 +805,17 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m ) #else int nlanes = 1; #endif - for( ; j <= size.width - nlanes - cn*2; j += nlanes ) + // for( ; j <= size.width - nlanes - cn*2; j += nlanes ) + // { + for (; j < size.width - cn*2; j += nlanes) { + if ( j > size.width - cn*2 - nlanes ) { + if (j == 0 || src == dst) { + break; + } + j = size.width - cn*2 - nlanes; + } + VT p0 = vop.load(row[0]+j-cn*2), p5 = vop.load(row[1]+j-cn*2), p10 = vop.load(row[2]+j-cn*2), p15 = vop.load(row[3]+j-cn*2), p20 = vop.load(row[4]+j-cn*2); VT p1 = vop.load(row[0]+j-cn*1), p6 = vop.load(row[1]+j-cn*1), p11 = vop.load(row[2]+j-cn*1), p16 = vop.load(row[3]+j-cn*1), p21 = vop.load(row[4]+j-cn*1); VT p2 = vop.load(row[0]+j-cn*0), p7 = vop.load(row[1]+j-cn*0), p12 = vop.load(row[2]+j-cn*0), p17 = vop.load(row[3]+j-cn*0), p22 = vop.load(row[4]+j-cn*0); ``` I was able to achieve a better performance on higher input resolution on my host with i7-12700K. Perf: <details> ``` Geometric mean (ms) Name of Test medianBlur-base medianBlur-patch-amd medianBlur-patch-fyt medianBlur-patch-amd medianBlur-patch-fyt vs vs medianBlur-base medianBlur-base (x-factor) (x-factor) medianBlur::Size_MatType_kSize::(127x61, 8UC1, 3) 0.020 0.002 0.003 8.60 5.73 medianBlur::Size_MatType_kSize::(127x61, 8UC1, 5) 0.115 0.021 0.041 5.43 2.76 medianBlur::Size_MatType_kSize::(127x61, 16UC1, 3) 0.005 0.002 0.002 2.30 2.27 medianBlur::Size_MatType_kSize::(127x61, 16UC1, 5) 0.177 0.024 0.018 7.47 9.85 medianBlur::Size_MatType_kSize::(127x61, 16SC1, 3) 0.005 0.003 0.002 1.56 2.56 medianBlur::Size_MatType_kSize::(127x61, 16SC1, 5) 0.177 0.021 0.018 8.56 9.92 medianBlur::Size_MatType_kSize::(127x61, 32FC1, 3) 0.007 0.005 0.004 1.51 1.93 medianBlur::Size_MatType_kSize::(127x61, 32FC1, 5) 0.039 0.033 0.033 1.19 1.19 medianBlur::Size_MatType_kSize::(127x61, 8UC4, 3) 0.020 0.008 0.020 2.44 1.03 medianBlur::Size_MatType_kSize::(127x61, 8UC4, 5) 0.118 0.082 0.097 1.44 1.22 medianBlur::Size_MatType_kSize::(320x240, 8UC1, 3) 0.084 0.013 0.012 6.57 7.10 medianBlur::Size_MatType_kSize::(320x240, 8UC1, 5) 0.502 0.108 0.107 4.66 4.70 medianBlur::Size_MatType_kSize::(320x240, 16UC1, 3) 0.091 0.020 0.021 4.56 4.26 medianBlur::Size_MatType_kSize::(320x240, 16UC1, 5) 0.851 0.270 0.272 3.15 3.13 medianBlur::Size_MatType_kSize::(320x240, 16SC1, 3) 0.091 0.019 0.018 4.69 5.09 medianBlur::Size_MatType_kSize::(320x240, 16SC1, 5) 0.831 0.269 0.255 3.09 3.25 medianBlur::Size_MatType_kSize::(320x240, 32FC1, 3) 0.040 0.033 0.033 1.20 1.21 medianBlur::Size_MatType_kSize::(320x240, 32FC1, 5) 0.289 0.260 0.259 1.11 1.12 medianBlur::Size_MatType_kSize::(320x240, 8UC4, 3) 0.106 0.058 0.049 1.84 2.17 medianBlur::Size_MatType_kSize::(320x240, 8UC4, 5) 0.633 0.443 0.425 1.43 1.49 medianBlur::Size_MatType_kSize::(640x480, 8UC1, 3) 0.176 0.040 0.038 4.40 4.62 medianBlur::Size_MatType_kSize::(640x480, 8UC1, 5) 1.064 0.329 0.311 3.24 3.42 medianBlur::Size_MatType_kSize::(640x480, 16UC1, 3) 0.235 0.087 0.072 2.71 3.25 medianBlur::Size_MatType_kSize::(640x480, 16UC1, 5) 1.873 0.745 0.728 2.51 2.57 medianBlur::Size_MatType_kSize::(640x480, 16SC1, 3) 0.240 0.086 0.073 2.79 3.27 medianBlur::Size_MatType_kSize::(640x480, 16SC1, 5) 1.877 0.737 0.724 2.55 2.59 medianBlur::Size_MatType_kSize::(640x480, 32FC1, 3) 0.143 0.125 0.126 1.14 1.13 medianBlur::Size_MatType_kSize::(640x480, 32FC1, 5) 0.981 0.936 0.944 1.05 1.04 medianBlur::Size_MatType_kSize::(640x480, 8UC4, 3) 0.265 0.199 0.169 1.34 1.57 medianBlur::Size_MatType_kSize::(640x480, 8UC4, 5) 1.639 1.321 1.257 1.24 1.30 medianBlur::Size_MatType_kSize::(1280x720, 8UC1, 3) 0.313 0.128 0.105 2.45 2.99 medianBlur::Size_MatType_kSize::(1280x720, 8UC1, 5) 1.864 0.806 0.765 2.31 2.44 medianBlur::Size_MatType_kSize::(1280x720, 16UC1, 3) 0.455 0.246 0.198 1.85 2.30 medianBlur::Size_MatType_kSize::(1280x720, 16UC1, 5) 3.384 1.757 1.672 1.93 2.02 medianBlur::Size_MatType_kSize::(1280x720, 16SC1, 3) 0.454 0.242 0.199 1.88 2.29 medianBlur::Size_MatType_kSize::(1280x720, 16SC1, 5) 3.379 1.751 1.684 1.93 2.01 medianBlur::Size_MatType_kSize::(1280x720, 32FC1, 3) 0.399 0.370 0.364 1.08 1.10 medianBlur::Size_MatType_kSize::(1280x720, 32FC1, 5) 2.729 2.695 2.675 1.01 1.02 medianBlur::Size_MatType_kSize::(1280x720, 8UC4, 3) 0.572 0.507 0.416 1.13 1.38 medianBlur::Size_MatType_kSize::(1280x720, 8UC4, 5) 3.614 3.223 3.052 1.12 1.18 ``` </details>
|
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/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement
**Code Changes:**
```diff
@@ -13,6 +13,7 @@
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
#else
```
|
Well, the starting index for j entering this loop should be cn (m=3) or cn*2 (m=5). So, the corrected version is as below. ```.diff diff --git a/modules/imgproc/src/median_blur.simd.hpp b/modules/imgproc/src/median_blur.simd.hpp index 7cc0aa693c..6185f5f9fd 100644 --- a/modules/imgproc/src/median_blur.simd.hpp +++ b/modules/imgproc/src/median_blur.simd.hpp @@ -693,8 +693,15 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m ) #else int nlanes = 1; #endif - for( ; j <= size.width - nlanes - cn; j += nlanes ) + for (; j < size.width - cn; j += nlanes) { + if ( j > size.width - cn - nlanes ) { + if (j == cn || src == dst) { + break; + } + j = size.width - cn - nlanes; + } + VT p0 = vop.load(row0+j-cn), p1 = vop.load(row0+j), p2 = vop.load(row0+j+cn); VT p3 = vop.load(row1+j-cn), p4 = vop.load(row1+j), p5 = vop.load(row1+j+cn); VT p6 = vop.load(row2+j-cn), p7 = vop.load(row2+j), p8 = vop.load(row2+j+cn); @@ -798,8 +805,17 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m ) #else int nlanes = 1; #endif - for( ; j <= size.width - nlanes - cn*2; j += nlanes ) + // for( ; j <= size.width - nlanes - cn*2; j += nlanes ) + // { + for (; j < size.width - cn*2; j += nlanes) { + if ( j > size.width - cn*2 - nlanes ) { + if (j == cn*2 || src == dst) { + break; + } + j = size.width - cn*2 - nlanes; + } + VT p0 = vop.load(row[0]+j-cn*2), p5 = vop.load(row[1]+j-cn*2), p10 = vop.load(row[2]+j-cn*2), p15 = vop.load(row[3]+j-cn*2), p20 = vop.load(row[4]+j-cn*2); VT p1 = vop.load(row[0]+j-cn*1), p6 = vop.load(row[1]+j-cn*1), p11 = vop.load(row[2]+j-cn*1), p16 = vop.load(row[3]+j-cn*1), p21 = vop.load(row[4]+j-cn*1); VT p2 = vop.load(row[0]+j-cn*0), p7 = vop.load(row[1]+j-cn*0), p12 = vop.load(row[2]+j-cn*0), p17 = vop.load(row[3]+j-cn*0), p22 = vop.load(row[4]+j-cn*0); ``` Performance is the same.
|
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/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement
**Code Changes:**
```diff
@@ -13,6 +13,7 @@
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
#else
```
|
Adjusting the start index fixes the issue. Yes, performance is the same as before. Do you wish to commit/author this? This tail handling method is better.
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/imgproc/src/median_blur.simd.hpp
**Change Type:** modified
**Context:** PR #27299: imgproc: medianblur: Performance improvement
**Code Changes:**
```diff
@@ -13,6 +13,7 @@
// Copyright (C) 2000-2008, 2018, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Copyright (C) 2014-2015, Itseez Inc., all rights reserved.
+// Copyright (C) 2025, Advanced Micro Devices, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
@@ -693,8 +694,16 @@ medianBlur_SortNet( const Mat& _src, Mat& _dst, int m )
#else
```
|
This trick is originally from Halide, IIRC. It is widely used in the codebase. I suggest to use the same to keep consistency and readability. You are welcome to do the 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/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Code Changes:**
```diff
@@ -726,8 +726,14 @@ class CV_EXPORTS_W IStreamReader
public:
virtual ~IStreamReader();
- /** @brief Read bytes from stream */
- virtual long long read(char* buffer, long long size) = 0;
+ /** @brief Read bytes from stream
+ *
+ * @param buffer already allocated buffer of at least @p size bytes
+ * @param size maximum number of bytes to read
```
|
I don't know if it may break ObjC bindings introduced in https://github.com/opencv/opencv/pull/25584
|
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/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Code Changes:**
```diff
@@ -726,8 +726,14 @@ class CV_EXPORTS_W IStreamReader
public:
virtual ~IStreamReader();
- /** @brief Read bytes from stream */
- virtual long long read(char* buffer, long long size) = 0;
+ /** @brief Read bytes from stream
+ *
+ * @param buffer already allocated buffer of at least @p size bytes
+ * @param size maximum number of bytes to read
```
|
IMHO, It should be kept wrapped as arguments of binding functions rely on this type. What is the error? Can we override behavior in java/gen_dict.json?
|
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/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Code Changes:**
```diff
@@ -726,8 +726,14 @@ class CV_EXPORTS_W IStreamReader
public:
virtual ~IStreamReader();
- /** @brief Read bytes from stream */
- virtual long long read(char* buffer, long long size) = 0;
+ /** @brief Read bytes from stream
+ *
+ * @param buffer already allocated buffer of at least @p size bytes
+ * @param size maximum number of bytes to read
```
|
Without `CV_EXPORTS_W` we also loose Python type hints.
|
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/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Code Changes:**
```diff
@@ -726,8 +726,14 @@ class CV_EXPORTS_W IStreamReader
public:
virtual ~IStreamReader();
- /** @brief Read bytes from stream */
- virtual long long read(char* buffer, long long size) = 0;
+ /** @brief Read bytes from stream
+ *
+ * @param buffer already allocated buffer of at least @p size bytes
+ * @param size maximum number of bytes to read
```
|
There is a minor error in gen_java but I were able to fix it. Let me try use a generated bindings again.
|
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 #27284: Java VideoCapture buffered stream constructor
**Code Changes:**
```diff
@@ -1,27 +1,41 @@
package org.opencv.test.videoio;
import java.util.List;
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import org.opencv.core.Mat;
```
|
What is `0` used for?
|
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 #27284: Java VideoCapture buffered stream constructor
**Code Changes:**
```diff
@@ -1,27 +1,41 @@
package org.opencv.test.videoio;
import java.util.List;
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import org.opencv.core.Mat;
```
|
Native object address, not used actually. Shall we hide it?
|
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/misc/java/test/VideoCaptureTest.java
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 106
**Code Changes:**
```diff
+
+ IStreamReader stream = new IStreamReader()
+ {
+ @Override
+ public long read(byte[] buffer, long size)
+ {
+ assertEquals(buffer.length, size);
+ try
+ {
+ return Math.max(f.read(buffer), 0);
+ }
```
|
I propose to add check if buffer length equal to size. Just to highlight bugs.
|
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/misc/java/src/cpp/videoio_converters.hpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 12
**Code Changes:**
```diff
+#include "opencv2/videoio/videoio.hpp"
+
+class JavaStreamReader : public cv::IStreamReader
+{
+public:
+ JavaStreamReader(JNIEnv* env, jobject obj);
+ ~JavaStreamReader();
+ long long read(char* buffer, long long size) CV_OVERRIDE;
+ long long seek(long long offset, int way) CV_OVERRIDE;
+
+private:
```
|
> The JNIEnv is used for thread-local storage. For this reason, you cannot share a JNIEnv between threads. If a piece of code has no other way to get its JNIEnv, you should share the JavaVM, and use GetEnv to discover the thread's JNIEnv. (Assuming it has one; see AttachCurrentThread below.) Source: https://developer.android.com/training/articles/perf-jni?hl=en Looks like the adapter should handle the threading model in smarter way.
|
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 #27284: Java VideoCapture buffered stream constructor
**Code Changes:**
```diff
@@ -1,27 +1,41 @@
package org.opencv.test.videoio;
import java.util.List;
+import java.io.File;
+import java.io.RandomAccessFile;
+import java.io.IOException;
+import java.io.FileNotFoundException;
+import org.opencv.core.Mat;
```
|
Fixed by `ManualFuncs`
|
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/misc/java/test/VideoCaptureTest.java
**Change Type:** modified
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 106
**Code Changes:**
```diff
+
+ IStreamReader stream = new IStreamReader()
+ {
+ @Override
+ public long read(byte[] buffer, long size)
+ {
+ assertEquals(buffer.length, size);
+ try
+ {
+ return Math.max(f.read(buffer), 0);
+ }
```
|
Sure. Also make sense to highlight in docstring that it's pre-allocated
|
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 58
**Code Changes:**
```diff
+ if (!m_read)
+ return 0;
+ JNIEnvHandler handler(vm);
+ JNIEnv* env = handler.env;
+ if (!env)
+ return 0;
+ jbyteArray jBuffer = env->NewByteArray(static_cast<jsize>(size));
+ if (!jBuffer)
+ return 0;
+ jlong res = env->CallLongMethod(obj, m_read, jBuffer, size);
+ env->GetByteArrayRegion(jBuffer, 0, static_cast<jsize>(size), reinterpret_cast<jbyte*>(buffer));
```
|
In general these callbacks are called from FFmpeg non-Java threads. `JNIEnv` may be not available for native threads. Should we use `AttachCurrentThread` in that case instead of `return 0` ? Docs: > For example, a thread started with pthread_create() or std::thread can be attached using the AttachCurrentThread() or AttachCurrentThreadAsDaemon() functions. Until a thread is attached, it has no JNIEnv, and cannot make JNI calls. But there is dedicated issue with detaching of such threads.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 58
**Code Changes:**
```diff
+ if (!m_read)
+ return 0;
+ JNIEnvHandler handler(vm);
+ JNIEnv* env = handler.env;
+ if (!env)
+ return 0;
+ jbyteArray jBuffer = env->NewByteArray(static_cast<jsize>(size));
+ if (!jBuffer)
+ return 0;
+ jlong res = env->CallLongMethod(obj, m_read, jBuffer, size);
+ env->GetByteArrayRegion(jBuffer, 0, static_cast<jsize>(size), reinterpret_cast<jbyte*>(buffer));
```
|
Added `AttachCurrentThread` if `GetEnv` returns specific `JNI_EDETACHED` error.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 58
**Code Changes:**
```diff
+ if (!m_read)
+ return 0;
+ JNIEnvHandler handler(vm);
+ JNIEnv* env = handler.env;
+ if (!env)
+ return 0;
+ jbyteArray jBuffer = env->NewByteArray(static_cast<jsize>(size));
+ if (!jBuffer)
+ return 0;
+ jlong res = env->CallLongMethod(obj, m_read, jBuffer, size);
+ env->GetByteArrayRegion(jBuffer, 0, static_cast<jsize>(size), reinterpret_cast<jbyte*>(buffer));
```
|
> But there is dedicated issue with detaching of such threads. Do you mean there is some bug in JNI or we also responsible for `DetachCurrentThread` 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/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 58
**Code Changes:**
```diff
+ if (!m_read)
+ return 0;
+ JNIEnvHandler handler(vm);
+ JNIEnv* env = handler.env;
+ if (!env)
+ return 0;
+ jbyteArray jBuffer = env->NewByteArray(static_cast<jsize>(size));
+ if (!jBuffer)
+ return 0;
+ jlong res = env->CallLongMethod(obj, m_read, jBuffer, size);
+ env->GetByteArrayRegion(jBuffer, 0, static_cast<jsize>(size), reinterpret_cast<jbyte*>(buffer));
```
|
> we also responsible this.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 24
**Code Changes:**
```diff
+
+ ~JNIEnvHandler()
+ {
+ if (env && detach)
+ {
+ vm->DetachCurrentThread();
+ }
+ }
+
+ JavaVM* vm;
+ JNIEnv* env = nullptr;
```
|
BTW, this could significantly slowdown execution through attach-detach on each callback 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/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 58
**Code Changes:**
```diff
+ if (!m_read)
+ return 0;
+ JNIEnvHandler handler(vm);
+ JNIEnv* env = handler.env;
+ if (!env)
+ return 0;
+ jbyteArray jBuffer = env->NewByteArray(static_cast<jsize>(size));
+ if (!jBuffer)
+ return 0;
+ jlong res = env->CallLongMethod(obj, m_read, jBuffer, size);
+ env->GetByteArrayRegion(jBuffer, 0, static_cast<jsize>(size), reinterpret_cast<jbyte*>(buffer));
```
|
Added in the latest commit for every read/seek 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/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 24
**Code Changes:**
```diff
+
+ ~JNIEnvHandler()
+ {
+ if (env && detach)
+ {
+ vm->DetachCurrentThread();
+ }
+ }
+
+ JavaVM* vm;
+ JNIEnv* env = nullptr;
```
|
I can move it to the wrapper class, just few minutes
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 24
**Code Changes:**
```diff
+
+ ~JNIEnvHandler()
+ {
+ if (env && detach)
+ {
+ vm->DetachCurrentThread();
+ }
+ }
+
+ JavaVM* vm;
+ JNIEnv* env = nullptr;
```
|
There is no guarantee that wrapper class uses the same thread,
|
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 24
**Code Changes:**
```diff
+
+ ~JNIEnvHandler()
+ {
+ if (env && detach)
+ {
+ vm->DetachCurrentThread();
+ }
+ }
+
+ JavaVM* vm;
+ JNIEnv* env = nullptr;
```
|
I propose to add some wording into docs that callbacks are called from the "creation thread" (this is how FFmpeg works for now), so we would not handle case with unknown "native threads" here.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/misc/java/src/cpp/videoio_converters.cpp
**Change Type:** added
**Context:** PR #27284: Java VideoCapture buffered stream constructor
**Review Line:** 24
**Code Changes:**
```diff
+
+ ~JNIEnvHandler()
+ {
+ if (env && detach)
+ {
+ vm->DetachCurrentThread();
+ }
+ }
+
+ JavaVM* vm;
+ JNIEnv* env = nullptr;
```
|
Agree, actually, I have concern that even if read/seek were used in the thread that requires `AttachCurrentThread`, the destructor of `JavaStreamReader` might be called in the main thread
|
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback.
|
**File:** hal/riscv-rvv/src/imgproc/common.hpp
**Change Type:** added
**Context:** PR #27301: hal/riscv-rvv: refactor the building process
**Code Changes:**
```diff
@@ -0,0 +1,76 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+//
+// Copyright (C) 2025, SpaceMIT Inc., all rights reserved.
+// Copyright (C) 2025, Institute of Software, Chinese Academy of Sciences.
+// Third party copyrights are property of their respective owners.
+
+#ifndef OPENCV_HAL_RVV_IMGPROC_COMMON_HPP_INCLUDED
```
|
Please use CV_HAL_BORDER_XXX constants from `modules/core/include/opencv2/core/hal/interface.h`
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** hal/ipp/src/sum_ipp.cpp
**Change Type:** added
**Context:** PR #27346: New HAL entry for cv::sum and IPP adoption
**Review Line:** 1
**Code Changes:**
```diff
@@ -0,0 +1,55 @@
+#include "ipp_hal_core.hpp"
+
+#include <opencv2/core.hpp>
+#include <opencv2/core/base.hpp>
+
+#if IPP_VERSION_X100 >= 700
```
|
License header.
|
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/sum.dispatch.cpp
**Change Type:** modified
**Context:** PR #27346: New HAL entry for cv::sum and IPP adoption
**Code Changes:**
```diff
@@ -10,14 +10,6 @@
#include "sum.simd.hpp"
#include "sum.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
-#ifndef OPENCV_IPP_SUM
-#undef HAVE_IPP
-#undef CV_IPP_RUN_FAST
-#define CV_IPP_RUN_FAST(f, ...)
-#undef CV_IPP_RUN
-#define CV_IPP_RUN(c, f, ...)
```
|
`CV_CheckLE` is preferable,
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** hal/ipp/src/sum_ipp.cpp
**Change Type:** added
**Context:** PR #27346: New HAL entry for cv::sum and IPP adoption
**Review Line:** 1
**Code Changes:**
```diff
@@ -0,0 +1,55 @@
+#include "ipp_hal_core.hpp"
+
+#include <opencv2/core.hpp>
+#include <opencv2/core/base.hpp>
+
+#if IPP_VERSION_X100 >= 700
```
|
There are no license headers in IPP HAL for now. I'll fix it with another PR.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/dnn/src/layers/attention_layer.cpp
**Change Type:** modified
**Context:** PR #27238: Rotary positional embeddings
**Code Changes:**
```diff
@@ -24,6 +24,105 @@ static void packWeight(size_t num_heads, size_t head_size, size_t input_hidden_s
}
}
+
+static void rotationKernel(
+ float* data, const float* rotation_table,
+ size_t seq_len, size_t d
+)
+{
```
|
No need to duplicate tail and scalar core. You can just close `#if (CV_SIMD || CV_SIMD_SCALABLE)` condition right after vectorized loop and extract `d` from ifdef.. In case, if vector intrinsics are not available, d = 0 and "tail" will be just main loop.
|
You are an expert OpenCV code reviewer specializing in performance optimization. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/dnn/src/layers/attention_layer.cpp
**Change Type:** modified
**Context:** PR #27238: Rotary positional embeddings
**Code Changes:**
```diff
@@ -24,6 +24,105 @@ static void packWeight(size_t num_heads, size_t head_size, size_t input_hidden_s
}
}
+
+static void rotationKernel(
+ float* data, const float* rotation_table,
+ size_t seq_len, size_t d
+)
+{
```
|
We have `v_sincos` to optimize it: https://docs.opencv.org/5.x/df/d91/group__core__hal__intrin.html#gaebe923bb2935eae727994a359c8c49c0
|
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/dnn/test/test_layers.cpp
**Change Type:** modified
**Context:** PR #27238: Rotary positional embeddings
**Review Line:** 746
**Code Changes:**
```diff
@@ -743,6 +743,32 @@ TEST_F(Layer_RNN_Test, get_set_test)
EXPECT_EQ(shape(outputs[1]), shape(nT, nS, nH));
}
+TEST(Layer_MHARoPe_Test_Accuracy_with_, Pytorch)
+{
+ Mat QKV = blobFromNPY(_tf("mha_rope.QKV.npy"));
+ Mat QKV_bias = blobFromNPY(_tf("mha_rope.QKV_bias.npy"));
+ std::vector<int> qkv_hidden_sizes = { 256, 256, 256 };
+ LayerParams mhaParams;
```
|
It'll be great, if the test imports ONNX, but not create the attention layer in code. It allows to check parser and ensure that the implementation handles feasible graph.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/dnn/src/layers/attention_layer.cpp
**Change Type:** modified
**Context:** PR #27238: Rotary positional embeddings
**Code Changes:**
```diff
@@ -24,6 +24,105 @@ static void packWeight(size_t num_heads, size_t head_size, size_t input_hidden_s
}
}
+
+static void rotationKernel(
+ float* data, const float* rotation_table,
+ size_t seq_len, size_t d
+)
+{
```
|
CV_SIMD_WIDTH is compile time constant. It may not work correctly with _SCALABLE branch. please use `VTraits<xxx>::max_nlanes` instead. For fixed-size SIMD it works in the same way.
|
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/dnn/test/test_layers.cpp
**Change Type:** modified
**Context:** PR #27238: Rotary positional embeddings
**Review Line:** 746
**Code Changes:**
```diff
@@ -743,6 +743,32 @@ TEST_F(Layer_RNN_Test, get_set_test)
EXPECT_EQ(shape(outputs[1]), shape(nT, nS, nH));
}
+TEST(Layer_MHARoPe_Test_Accuracy_with_, Pytorch)
+{
+ Mat QKV = blobFromNPY(_tf("mha_rope.QKV.npy"));
+ Mat QKV_bias = blobFromNPY(_tf("mha_rope.QKV_bias.npy"));
+ std::vector<int> qkv_hidden_sizes = { 256, 256, 256 };
+ LayerParams mhaParams;
```
|
This is a little tricky due to compatibility issues with onnx runtime on my dev machine (apple silicon) I have just checked, do_rotary flag is ignored. so i can't produce a reference output of the corresponding onnx (with `do_rotary=1`) model locally. I also opened an issue at https://github.com/microsoft/onnxruntime maybe i get feedback on this soon
|
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/dnn/src/layers/attention_layer.cpp
**Change Type:** modified
**Context:** PR #27238: Rotary positional embeddings
**Code Changes:**
```diff
@@ -24,6 +24,105 @@ static void packWeight(size_t num_heads, size_t head_size, size_t input_hidden_s
}
}
+
+static void rotationKernel(
+ float* data, const float* rotation_table,
+ size_t seq_len, size_t d
+)
+{
```
|
Yes, it does not work, because `w` value is not known in compile time. `VTraits<xxx>::max_nlanes` is compile time constant. It's equal to `CV_SIMD_WIDTH` for fixed SIMD size architectures (x86). RISC-V RVV vector size is not known in compile time, but we know maximum vector length and use it for intermediate buffers to fit any feasible vector size.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/dnn/src/layers/attention_layer.cpp
**Change Type:** modified
**Context:** PR #27238: Rotary positional embeddings
**Code Changes:**
```diff
@@ -24,6 +24,105 @@ static void packWeight(size_t num_heads, size_t head_size, size_t input_hidden_s
}
}
+
+static void rotationKernel(
+ float* data, const float* rotation_table,
+ size_t seq_len, size_t d
+)
+{
```
|
I have replaced CV_SIMD_WIDTH with VTraits<v_float32>::max_nlanes for both CV_SIMD and CV_SIMD_SCALABLE branch
|
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_obsensor/obsensor_uvc_stream_channel.cpp
**Change Type:** modified
**Context:** PR #27230: videoio: add Orbbec Gemini 330 camera support
**Review Line:** 69
**Code Changes:**
```diff
#define fourCc2Int(a, b, c, d) \
@@ -62,6 +66,7 @@ const std::map<uint32_t, FrameFormat> fourccToOBFormat = {
{fourCc2Int('M', 'J', 'P', 'G'), FRAME_FORMAT_MJPG},
{fourCc2Int('Y', '1', '6', ' '), FRAME_FORMAT_Y16},
{fourCc2Int('Y', '1', '4', ' '), FRAME_FORMAT_Y14},
+ {fourCc2Int('Z', '1', '6', ' '), FRAME_FORMAT_Y16}
};
StreamType parseUvcDeviceNameToStreamType(const std::string& devName)
@@ -204,7 +209,6 @@ DepthFrameUnpacker::~DepthFrameUnpacker() {
delete[] outputDataBuf_;
```
|
`fourCc2Int('Y', '1', '6', ' ')` and `fourCc2Int('Z', '1', '6', ' ')` are both mapped to `FRAME_FORMAT_Y16`?
|
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_obsensor/obsensor_uvc_stream_channel.cpp
**Change Type:** modified
**Context:** PR #27230: videoio: add Orbbec Gemini 330 camera support
**Review Line:** 69
**Code Changes:**
```diff
#define fourCc2Int(a, b, c, d) \
@@ -62,6 +66,7 @@ const std::map<uint32_t, FrameFormat> fourccToOBFormat = {
{fourCc2Int('M', 'J', 'P', 'G'), FRAME_FORMAT_MJPG},
{fourCc2Int('Y', '1', '6', ' '), FRAME_FORMAT_Y16},
{fourCc2Int('Y', '1', '4', ' '), FRAME_FORMAT_Y14},
+ {fourCc2Int('Z', '1', '6', ' '), FRAME_FORMAT_Y16}
};
StreamType parseUvcDeviceNameToStreamType(const std::string& devName)
@@ -204,7 +209,6 @@ DepthFrameUnpacker::~DepthFrameUnpacker() {
delete[] outputDataBuf_;
```
|
Still not working.
|
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_obsensor/obsensor_uvc_stream_channel.cpp
**Change Type:** modified
**Context:** PR #27230: videoio: add Orbbec Gemini 330 camera support
**Code Changes:**
```diff
@@ -35,19 +35,23 @@
namespace cv {
namespace obsensor {
+const ObExtensionUnit OBSENSOR_COMMON_XU_UNIT = { XU_UNIT_ID_COMMON, { 0xA55751A1, 0xF3C5, 0x4A5E, { 0x8D, 0x5A, 0x68, 0x54, 0xB8, 0xFA, 0x27, 0x16 } } };
+const ObExtensionUnit OBSENSOR_G330_XU_UNIT = { XU_UNIT_ID_G330, { 0xC9606CCB, 0x594C, 0x4D25, { 0xaf, 0x47, 0xcc, 0xc4, 0x96, 0x43, 0x59, 0x95 } } };
+
const uint8_t OB_EXT_CMD0[16] = { 0x47, 0x4d, 0x04, 0x00, 0x02, 0x00, 0x52, 0x00, 0x5B, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 };
const uint8_t OB_EXT_CMD1[16] = { 0x47, 0x4d, 0x04, 0x00, 0x02, 0x00, 0x54, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const uint8_t OB_EXT_CMD2[16] = { 0x47, 0x4d, 0x04, 0x00, 0x02, 0x00, 0x56, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00 };
```
|
Why do you need resize and crop for the camera frames? I propose to return them in original size. Also resized does not support in-place processing. The code always triggers srcMat realloc.
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/transpose.hpp
**Change Type:** added
**Context:** PR #27229: HAL: implemented cv_hal_transpose in hal_rvv
**Review Line:** 208
**Code Changes:**
```diff
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0
+ };
+ Transpose2dFunc func = tab[element_size];
+ if (!func) {
+ return CV_HAL_ERROR_NOT_IMPLEMENTED;
+ }
+
+ func(src_data, src_step, dst_data, dst_step, src_width, src_height);
```
|
`element_size` may trigger out-of-bound access issue. I propose to add range check before.
|
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
|
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/transpose.hpp
**Change Type:** added
**Context:** PR #27229: HAL: implemented cv_hal_transpose in hal_rvv
**Review Line:** 208
**Code Changes:**
```diff
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0
+ };
+ Transpose2dFunc func = tab[element_size];
+ if (!func) {
+ return CV_HAL_ERROR_NOT_IMPLEMENTED;
+ }
+
+ func(src_data, src_step, dst_data, dst_step, src_width, src_height);
```
|
It is checked before calling hal: https://github.com/opencv/opencv/blob/e37819c2ac1b8ec2beac917bba0d885c79195603/modules/core/src/matrix_transform.cpp#L181
|
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_core.cpp
**Change Type:** modified
**Context:** PR #27184: FastCV gemm hal
**Code Changes:**
```diff
@@ -623,4 +623,119 @@ int fastcv_hal_SVD32f(
}
CV_HAL_RETURN(status, fastcv_hal_SVD32f);
+}
+
+int fastcv_hal_gemm32f(
+ const float* src1,
+ size_t src1_step,
+ const float* src2,
```
|
It's redundant.
|
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_core.cpp
**Change Type:** modified
**Context:** PR #27184: FastCV gemm hal
**Code Changes:**
```diff
@@ -623,4 +623,119 @@ int fastcv_hal_SVD32f(
}
CV_HAL_RETURN(status, fastcv_hal_SVD32f);
+}
+
+int fastcv_hal_gemm32f(
+ const float* src1,
+ size_t src1_step,
+ const float* src2,
```
|
`dst_temp1 = cv::Mat(height_a, width_d, CV_32FC1);` Why do you need roi `cv::Rect(0, 0, width_d, height_a)` here?
|
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_core.cpp
**Change Type:** modified
**Context:** PR #27184: FastCV gemm hal
**Code Changes:**
```diff
@@ -623,4 +623,119 @@ int fastcv_hal_SVD32f(
}
CV_HAL_RETURN(status, fastcv_hal_SVD32f);
+}
+
+int fastcv_hal_gemm32f(
+ const float* src1,
+ size_t src1_step,
+ const float* src2,
```
|
As optimization hint: A*B = B_transopsed * A_transposed.
|
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_core.cpp
**Change Type:** modified
**Context:** PR #27184: FastCV gemm hal
**Code Changes:**
```diff
@@ -623,4 +623,119 @@ int fastcv_hal_SVD32f(
}
CV_HAL_RETURN(status, fastcv_hal_SVD32f);
+}
+
+int fastcv_hal_gemm32f(
+ const float* src1,
+ size_t src1_step,
+ const float* src2,
```
|
Hi Alex u mean line no 669 ?
|
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_core.cpp
**Change Type:** modified
**Context:** PR #27184: FastCV gemm hal
**Code Changes:**
```diff
@@ -623,4 +623,119 @@ int fastcv_hal_SVD32f(
}
CV_HAL_RETURN(status, fastcv_hal_SVD32f);
+}
+
+int fastcv_hal_gemm32f(
+ const float* src1,
+ size_t src1_step,
+ const float* src2,
```
|
Hi Alex we added it here in case the original dst has some padding, i.e. stride > width*sizeof(datatype), since in case of inplace, we are making dst_temp of width * height size
|
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_core.cpp
**Change Type:** modified
**Context:** PR #27184: FastCV gemm hal
**Code Changes:**
```diff
@@ -623,4 +623,119 @@ int fastcv_hal_SVD32f(
}
CV_HAL_RETURN(status, fastcv_hal_SVD32f);
+}
+
+int fastcv_hal_gemm32f(
+ const float* src1,
+ size_t src1_step,
+ const float* src2,
```
|
No need to reset local pointers before return call.
|
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_core.cpp
**Change Type:** modified
**Context:** PR #27184: FastCV gemm hal
**Code Changes:**
```diff
@@ -623,4 +623,119 @@ int fastcv_hal_SVD32f(
}
CV_HAL_RETURN(status, fastcv_hal_SVD32f);
+}
+
+int fastcv_hal_gemm32f(
+ const float* src1,
+ size_t src1_step,
+ const float* src2,
```
|
`copyTo()` handles strides correctly. No need in roi.
|
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/calib3d/camera_calibration_pattern/camera_calibration_pattern.markdown
**Change Type:** modified
**Context:** PR #27221: minor changes in calib3d docs for clarity
**Code Changes:**
```diff
@@ -11,7 +11,7 @@ Create calibration pattern {#tutorial_camera_calibration_pattern}
| Compatibility | OpenCV >= 3.0 |
-The goal of this tutorial is to learn how to create calibration pattern.
+The goal of this tutorial is to learn how to create a calibration pattern.
You can find a chessboard pattern in https://github.com/opencv/opencv/blob/4.x/doc/pattern.png
@@ -47,14 +47,14 @@ create a ChAruco board pattern in charuco_board.svg with 7 rows, 5 columns, squa
```
|
the measurement units
|
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:** platforms/android/build_sdk.py
**Change Type:** modified
**Context:** PR #27239: Android-SDK: check flag IPP package
**Code Changes:**
```diff
@@ -380,7 +380,40 @@ def get_ndk_dir():
return android_sdk_ndk_bundle
return None
+def check_cmake_flag_enabled(cmake_file, flag_name, strict=True):
+ print(f"Checking build flag '{flag_name}' in: {cmake_file}")
+
+ if not os.path.isfile(cmake_file):
+ msg = f"ERROR: File {cmake_file} does not exist."
+ if strict:
```
|
It makes sense to move key name to the function parameters. E.g. check_cmake_flag_enabled(cmake_file, "HAVE_IPP") The same function may be used for KleidiCV and other dependencies.
|
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:** platforms/android/build_sdk.py
**Change Type:** modified
**Context:** PR #27239: Android-SDK: check flag IPP package
**Code Changes:**
```diff
@@ -380,7 +380,40 @@ def get_ndk_dir():
return android_sdk_ndk_bundle
return None
+def check_cmake_flag_enabled(cmake_file, flag_name, strict=True):
+ print(f"Checking build flag '{flag_name}' in: {cmake_file}")
+
+ if not os.path.isfile(cmake_file):
+ msg = f"ERROR: File {cmake_file} does not exist."
+ if strict:
```
|
I propose to add command line option, e.g. "--strict-dependencies" to make the check optional.
|
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:** platforms/android/build_sdk.py
**Change Type:** modified
**Context:** PR #27239: Android-SDK: check flag IPP package
**Code Changes:**
```diff
@@ -380,7 +380,40 @@ def get_ndk_dir():
return android_sdk_ndk_bundle
return None
+def check_cmake_flag_enabled(cmake_file, flag_name, strict=True):
+ print(f"Checking build flag '{flag_name}' in: {cmake_file}")
+
+ if not os.path.isfile(cmake_file):
+ msg = f"ERROR: File {cmake_file} does not exist."
+ if strict:
```
|
Move into ``` for i, abi in enumerate(ABIs): ``` and check configuration.
|
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/macbeth_chart_detection.cpp
**Change Type:** added
**Context:** PR #26906: Adding macbeth chart detector to objdetect module from opencv_contrib
**Code Changes:**
```diff
@@ -0,0 +1,194 @@
+#include <opencv2/core.hpp>
+#include <opencv2/highgui.hpp>
+#include <opencv2/objdetect.hpp>
+#include <opencv2/dnn.hpp>
+#include <iostream>
+#include "../dnn/common.hpp"
+
+using namespace std;
+using namespace cv;
```
|
`getChartsRGB()` 1) returns matrix as a value, 2) that needs to be further reshaped. `getRefColor()` 1) returns matrix via output parameter 2) that does not need to be reshaped. please, align API and output shapes in both cases.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/cpp/macbeth_chart_detection.cpp
**Change Type:** added
**Context:** PR #26906: Adding macbeth chart detector to objdetect module from opencv_contrib
**Review Line:** 178
**Code Changes:**
```diff
+ }
+ }
+ else if (key == 27) exit(0);
+ }
+ if(found){
+ cout<<"Reference colors: "<<tgt<<endl<<"--------------------"<<endl;
+ cout<<"Actual colors: "<<src<<endl<<endl;
+ }
+ }
+ else{
+ found = processFrame(image, detector, src, tgt, nc);
```
|
don't print colors on each frame. print them in the end.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/cpp/macbeth_chart_detection.cpp
**Change Type:** added
**Context:** PR #26906: Adding macbeth chart detector to objdetect module from opencv_contrib
**Code Changes:**
```diff
@@ -0,0 +1,194 @@
+#include <opencv2/core.hpp>
+#include <opencv2/highgui.hpp>
+#include <opencv2/objdetect.hpp>
+#include <opencv2/dnn.hpp>
+#include <iostream>
+#include "../dnn/common.hpp"
+
+using namespace std;
+using namespace cv;
```
|
there is still missing branch that processes still images
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/cpp/macbeth_chart_detection.cpp
**Change Type:** added
**Context:** PR #26906: Adding macbeth chart detector to objdetect module from opencv_contrib
**Code Changes:**
```diff
@@ -0,0 +1,194 @@
+#include <opencv2/core.hpp>
+#include <opencv2/highgui.hpp>
+#include <opencv2/objdetect.hpp>
+#include <opencv2/dnn.hpp>
+#include <iostream>
+#include "../dnn/common.hpp"
+
+using namespace std;
+using namespace cv;
```
|
why do we wait for another key press after user pressed ESC?
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/cpp/macbeth_chart_detection.cpp
**Change Type:** added
**Context:** PR #26906: Adding macbeth chart detector to objdetect module from opencv_contrib
**Code Changes:**
```diff
@@ -0,0 +1,194 @@
+#include <opencv2/core.hpp>
+#include <opencv2/highgui.hpp>
+#include <opencv2/objdetect.hpp>
+#include <opencv2/dnn.hpp>
+#include <iostream>
+#include "../dnn/common.hpp"
+
+using namespace std;
+using namespace cv;
```
|
please remove this printf(). When the pattern is detected, patches are outlined anyway. No need to create extra noise in terminal
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/cpp/macbeth_chart_detection.cpp
**Change Type:** added
**Context:** PR #26906: Adding macbeth chart detector to objdetect module from opencv_contrib
**Code Changes:**
```diff
@@ -0,0 +1,194 @@
+#include <opencv2/core.hpp>
+#include <opencv2/highgui.hpp>
+#include <opencv2/objdetect.hpp>
+#include <opencv2/dnn.hpp>
+#include <iostream>
+#include "../dnn/common.hpp"
+
+using namespace std;
+using namespace cv;
```
|
`getChartsRGB()` and `getRefColors()` still use different ways to return data. Can `getRefColors()` return Mat as return value?
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/cpp/macbeth_chart_detection.cpp
**Change Type:** added
**Context:** PR #26906: Adding macbeth chart detector to objdetect module from opencv_contrib
**Review Line:** 175
**Code Changes:**
```diff
+ }
+ else{
+ cout<<"No color chart detected!!"<<endl;
+ }
+ }
+ else if (key == 27) exit(0);
+ }
+ if(found){
+ cout<<"Reference colors: "<<tgt<<endl<<"--------------------"<<endl;
+ cout<<"Actual colors: "<<src<<endl<<endl;
+ }
```
|
1) when user presses ESCAPE, he does not get colors printed. 2) what if the board was never detected?
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/cpp/macbeth_chart_detection.cpp
**Change Type:** added
**Context:** PR #26906: Adding macbeth chart detector to objdetect module from opencv_contrib
**Code Changes:**
```diff
@@ -0,0 +1,194 @@
+#include <opencv2/core.hpp>
+#include <opencv2/highgui.hpp>
+#include <opencv2/objdetect.hpp>
+#include <opencv2/dnn.hpp>
+#include <iostream>
+#include "../dnn/common.hpp"
+
+using namespace std;
+using namespace cv;
```
|
`processFrame()` should return bool and colors need to be printed only when the chart is detected
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/cpp/macbeth_chart_detection.cpp
**Change Type:** added
**Context:** PR #26906: Adding macbeth chart detector to objdetect module from opencv_contrib
**Review Line:** 153
**Code Changes:**
```diff
+
+ Mat src, tgt;
+ bool found = false;
+ if (isVideo){
+ cout<<"To print the actual colors and reference colors for current frame press SPACEBAR. To resume press SPACEBAR again"<<endl;
+
+ while (cap.grab())
+ {
+ Mat frame;
+ cap.retrieve(frame);
+
```
|
put `bool found = false;` before while loop
|
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/src/mcc/checker_detector.hpp
**Change Type:** added
**Context:** PR #26906: Adding macbeth chart detector to objdetect module from opencv_contrib
**Review Line:** 48
**Code Changes:**
```diff
+ typedef std::vector<Point> PointsVector;
+ typedef std::vector<PointsVector> ContoursVector;
+
+public:
+ CCheckerDetectorImpl();
+ CCheckerDetectorImpl(const dnn::Net& _net){
+ net = _net;
+ }
+ virtual ~CCheckerDetectorImpl();
+
+ bool process(InputArray image, const std::vector<Rect> ®ionsOfInterest,
```
|
Adding a fix in this PR https://github.com/opencv/opencv/pull/27246
|
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 #27217: Optimize gaussian blur performance in FastCV HAL
**Code Changes:**
```diff
@@ -536,30 +536,88 @@ class FcvGaussianBlurLoop_Invoker : public cv::ParallelLoopBody
{
public:
- FcvGaussianBlurLoop_Invoker(const cv::Mat& _src, cv::Mat& _dst, int _ksize, int _borderType, int _fcvBorderValue) :
- cv::ParallelLoopBody(), src(_src),dst(_dst), ksize(_ksize), borderType(_borderType), fcvBorderValue(_fcvBorderValue)
+ FcvGaussianBlurLoop_Invoker(const cv::Mat& _src, cv::Mat& _dst, int _ksize, int _borderType) :
+ cv::ParallelLoopBody(), src(_src),dst(_dst), ksize(_ksize), borderType(_borderType)
{
width = src.cols;
```
|
Build warning: ``` [660/2676] Building CXX object 3rdparty/fastcv/CMakeFiles/fastcv_hal.dir/src/fastcv_hal_imgproc.cpp.o /mnt/Projects/Projects/opencv/3rdparty/fastcv/src/fastcv_hal_imgproc.cpp:671:58: warning: overlapping comparisons always evaluate to true [-Wtautological-overlap-compare] 671 | if( border_type != cv::BorderTypes::BORDER_CONSTANT || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~ 672 | border_type != cv::BorderTypes::BORDER_REPLICATE || | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. ```
|
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 #27182: Parallel_for in box Filter and support for 32f box filter in Fastcv hal
**Code Changes:**
```diff
@@ -314,6 +314,69 @@ int fastcv_hal_sobel(
CV_HAL_RETURN(status, hal_sobel);
}
+class FcvBoxLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
+ FcvBoxLoop_Invoker(cv::Mat src_, int width_, int height_, cv::Mat dst_, int bdr_, int knl_, int normalize_, int stripeHeight_, int nStripes_, int depth_) :
+ cv::ParallelLoopBody(), src(src_), width(width_), height(height_), dst(dst_), bdr(bdr_), knl(knl_), normalize(normalize_), stripeHeight(stripeHeight_), nStripes(nStripes_), depth(depth_)
```
|
`stripeHeight = nThreads * 10;` sounds strange. More threads -> larger piece for each thread.
|
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 #27182: Parallel_for in box Filter and support for 32f box filter in Fastcv hal
**Code Changes:**
```diff
@@ -314,6 +314,69 @@ int fastcv_hal_sobel(
CV_HAL_RETURN(status, hal_sobel);
}
+class FcvBoxLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
+ FcvBoxLoop_Invoker(cv::Mat src_, int width_, int height_, cv::Mat dst_, int bdr_, int knl_, int normalize_, int stripeHeight_, int nStripes_, int depth_) :
+ cv::ParallelLoopBody(), src(src_), width(width_), height(height_), dst(dst_), bdr(bdr_), knl(knl_), normalize(normalize_), stripeHeight(stripeHeight_), nStripes(nStripes_), depth(depth_)
```
|
``` if(inPlace) dst_temp = cv::Mat(height, width, src_depth); else dst_temp = cv::Mat(height, width, src_depth, (void*)dst_data, dst_step); ``` Why do you need roi `cv::Rect(0, 0, width, height)` here?
|
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 #27182: Parallel_for in box Filter and support for 32f box filter in Fastcv hal
**Code Changes:**
```diff
@@ -314,6 +314,69 @@ int fastcv_hal_sobel(
CV_HAL_RETURN(status, hal_sobel);
}
+class FcvBoxLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
+ FcvBoxLoop_Invoker(cv::Mat src_, int width_, int height_, cv::Mat dst_, int bdr_, int knl_, int normalize_, int stripeHeight_, int nStripes_, int depth_) :
+ cv::ParallelLoopBody(), src(src_), width(width_), height(height_), dst(dst_), bdr(bdr_), knl(knl_), normalize(normalize_), stripeHeight(stripeHeight_), nStripes(nStripes_), depth(depth_)
```
|
Hi Alex we added it in case the original dst has some padding (stride > width * sizeof(datatype)), so to only access the width * height data part
|
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 #27182: Parallel_for in box Filter and support for 32f box filter in Fastcv hal
**Code Changes:**
```diff
@@ -314,6 +314,69 @@ int fastcv_hal_sobel(
CV_HAL_RETURN(status, hal_sobel);
}
+class FcvBoxLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
+ FcvBoxLoop_Invoker(cv::Mat src_, int width_, int height_, cv::Mat dst_, int bdr_, int knl_, int normalize_, int stripeHeight_, int nStripes_, int depth_) :
+ cv::ParallelLoopBody(), src(src_), width(width_), height(height_), dst(dst_), bdr(bdr_), knl(knl_), normalize(normalize_), stripeHeight(stripeHeight_), nStripes(nStripes_), depth(depth_)
```
|
Hi Alex We tested this and found it having good speed, since usually threads are 8 as per our experiments. Please guide what optimizations we can do here.
|
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 #27182: Parallel_for in box Filter and support for 32f box filter in Fastcv hal
**Code Changes:**
```diff
@@ -314,6 +314,69 @@ int fastcv_hal_sobel(
CV_HAL_RETURN(status, hal_sobel);
}
+class FcvBoxLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
+ FcvBoxLoop_Invoker(cv::Mat src_, int width_, int height_, cv::Mat dst_, int bdr_, int knl_, int normalize_, int stripeHeight_, int nStripes_, int depth_) :
+ cv::ParallelLoopBody(), src(src_), width(width_), height(height_), dst(dst_), bdr(bdr_), knl(knl_), normalize(normalize_), stripeHeight(stripeHeight_), nStripes(nStripes_), depth(depth_)
```
|
`copyTo()` handles strides correctly. No need to use roi. It creates redundant cv::Mat object.
|
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 #27182: Parallel_for in box Filter and support for 32f box filter in Fastcv hal
**Code Changes:**
```diff
@@ -314,6 +314,69 @@ int fastcv_hal_sobel(
CV_HAL_RETURN(status, hal_sobel);
}
+class FcvBoxLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
+ FcvBoxLoop_Invoker(cv::Mat src_, int width_, int height_, cv::Mat dst_, int bdr_, int knl_, int normalize_, int stripeHeight_, int nStripes_, int depth_) :
+ cv::ParallelLoopBody(), src(src_), width(width_), height(height_), dst(dst_), bdr(bdr_), knl(knl_), normalize(normalize_), stripeHeight(stripeHeight_), nStripes(nStripes_), depth(depth_)
```
|
threads are 8. It's not true: - Android build uses 2 threads by default. It's done to prevent overheating, but may be changed in future. - Linux builds use all available cores. - parallel_for_ serializes nested parallel_for_ calls. So you can easily get 1 here.
|
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 #27182: Parallel_for in box Filter and support for 32f box filter in Fastcv hal
**Code Changes:**
```diff
@@ -314,6 +314,69 @@ int fastcv_hal_sobel(
CV_HAL_RETURN(status, hal_sobel);
}
+class FcvBoxLoop_Invoker : public cv::ParallelLoopBody
+{
+public:
+
+ FcvBoxLoop_Invoker(cv::Mat src_, int width_, int height_, cv::Mat dst_, int bdr_, int knl_, int normalize_, int stripeHeight_, int nStripes_, int depth_) :
+ cv::ParallelLoopBody(), src(src_), width(width_), height(height_), dst(dst_), bdr(bdr_), knl(knl_), normalize(normalize_), stripeHeight(stripeHeight_), nStripes(nStripes_), depth(depth_)
```
|
We usually set granularity to some reasonable size for single thread. OpenCV uses dynamic scheduling, so all other steps are done automatically.
|
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/mat.hpp
**Change Type:** modified
**Context:** PR #27265: 5.x merge 4.x - OpenCV Contrib: https://github.com/opencv/opencv_contrib/pull/3928 OpenCV Extra: https://github.com/opencv/opencv_extra/pul...
**Code Changes:**
```diff
@@ -494,6 +494,7 @@ class CV_EXPORTS _OutputArray : public _InputArray
void clear() const;
void setTo(const _InputArray& value, const _InputArray & mask = _InputArray()) const;
void setZero() const;
+ Mat reinterpret( int type ) const;
void assign(const UMat& u) const;
void assign(const Mat& m) const;
@@ -1540,6 +1541,15 @@ class CV_EXPORTS Mat
*/
```
|
Looks like this change is wrong.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/highgui/src/window_QT.cpp
**Change Type:** modified
**Context:** PR #27265: 5.x merge 4.x - OpenCV Contrib: https://github.com/opencv/opencv_contrib/pull/3928 OpenCV Extra: https://github.com/opencv/opencv_extra/pul...
**Review Line:** 1668
**Code Changes:**
```diff
- if (guiMainThread)
- guiMainThread->isLastWindow();
-}
-
-
void CvWindow::setMouseCallBack(CvMouseCallback callback, void* param)
{
myView->setMouseCallBack(callback, param);
@@ -2185,6 +2178,15 @@ void CvWindow::keyPressEvent(QKeyEvent *evnt)
}
```
|
Destructor has not been removed in header file (#27170).
|
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/riscv-rvv/hal_rvv_1p0/norm.hpp
**Change Type:** renamed
**Context:** PR #27265: 5.x merge 4.x - OpenCV Contrib: https://github.com/opencv/opencv_contrib/pull/3928 OpenCV Extra: https://github.com/opencv/opencv_extra/pul...
**Review Line:** 1
**Code Changes:**
```diff
@@ -1016,7 +1016,7 @@ inline int norm(const uchar* src, size_t src_step, const uchar* mask, size_t mas
CV_Assert(elem_size_tab[depth]);
bool src_continuous = (src_step == width * elem_size_tab[depth] * cn || (src_step != width * elem_size_tab[depth] * cn && height == 1));
- bool mask_continuous = (mask_step == width);
+ bool mask_continuous = (mask_step == static_cast<size_t>(width));
size_t nplanes = 1;
size_t size = width * height;
if ((mask && (!src_continuous || !mask_continuous)) || !src_continuous) {
```
|
Changes in this file needs to be reverted except line 1014.
|
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/riscv-rvv/hal_rvv_1p0/norm_diff.hpp
**Change Type:** renamed
**Context:** PR #27265: 5.x merge 4.x - OpenCV Contrib: https://github.com/opencv/opencv_contrib/pull/3928 OpenCV Extra: https://github.com/opencv/opencv_extra/pul...
**Review Line:** 1
**Code Changes:**
```diff
@@ -1128,7 +1128,7 @@ inline int normDiff(const uchar* src1, size_t src1_step, const uchar* src2, size
bool src_continuous = (src1_step == width * elem_size_tab[depth] * cn || (src1_step != width * elem_size_tab[depth] * cn && height == 1));
src_continuous &= (src2_step == width * elem_size_tab[depth] * cn || (src2_step != width * elem_size_tab[depth] * cn && height == 1));
- bool mask_continuous = (mask_step == width);
+ bool mask_continuous = (mask_step == static_cast<size_t>(width));
size_t nplanes = 1;
size_t size = width * height;
if ((mask && (!src_continuous || !mask_continuous)) || !src_continuous) {
```
|
Changes in this file needs to be reverted except line 1128.
|
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback.
|
**File:** 3rdparty/ipphal/CMakeLists.txt
**Change Type:** modified
**Context:** PR #27194: Migrated IPP impl for flip and transpose to HAL
**Review Line:** 27
**Code Changes:**
```diff
if(HAVE_IPP_ICV)
target_compile_definitions(ipphal PRIVATE HAVE_IPP_ICV)
endif()
+if(HAVE_IPP_IW)
+ target_compile_definitions(ipphal PRIVATE HAVE_IPP_IW)
+endif()
+
target_include_directories(ipphal PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
+ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-suggest-override)
```
|
PRIVATE? This macro is used in "interface" headers.
|
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/ipphal/CMakeLists.txt
**Change Type:** modified
**Context:** PR #27194: Migrated IPP impl for flip and transpose to HAL
**Review Line:** 27
**Code Changes:**
```diff
if(HAVE_IPP_ICV)
target_compile_definitions(ipphal PRIVATE HAVE_IPP_ICV)
endif()
+if(HAVE_IPP_IW)
+ target_compile_definitions(ipphal PRIVATE HAVE_IPP_IW)
+endif()
+
target_include_directories(ipphal PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
+ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-suggest-override)
```
|
Good point. Fixed.
|
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/ipphal/CMakeLists.txt
**Change Type:** modified
**Context:** PR #27194: Migrated IPP impl for flip and transpose to HAL
**Review Line:** 27
**Code Changes:**
```diff
if(HAVE_IPP_ICV)
target_compile_definitions(ipphal PRIVATE HAVE_IPP_ICV)
endif()
+if(HAVE_IPP_IW)
+ target_compile_definitions(ipphal PRIVATE HAVE_IPP_IW)
+endif()
+
target_include_directories(ipphal PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
+ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-suggest-override)
```
|
Looks like I cannot make it public for now. We get redefinition issue. The macros are defined by both HAL and IPP core. I made it private for now to exclude the redefinition issue and added note to CMake.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/dnn/yolo_detector.cpp
**Change Type:** modified
**Context:** PR #25794: Add sample support of `YOLOv9` and `YOLOv10` in OpenCV
**Review Line:** 143
**Code Changes:**
```diff
+ outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, nc + 4});
}
+ // assert if last dim is 85 or 84
+ CV_CheckEQ(outs[0].dims, 3, "Invalid output shape. The shape should be [1, #anchors, 85 or 84]");
+ CV_CheckEQ((outs[0].size[2] == nc + 5 || outs[0].size[2] == 80 + 4), true, "Invalid output shape: ");
+
for (auto preds : outs)
{
preds = preds.reshape(1, preds.size[1]); // [1, 8400, 85] -> [8400, 85]
for (int i = 0; i < preds.rows; ++i)
```
|
Check also that `outs[0].dims == 2` before.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/dnn/yolo_detector.cpp
**Change Type:** modified
**Context:** PR #25794: Add sample support of `YOLOv9` and `YOLOv10` in OpenCV
**Review Line:** 138
**Code Changes:**
```diff
@@ -131,25 +135,30 @@ void yoloPostProcessing(
// remove the second element
outs.pop_back();
// unsqueeze the first dimension
- outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, 84});
+ outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, nc + 4});
}
+ // assert if last dim is 85 or 84
+ CV_CheckEQ(outs[0].dims, 3, "Invalid output shape. The shape should be [1, #anchors, 85 or 84]");
+ CV_CheckEQ((outs[0].size[2] == nc + 5 || outs[0].size[2] == 80 + 4), true, "Invalid output shape: ");
```
|
8400 is also depends on number of classes? So should it be `(nc + 4) * 100` or not?
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/dnn/yolo_detector.cpp
**Change Type:** modified
**Context:** PR #25794: Add sample support of `YOLOv9` and `YOLOv10` in OpenCV
**Review Line:** 138
**Code Changes:**
```diff
@@ -131,25 +135,30 @@ void yoloPostProcessing(
// remove the second element
outs.pop_back();
// unsqueeze the first dimension
- outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, 84});
+ outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, nc + 4});
}
+ // assert if last dim is 85 or 84
+ CV_CheckEQ(outs[0].dims, 3, "Invalid output shape. The shape should be [1, #anchors, 85 or 84]");
+ CV_CheckEQ((outs[0].size[2] == nc + 5 || outs[0].size[2] == 80 + 4), true, "Invalid output shape: ");
```
|
`nc` seems redundant as it can be computed from original shape: ```cpp int nc = outs[0].total() / 8400 - 4; ``` or, if 8400 is also depends on `nc`: ```cpp int nc = sqrt(outs[0].total() / 100) - 4; ```
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/dnn/yolo_detector.cpp
**Change Type:** modified
**Context:** PR #25794: Add sample support of `YOLOv9` and `YOLOv10` in OpenCV
**Review Line:** 138
**Code Changes:**
```diff
@@ -131,25 +135,30 @@ void yoloPostProcessing(
// remove the second element
outs.pop_back();
// unsqueeze the first dimension
- outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, 84});
+ outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, nc + 4});
}
+ // assert if last dim is 85 or 84
+ CV_CheckEQ(outs[0].dims, 3, "Invalid output shape. The shape should be [1, #anchors, 85 or 84]");
+ CV_CheckEQ((outs[0].size[2] == nc + 5 || outs[0].size[2] == 80 + 4), true, "Invalid output shape: ");
```
|
> 8400 is also depends on number of classes? So should it be `(nc + 4) * 100` or not? 8400 depends on number of anchors only and has nothing to do with `nc`. `nc` depends on which dataset detector what trained. On `COCO` dataset `nc = 80`. For other datasets it might be different.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/dnn/yolo_detector.cpp
**Change Type:** modified
**Context:** PR #25794: Add sample support of `YOLOv9` and `YOLOv10` in OpenCV
**Review Line:** 138
**Code Changes:**
```diff
@@ -131,25 +135,30 @@ void yoloPostProcessing(
// remove the second element
outs.pop_back();
// unsqueeze the first dimension
- outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, 84});
+ outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, nc + 4});
}
+ // assert if last dim is 85 or 84
+ CV_CheckEQ(outs[0].dims, 3, "Invalid output shape. The shape should be [1, #anchors, 85 or 84]");
+ CV_CheckEQ((outs[0].size[2] == nc + 5 || outs[0].size[2] == 80 + 4), true, "Invalid output shape: ");
```
|
I strongly believe that it should stay as a papermeter. As this is a parameter during traning. Computing it via `outs[0]` is kind of hack.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/dnn/yolo_detector.cpp
**Change Type:** modified
**Context:** PR #25794: Add sample support of `YOLOv9` and `YOLOv10` in OpenCV
**Review Line:** 138
**Code Changes:**
```diff
@@ -131,25 +135,30 @@ void yoloPostProcessing(
// remove the second element
outs.pop_back();
// unsqueeze the first dimension
- outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, 84});
+ outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, nc + 4});
}
+ // assert if last dim is 85 or 84
+ CV_CheckEQ(outs[0].dims, 3, "Invalid output shape. The shape should be [1, #anchors, 85 or 84]");
+ CV_CheckEQ((outs[0].size[2] == nc + 5 || outs[0].size[2] == 80 + 4), true, "Invalid output shape: ");
```
|
The corner case is a background class. Some training utils may include this as a separate class - some not. So even if you trained model for 80 real classes, there is a variation nc=80 nc=81 and it may confuse even more.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** samples/dnn/yolo_detector.cpp
**Change Type:** modified
**Context:** PR #25794: Add sample support of `YOLOv9` and `YOLOv10` in OpenCV
**Review Line:** 138
**Code Changes:**
```diff
@@ -131,25 +135,30 @@ void yoloPostProcessing(
// remove the second element
outs.pop_back();
// unsqueeze the first dimension
- outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, 84});
+ outs[0] = outs[0].reshape(0, std::vector<int>{1, 8400, nc + 4});
}
+ // assert if last dim is 85 or 84
+ CV_CheckEQ(outs[0].dims, 3, "Invalid output shape. The shape should be [1, #anchors, 85 or 84]");
+ CV_CheckEQ((outs[0].size[2] == nc + 5 || outs[0].size[2] == 80 + 4), true, "Invalid output shape: ");
```
|
Computing `nc` using number of anchor points is not good since number of anchors depens on the image size. Inference can happen on different image resolutons, depending on use case.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.