nareshmlx/opencv-pr huggingface dataset:
**File:** doc/tutorials/introduction/env_reference/env_reference.markdown
**Change Type:** added
**Context:** PR #23968: doc: added environment vars reference - Collected most environment variables used to a single document.
**Review Line:** 186

**Code Changes:**
```diff
+
+##### Links:
+- https://github.com/opencv/opencv/wiki/OpenCL-optimizations
+
+
+### Tracing/Profiling
+| name | type | default | description |
+|------|------|---------|-------------|
+| ⭐ OPENCV_TRACE | bool | false | enable trace |
+| OPENCV_TRACE_LOCATION | string | `OpenCVTrace` | trace file name ("${name}-$03d.txt") |
+| OPENCV_TRACE_DEPTH_OPENCV | num | 1 | |
```

Review comment:
Trable formatting is broken. See https://pullrequest.opencv.org/buildbot/export/pr/23968/docs/d6/dea/tutorial_env_reference.html
**File:** doc/tutorials/introduction/env_reference/env_reference.markdown
**Change Type:** added
**Context:** PR #23968: doc: added environment vars reference - Collected most environment variables used to a single document.

**Code Changes:**
```diff
@@ -0,0 +1,345 @@
+OpenCV environment variables reference {#tutorial_env_reference}
+======================================
+
+@prev_tutorial{tutorial_config_reference}
+@next_tutorial{tutorial_linux_install}
+
+@tableofcontents
+
+### Introduction
```

Review comment:
`:star:` is not rendered by Doxygen
**File:** modules/core/misc/python/package/mat_wrapper/__init__.py
**Change Type:** modified
**Context:** PR #23927: Fix partially unknown Mat
**Review Line:** 8

**Code Changes:**
```diff
 import numpy as np
 import cv2 as cv
+from typing import TYPE_CHECKING, Any
+
+# Type subscription is not possible in python 3.8
+if TYPE_CHECKING:
+    _NDArray = np.ndarray[Any, np.dtype[np.generic]]
+else:
+    _NDArray = np.ndarray
 
 # NumPy documentation: https://numpy.org/doc/stable/user/basics.subclassing.html
```

Review comment:
Why this check isn't based on NumPy and Python versions like in [PR 23838](https://github.com/opencv/opencv/pull/23838)?
**File:** modules/core/misc/python/package/mat_wrapper/__init__.py
**Change Type:** modified
**Context:** PR #23927: Fix partially unknown Mat
**Review Line:** 8

**Code Changes:**
```diff
 import numpy as np
 import cv2 as cv
+from typing import TYPE_CHECKING, Any
+
+# Type subscription is not possible in python 3.8
+if TYPE_CHECKING:
+    _NDArray = np.ndarray[Any, np.dtype[np.generic]]
+else:
+    _NDArray = np.ndarray
 
 # NumPy documentation: https://numpy.org/doc/stable/user/basics.subclassing.html
```

Review comment:
https://github.com/opencv/opencv/blob/cb2e831da43f4426353b2b2ae961175720447f9f/modules/python/src2/typing_stubs_generation/nodes/type_node.py#L410
**File:** modules/core/misc/python/package/mat_wrapper/__init__.py
**Change Type:** modified
**Context:** PR #23927: Fix partially unknown Mat
**Review Line:** 8

**Code Changes:**
```diff
 import numpy as np
 import cv2 as cv
+from typing import TYPE_CHECKING, Any
+
+# Type subscription is not possible in python 3.8
+if TYPE_CHECKING:
+    _NDArray = np.ndarray[Any, np.dtype[np.generic]]
+else:
+    _NDArray = np.ndarray
 
 # NumPy documentation: https://numpy.org/doc/stable/user/basics.subclassing.html
```

Review comment:
https://peps.python.org/pep-0484/#version-and-platform-checking > Type checkers are expected to understand simple version and platform checks [...] If I was to include a numpy version check, static type checkers would see this as two possible assignements of the `_NDArray` type alias and their exact behaviour will differ with implementation. I could probably do a Python version check, but a `TYPE_CHECKING` check was just simpler, works across all versions, and clearly shows that this condition exists purely for static type-checking reasons.
**File:** modules/core/misc/python/package/mat_wrapper/__init__.py
**Change Type:** modified
**Context:** PR #23927: Fix partially unknown Mat
**Review Line:** 8

**Code Changes:**
```diff
 import numpy as np
 import cv2 as cv
+from typing import TYPE_CHECKING, Any
+
+# Type subscription is not possible in python 3.8
+if TYPE_CHECKING:
+    _NDArray = np.ndarray[Any, np.dtype[np.generic]]
+else:
+    _NDArray = np.ndarray
 
 # NumPy documentation: https://numpy.org/doc/stable/user/basics.subclassing.html
```

Review comment:
It's a bit unclear to me on how type checker would behave if library doesn't provide such type (NumPy version check) or/and type subscription is not possible (Python version check). Can you elaborate on this if you are familiar with it? There won't be a state when there are 2 alias definitions, because libraries and interpreter versions are known and fixed.
**File:** modules/core/misc/python/package/mat_wrapper/__init__.py
**Change Type:** modified
**Context:** PR #23927: Fix partially unknown Mat
**Review Line:** 8

**Code Changes:**
```diff
 import numpy as np
 import cv2 as cv
+from typing import TYPE_CHECKING, Any
+
+# Type subscription is not possible in python 3.8
+if TYPE_CHECKING:
+    _NDArray = np.ndarray[Any, np.dtype[np.generic]]
+else:
+    _NDArray = np.ndarray
 
 # NumPy documentation: https://numpy.org/doc/stable/user/basics.subclassing.html
```

Review comment:
> pyright made a union of both ndarray. We're back to square 1 with lost generic types. Which means that #23838 would also cause #23780 for `MatLike`. I'll wait for your answer, but I can update that too.
**File:** modules/core/test/test_mat.cpp
**Change Type:** modified
**Context:** PR #23938: Fix compiler warnings for GCC 11-12 and Clang 13 - Related issue: https://github.com/opencv/opencv/issues/22218 * Silenced or workarounded ...

**Code Changes:**
```diff
@@ -18,7 +18,7 @@ class Core_ReduceTest : public cvtest::BaseTest
 public:
     Core_ReduceTest() {}
 protected:
-    void run( int);
+    void run( int) CV_OVERRIDE;
     int checkOp( const Mat& src, int dstType, int opType, const Mat& opRes, int dim );
     int checkCase( int srcType, int dstType, int dim, Size sz );
     int checkDim( int dim, Size sz );
@@ -495,7 +495,7 @@ class Core_ArrayOpTest : public cvtest::BaseTest
```

Review comment:
We use C++11 by default. Why do you need the check?
**File:** modules/core/test/test_mat.cpp
**Change Type:** modified
**Context:** PR #23938: Fix compiler warnings for GCC 11-12 and Clang 13 - Related issue: https://github.com/opencv/opencv/issues/22218 * Silenced or workarounded ...

**Code Changes:**
```diff
@@ -18,7 +18,7 @@ class Core_ReduceTest : public cvtest::BaseTest
 public:
     Core_ReduceTest() {}
 protected:
-    void run( int);
+    void run( int) CV_OVERRIDE;
     int checkOp( const Mat& src, int dstType, int opType, const Mat& opRes, int dim );
     int checkCase( int srcType, int dstType, int dim, Size sz );
     int checkDim( int dim, Size sz );
@@ -495,7 +495,7 @@ class Core_ArrayOpTest : public cvtest::BaseTest
```

Review comment:
There is test below `range_checking` which uses `GpuMat` and is guarded by `#ifdef CV_CXX11`, so I added the same guard for the header. Probably both _ifdefs_ should be removed if we choose to merge #23736 .
**File:** modules/core/test/test_mat.cpp
**Change Type:** modified
**Context:** PR #23938: Fix compiler warnings for GCC 11-12 and Clang 13 - Related issue: https://github.com/opencv/opencv/issues/22218 * Silenced or workarounded ...

**Code Changes:**
```diff
@@ -18,7 +18,7 @@ class Core_ReduceTest : public cvtest::BaseTest
 public:
     Core_ReduceTest() {}
 protected:
-    void run( int);
+    void run( int) CV_OVERRIDE;
     int checkOp( const Mat& src, int dstType, int opType, const Mat& opRes, int dim );
     int checkCase( int srcType, int dstType, int dim, Size sz );
     int checkDim( int dim, Size sz );
@@ -495,7 +495,7 @@ class Core_ArrayOpTest : public cvtest::BaseTest
```

Review comment:
I propose to remove both `CV_CXX11` checks as not relevant any more.
**File:** apps/createsamples/CMakeLists.txt
**Change Type:** modified
**Context:** PR #11736: cmake: function for application creation - to be merged after #11734 ### This pullrequest changes Added single cmake function for applicati...
**Review Line:** 15

**Code Changes:**
```diff
@@ -1,38 +1,4 @@
-set(OPENCV_CREATESAMPLES_DEPS opencv_core opencv_imgproc opencv_objdetect opencv_imgcodecs opencv_highgui opencv_calib3d opencv_features2d opencv_videoio)
-ocv_check_dependencies(${OPENCV_CREATESAMPLES_DEPS})
-
-if(NOT OCV_DEPENDENCIES_FOUND)
-  return()
-endif()
-
-project(createsamples)
-set(the_target opencv_createsamples)
-
-ocv_target_include_directories(${the_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv")
-ocv_target_include_modules_recurse(${the_target} ${OPENCV_CREATESAMPLES_DEPS})
-
 file(GLOB SRCS *.cpp)
```

Review comment:
BTW, non-included header files are not showed in MSVS solutions.
**File:** apps/version/CMakeLists.txt
**Change Type:** modified
**Context:** PR #11736: cmake: function for application creation - to be merged after #11734 ### This pullrequest changes Added single cmake function for applicati...
**Review Line:** 4

**Code Changes:**
```diff
-else()
-  install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs)
+ocv_add_application(opencv_version MODULES opencv_core SRCS opencv_version.cpp)
+if(WIN32)
+  ocv_add_application(opencv_version_win32 MODULES opencv_core SRCS opencv_version.cpp)
+  target_compile_definitions(opencv_version_win32 PRIVATE "OPENCV_WIN32_API=1")
 endif()
```

Review comment:
``` if(TARGET opencv_version_win32) target_compile_definitions(...) endif() ``` for case of 'return' from function (missing dependencies). Actually it is not required for this case, but may be useful for others.
**File:** modules/imgproc/src/color_hsv.simd.hpp
**Change Type:** modified
**Context:** PR #22441: Speed up HLS2RGB.
**Review Line:** 423

**Code Changes:**
```diff
@@ -419,6 +419,14 @@ inline void HSV2RGB_simd(const v_float32& h, const v_float32& s, const v_float32
 }
 #endif
 
+// Compute the sector and the new H for HSV and HLS 2 RGB conversions.
+inline void ComputeSectorAndClampedH(float& h, int &sector) {
+    sector = cvFloor(h);
+    h -= sector;
+    sector %= 6;
+    sector += sector < 0 ? 6 : 0;
+}
```

Review comment:
`static inline` to avoid function exporting / ODR violation.
**File:** modules/imgproc/src/color_hsv.simd.hpp
**Change Type:** modified
**Context:** PR #22441: Speed up HLS2RGB.
**Review Line:** 423

**Code Changes:**
```diff
@@ -419,6 +419,14 @@ inline void HSV2RGB_simd(const v_float32& h, const v_float32& s, const v_float32
 }
 #endif
 
+// Compute the sector and the new H for HSV and HLS 2 RGB conversions.
+inline void ComputeSectorAndClampedH(float& h, int &sector) {
+    sector = cvFloor(h);
+    h -= sector;
+    sector %= 6;
+    sector += sector < 0 ? 6 : 0;
+}
```

Review comment:
No need as this is in an anonymous namespace (the function right below is also just inline)
**File:** modules/videoio/src/cap_images.cpp
**Change Type:** modified
**Context:** PR #23896: videoio: tests for CAP_IMAGES - * Basic CAP_IMAGES tests * exposed `icvExtractPattern` for testing purposes Related: single image reading s...
**Review Line:** 204

**Code Changes:**
```diff
     return false;
 }
 
-static
+// static
 std::string icvExtractPattern(const std::string& filename, unsigned *offset)
 {
     size_t len = filename.size();
```

Review comment:
`unsigned *offset` -> `unsigned& offset`.
**File:** modules/videoio/src/cap_images.cpp
**Change Type:** modified
**Context:** PR #23896: videoio: tests for CAP_IMAGES - * Basic CAP_IMAGES tests * exposed `icvExtractPattern` for testing purposes Related: single image reading s...
**Review Line:** 204

**Code Changes:**
```diff
     return false;
 }
 
-static
+// static
 std::string icvExtractPattern(const std::string& filename, unsigned *offset)
 {
     size_t len = filename.size();
```

Review comment:
I propose to rename the function to `extractFileNamePattern` to follow common naming (not old C API).
**File:** modules/videoio/src/cap_images.cpp
**Change Type:** modified
**Context:** PR #23896: videoio: tests for CAP_IMAGES - * Basic CAP_IMAGES tests * exposed `icvExtractPattern` for testing purposes Related: single image reading s...
**Review Line:** 204

**Code Changes:**
```diff
     return false;
 }
 
-static
+// static
 std::string icvExtractPattern(const std::string& filename, unsigned *offset)
 {
     size_t len = filename.size();
```

Review comment:
I tried to make as little modification in the source code as possible to simplify merge with #23815 . Maybe it would be better to postpone refactoring? I had some ideas, like multiple pattern support (e.g. `frame_%d_%d.png`), which would require to rework this function even more.
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #23884: G-API: Fix async inference for OpenVINO backend

**Code Changes:**
```diff
@@ -1403,8 +1403,10 @@ cv::gimpl::ov::GOVExecutable::GOVExecutable(const ade::Graph &g,
         case NodeType::OP:
             if (this_nh == nullptr) {
                 this_nh = nh;
-                compiled = const_cast<OVUnit&>(ovm.metadata(this_nh).get<OVUnit>()).compile();
-                m_reqPool.reset(new RequestPool(createInferRequests(compiled.compiled_model, 1)));
+                const auto &unit = ovm.metadata(this_nh).get<OVUnit>();
+                compiled = const_cast<OVUnit&>(unit).compile();
+                m_reqPool.reset(new RequestPool(createInferRequests(
+                                compiled.compiled_model, unit.params.nireq)));
```

Review comment:
`nireq` is not modified in `compile` or somewhere else and used as pipeline input. Why do you need it here?
**File:** modules/gapi/src/backends/ov/govbackend.cpp
**Change Type:** modified
**Context:** PR #23884: G-API: Fix async inference for OpenVINO backend

**Code Changes:**
```diff
@@ -1403,8 +1403,10 @@ cv::gimpl::ov::GOVExecutable::GOVExecutable(const ade::Graph &g,
         case NodeType::OP:
             if (this_nh == nullptr) {
                 this_nh = nh;
-                compiled = const_cast<OVUnit&>(ovm.metadata(this_nh).get<OVUnit>()).compile();
-                m_reqPool.reset(new RequestPool(createInferRequests(compiled.compiled_model, 1)));
+                const auto &unit = ovm.metadata(this_nh).get<OVUnit>();
+                compiled = const_cast<OVUnit&>(unit).compile();
+                m_reqPool.reset(new RequestPool(createInferRequests(
+                                compiled.compiled_model, unit.params.nireq)));
```

Review comment:
Well, it should be available from graph metadata in order to extract this value to create `RequestPool`. `OVCompiled` is the only structure which is accessible from meta.
**File:** modules/dnn/src/layers/convolution_layer.cpp
**Change Type:** modified
**Context:** PR #23319: dnn CANN backend: fix some bugs and add some features
**Review Line:** 823

**Code Changes:**
```diff
+                    // identity SAME_UPPER and SAME_LOWER, extra padding is always
+                    // added to the end.
+                    pads_end[i] = pads_at_i - pads_begin[i];
+                }
+            }
+        }
         op->set_attr_pads(ge::Operator::OpListInt(
             {(int64_t)pads_begin[1], (int64_t)pads_end[1], (int64_t)pads_begin[0], (int64_t)pads_end[0]}
         ));
@@ -815,12 +833,12 @@ class ConvolutionLayerImpl CV_FINAL : public BaseConvolutionLayerImpl
         // set inputs
```

Review comment:
This is a temporal solution of "SAME pad mode to pads" calculation specifically for CANN. Will submit another pull request to fix for all backends if possible.
**File:** modules/calib3d/src/usac/degeneracy.cpp
**Change Type:** modified
**Context:** PR #23806: Get rid of unsafe raw pointers to Mat object in USAC

**Code Changes:**
```diff
@@ -8,12 +8,14 @@
 namespace cv { namespace usac {
 class EpipolarGeometryDegeneracyImpl : public EpipolarGeometryDegeneracy {
 private:
-    const Mat * points_mat;
-    const float * const points; // i-th row xi1 yi1 xi2 yi2
+    Mat points_mat;
     const int min_sample_size;
 public:
     explicit EpipolarGeometryDegeneracyImpl (const Mat &points_, int sample_size_) :
```

Review comment:
Maybe `points_mat.ptr<float>()` would be better? Here and in other similar places.
**File:** modules/calib3d/src/usac/estimator.cpp
**Change Type:** modified
**Context:** PR #23806: Get rid of unsafe raw pointers to Mat object in USAC

**Code Changes:**
```diff
@@ -216,19 +216,18 @@ Ptr<PnPEstimator> PnPEstimator::create (const Ptr<MinimalSolver> &min_solver_,
 // Symmetric Reprojection Error
 class ReprojectionErrorSymmetricImpl : public ReprojectionErrorSymmetric {
 private:
-    const Mat * points_mat;
-    const float * const points;
+    Mat points_mat;
     float m11, m12, m13, m21, m22, m23, m31, m32, m33;
     float minv11, minv12, minv13, minv21, minv22, minv23, minv31, minv32, minv33;
     std::vector<float> errors;
```

Review comment:
I think we should also add `CV_Assert(points.isContinuous())` check. Here and in other places where Mat objects enter the scope. Maybe type and dimensions should be verified too?
**File:** modules/calib3d/src/usac/pnp_solver.cpp
**Change Type:** modified
**Context:** PR #23806: Get rid of unsafe raw pointers to Mat object in USAC

**Code Changes:**
```diff
@@ -15,15 +15,17 @@
 namespace cv { namespace usac {
 class PnPMinimalSolver6PtsImpl : public PnPMinimalSolver6Pts {
 private:
-    const Mat * points_mat;
-    const float * const points;
+    Mat points_mat;
 public:
     // linear 6 points required (11 equations)
     int getSampleSize() const override { return 6; }
```

Review comment:
Here `ptr` method should be used too.
**File:** modules/calib3d/src/usac/pnp_solver.cpp
**Change Type:** modified
**Context:** PR #23806: Get rid of unsafe raw pointers to Mat object in USAC

**Code Changes:**
```diff
@@ -15,15 +15,17 @@
 namespace cv { namespace usac {
 class PnPMinimalSolver6PtsImpl : public PnPMinimalSolver6Pts {
 private:
-    const Mat * points_mat;
-    const float * const points;
+    Mat points_mat;
 public:
     // linear 6 points required (11 equations)
     int getSampleSize() const override { return 6; }
```

Review comment:
I think `ptr<float>` should work as well, because there exists [const T* Mat::ptr(int i = 0) const](https://docs.opencv.org/4.x/d3/d63/classcv_1_1Mat.html#a6a6b3696440fe48751bfe60fe2a729f3) method. Though it's more of a styling preference.
**File:** modules/calib3d/src/usac/pnp_solver.cpp
**Change Type:** modified
**Context:** PR #23806: Get rid of unsafe raw pointers to Mat object in USAC
**Review Line:** 304

**Code Changes:**
```diff
-        points_mat(&points_), calib_norm_points_mat(&calib_norm_points_), K(K_),
-        calib_norm_points((float*)calib_norm_points_mat->data), points((float*)points_mat->data) {}
+        points_mat(points_), calib_norm_points_mat(calib_norm_points_), K(K_)
+    {
+        CV_DbgAssert(!points_mat.empty() && points_mat.isContinuous());
+        CV_DbgAssert(!calib_norm_points_mat.empty() && calib_norm_points_mat.isContinuous());
+    }
 
     int estimate (const std::vector<int> &sample, std::vector<Mat> &models) const override {
         /*
          * The description of this solution can be found here:
```

Review comment:
I'm wondering if it is possible to use `CV_Assert` instead of debug. Is it performance sensitive code?
**File:** modules/calib3d/src/usac/pnp_solver.cpp
**Change Type:** modified
**Context:** PR #23806: Get rid of unsafe raw pointers to Mat object in USAC
**Review Line:** 304

**Code Changes:**
```diff
-        points_mat(&points_), calib_norm_points_mat(&calib_norm_points_), K(K_),
-        calib_norm_points((float*)calib_norm_points_mat->data), points((float*)points_mat->data) {}
+        points_mat(points_), calib_norm_points_mat(calib_norm_points_), K(K_)
+    {
+        CV_DbgAssert(!points_mat.empty() && points_mat.isContinuous());
+        CV_DbgAssert(!calib_norm_points_mat.empty() && calib_norm_points_mat.isContinuous());
+    }
 
     int estimate (const std::vector<int> &sample, std::vector<Mat> &models) const override {
         /*
          * The description of this solution can be found here:
```

Review comment:
There is continuity check and check for emptiness in interface USAC functions. The checks originally were added for debug purposes. I propose to remain them as debug.
**File:** 3rdparty/ffmpeg/ffmpeg.cmake
**Change Type:** modified
**Context:** PR #23846: FFmpeg/4.x: update FFmpeg wrapper 2023.6 - Related PR in 3rdparty: https://github.com/opencv/opencv_3rdparty/pull/77 Previous FFmpeg Update...
**Review Line:** 3

**Code Changes:**
```diff
-ocv_update(FFMPEG_BINARIES_COMMIT "7dd0d4f1d6fe75f05f3d3b5e38cbc96c1a2d2809")
-ocv_update(FFMPEG_FILE_HASH_BIN32 "e598ae2ece1ddf310bc49b58202fd87a")
-ocv_update(FFMPEG_FILE_HASH_BIN64 "b2a40c142c20aef9fd663fc8f85c2971")
+# Binaries branch name: ffmpeg/4.x_20230622
+# Binaries were created for OpenCV: 61d48dd0f8d1cc1a115d26998705a61478f64a3c
+ocv_update(FFMPEG_BINARIES_COMMIT "7da61f0695eabf8972a2c302bf1632a3d99fb0d5")
+ocv_update(FFMPEG_FILE_HASH_BIN32 "4aaef1456e282e5ef665d65555f47f56")
+ocv_update(FFMPEG_FILE_HASH_BIN64 "38a638851e064c591ce812e27ed43f1f")
 ocv_update(FFMPEG_FILE_HASH_CMAKE "8862c87496e2e8c375965e1277dee1c7")
 
 function(download_win_ffmpeg script_var)
```

Review comment:
First 2 lines must be updated too.
**File:** modules/core/include/opencv2/core/mat.hpp
**Change Type:** modified
**Context:** PR #23832: Document parameters of multi-dimentional reshape
**Review Line:** 1337

**Code Changes:**
```diff
-    /** @overload */
+    /** @overload
+     * @param cn New number of channels. If the parameter is 0, the number of channels remains the same.
+     * @param newshape Vector with new matrix size by all dimentions. If some sizes are zero,
+     * the original sizes in those dimensions are presumed.
+     */
     Mat reshape(int cn, const std::vector<int>& newshape) const;
 
     /** @brief Transposes a matrix.
```

Review comment:
Added to the main description.
**File:** modules/python/src2/cv2_convert.cpp
**Change Type:** modified
**Context:** PR #23702: Python binding for RotatedRect
**Review Line:** 757

**Code Changes:**
```diff
 {
     if (!obj || obj == Py_None)
     {
         return true;
     }
+    // This is a workaround for compatibility with an initialization from tuple.
+    // Allows import RotatedRect as an object.
+    if (convertToRotatedRect(obj, dst))
+    {
+        return true;
+    }
```

Review comment:
After changing `CV_EXPORTS` to `CV_EXPORTS_W_SIMPLE` code generator produces `struct pyopencv_RotatedRect_t` as well as specialization of `struct PyOpenCV_Converter` for `cv::RotatedRect` (see: build/modules/python_bindings_generator/pyopencv_generated_types_content.h) Introducing one more `struct pyopencv_RotatedRect_t` in separate compilation unit leads to ODR violation. Templated version of `pyopencv_to` uses `PyOpenCV_Converter<T>::to` method if there is no specialization of `pyopencv_to` (`cv::RotatedRect` has it), so you can call `PyOpenCV_Converter<cv::RotatedRect>::to` and check against successful conversion. ```cpp template<> bool pyopencv_to(PyObject* obj, RotatedRect& dst, const ArgInfo& info) { if (!obj || obj == Py_None) { return true; } // Check if user passed `cv::RotatedRect` instance if (PyOpenCV_Converter<T>::to(obj, dst, info)) { return true; } PyErr_Clear(); // Fallback to [[center_x, center_y], [width, height], angle] parsing if (!PySequence_Check(obj)) { failmsg("Can't parse '%s' as RotatedRect." "Input argument is neither cv::RotatedRect object instance nor provides sequence protocol", info.name); return false; } ```