nareshmlx/opencv-pr huggingface dataset:
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
OpenCV drawing functions are not optimized at all. This change may bring unnecessary performance degradation to existed functionality. --- It is impossible to run UBSAN on that code (adding offset to NULL pointer is an ERROR). Adding one more check is performance degradation again. --- See comments in previous patch about that: #13843 (**mentioned** in PR description)
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #13869: LineVirtualIterator - Proposal of LineVirtualIterator, an alternative to "LineIterator not attached to any mat". This is basically the same...

**Code Changes:**
```diff
@@ -4714,10 +4714,39 @@ class CV_EXPORTS LineIterator
     the line is 8-connected or 4-connected
     If leftToRight=true, then the iteration is always done
     from the left-most point to the right most,
-    not to depend on the ordering of pt1 and pt2 parameters
+    not to depend on the ordering of pt1 and pt2 parameters;
     */
     LineIterator( const Mat& img, Point pt1, Point pt2,
-                  int connectivity = 8, bool leftToRight = false );
+                  int connectivity = 8, bool leftToRight = false )
```

Review comment:
ok, I've eliminated the performance degradation and also made the code UBSAN compatible
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #3554: [imgproc]Add template match with mask. - Signed-off-by: Yan Wang yan.wang@linux.intel.com

**Code Changes:**
```diff
@@ -3330,9 +3330,11 @@ data type.
 @param result Map of comparison results. It must be single-channel 32-bit floating-point. If image
 is \f$W \times H\f$ and templ is \f$w \times h\f$ , then result is \f$(W-w+1) \times (H-h+1)\f$ .
 @param method Parameter specifying the comparison method, see cv::TemplateMatchModes
+@param mask Mask of searched template. It must have the same datatype and size with templ. It is
+not set by default.
  */
 CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
-                                 OutputArray result, int method );
+                                 OutputArray result, int method, InputArray mask = noArray() );
```

Review comment:
I believe the introducing another one function is a wrong way. You can add an optional parameter to usual `matchTemplate` and check inside whether `_mask` is empty or not
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #3554: [imgproc]Add template match with mask. - Signed-off-by: Yan Wang yan.wang@linux.intel.com

**Code Changes:**
```diff
@@ -3330,9 +3330,11 @@ data type.
 @param result Map of comparison results. It must be single-channel 32-bit floating-point. If image
 is \f$W \times H\f$ and templ is \f$w \times h\f$ , then result is \f$(W-w+1) \times (H-h+1)\f$ .
 @param method Parameter specifying the comparison method, see cv::TemplateMatchModes
+@param mask Mask of searched template. It must have the same datatype and size with templ. It is
+not set by default.
  */
 CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
-                                 OutputArray result, int method );
+                                 OutputArray result, int method, InputArray mask = noArray() );
```

Review comment:
Please add a name for the new parameter (`mask`), so it will be clear what does the parameter used for.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #3554: [imgproc]Add template match with mask. - Signed-off-by: Yan Wang yan.wang@linux.intel.com

**Code Changes:**
```diff
@@ -3330,9 +3330,11 @@ data type.
 @param result Map of comparison results. It must be single-channel 32-bit floating-point. If image
 is \f$W \times H\f$ and templ is \f$w \times h\f$ , then result is \f$(W-w+1) \times (H-h+1)\f$ .
 @param method Parameter specifying the comparison method, see cv::TemplateMatchModes
+@param mask Mask of searched template. It must have the same datatype and size with templ. It is
+not set by default.
  */
 CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
-                                 OutputArray result, int method );
+                                 OutputArray result, int method, InputArray mask = noArray() );
```

Review comment:
Sorry. It is may fault. I will add it.
**File:** samples/cpp/mask_tmpl.cpp
**Change Type:** added
**Context:** PR #3554: [imgproc]Add template match with mask. - Signed-off-by: Yan Wang yan.wang@linux.intel.com

**Code Changes:**
```diff
@@ -0,0 +1,72 @@
+#include "opencv2/imgproc.hpp"
+#include "opencv2/highgui.hpp"
+
+#include <cctype>
+#include <iostream>
+#include <iterator>
+#include <stdio.h>
+
+using namespace std;
```

Review comment:
Should it be `argv[3]`?
**File:** samples/cpp/mask_tmpl.cpp
**Change Type:** added
**Context:** PR #3554: [imgproc]Add template match with mask. - Signed-off-by: Yan Wang yan.wang@linux.intel.com

**Code Changes:**
```diff
@@ -0,0 +1,72 @@
+#include "opencv2/imgproc.hpp"
+#include "opencv2/highgui.hpp"
+
+#include <cctype>
+#include <iostream>
+#include <iterator>
+#include <stdio.h>
+
+using namespace std;
```

Review comment:
Yes. It is typo. Sorry.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #3554: [imgproc]Add template match with mask. - Signed-off-by: Yan Wang yan.wang@linux.intel.com
**Review Line:** 3337

**Code Changes:**
```diff
+@param mask Mask of searched template. It must have the same datatype and size with templ. It is
+not set by default.
  */
 CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
-                                 OutputArray result, int method );
+                                 OutputArray result, int method, InputArray mask = noArray() );
 
 //! @}
 
```

Review comment:
Last remark :smile: Please add a doxygen documentation for the mask parameter (http://pullrequest.opencv.org/buildbot/builders/precommit_docs/builds/2125/steps/make%20doxygen/logs/warnings%20%281%29).
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #3554: [imgproc]Add template match with mask. - Signed-off-by: Yan Wang yan.wang@linux.intel.com
**Review Line:** 3337

**Code Changes:**
```diff
+@param mask Mask of searched template. It must have the same datatype and size with templ. It is
+not set by default.
  */
 CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ,
-                                 OutputArray result, int method );
+                                 OutputArray result, int method, InputArray mask = noArray() );
 
 //! @}
 
```

Review comment:
Sure. I will. :)
**File:** modules/imgproc/src/templmatch.cpp
**Change Type:** modified
**Context:** PR #3554: [imgproc]Add template match with mask. - Signed-off-by: Yan Wang yan.wang@linux.intel.com
**Review Line:** 847

**Code Changes:**
```diff
+    if (mdepth == CV_8U)
+    {
+        mdepth = CV_32F;
+        mtype = CV_MAKETYPE(CV_32F, mcn);
+        compare(mask, Scalar::all(0), mask, CMP_NE);
+        mask.convertTo(mask, mtype, 1.0 / 255);
+    }
+
+    Size corrSize(img.cols - templ.cols + 1, img.rows - templ.rows + 1);
+    _result.create(corrSize, CV_32F);
+    Mat result = _result.getMat();
```

Review comment:
it should probably be (mask != 0).convertTo(mask, mtype, 1.0/255);
**File:** modules/imgproc/src/templmatch.cpp
**Change Type:** modified
**Context:** PR #3554: [imgproc]Add template match with mask. - Signed-off-by: Yan Wang yan.wang@linux.intel.com

**Code Changes:**
```diff
@@ -814,12 +814,97 @@ void crossCorr( const Mat& img, const Mat& _templ, Mat& corr,
         }
     }
 }
+
+static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _result, int method, InputArray _mask )
+{
+    int type = _img.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
+    CV_Assert( CV_TM_SQDIFF <= method && method <= CV_TM_CCOEFF_NORMED );
+    CV_Assert( (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 );
```

Review comment:
this is bug. CV_Error(Error::StsNotImplemented, "") should be called here
**File:** modules/imgproc/src/templmatch.cpp
**Change Type:** modified
**Context:** PR #3554: [imgproc]Add template match with mask. - Signed-off-by: Yan Wang yan.wang@linux.intel.com
**Review Line:** 894

**Code Changes:**
```diff
+        sqrt(corr, corr);
+        result = result.mul(1/corr);
+        result /= std::sqrt(templSum2);
+    }
+    else
+        CV_Error(Error::StsNotImplemented, "");
+}
 }
 
 ////////////////////////////////////////////////////////////////////////////////////////////////////////
 
```

Review comment:
The fact that this does not implement anything but SQDIFF and CCORR_NORMED would be very helpful to have documented.
**File:** modules/calib3d/test/test_translation3d_estimator.cpp
**Change Type:** added
**Context:** PR #16614: added estimateTranslation3D to calib3d/ptsetreg

**Code Changes:**
```diff
@@ -0,0 +1,100 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+
+
+#include "test_precomp.hpp"
+
+namespace opencv_test { namespace {
+
```

Review comment:
Please use short license header: https://github.com/opencv/opencv/wiki/Coding_Style_Guide#file-structure ``` // 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. ```
**File:** modules/calib3d/src/ptsetreg.cpp
**Change Type:** modified
**Context:** PR #16614: added estimateTranslation3D to calib3d/ptsetreg

**Code Changes:**
```diff
@@ -505,6 +505,86 @@ class Affine3DEstimatorCallback : public PointSetRegistrator::Callback
     }
 };
 
+
+/*
+ * Compute
+ *  x      X     t1
+ *  y  =   Y  +  t2
+ *  z      Z     t3
```

Review comment:
Consider using `Matx13d` instead. ```.diff -T.copyTo(_model); +Mat(T, false).copyTo(_model); ```
**File:** modules/calib3d/src/ptsetreg.cpp
**Change Type:** modified
**Context:** PR #16614: added estimateTranslation3D to calib3d/ptsetreg

**Code Changes:**
```diff
@@ -505,6 +505,86 @@ class Affine3DEstimatorCallback : public PointSetRegistrator::Callback
     }
 };
 
+
+/*
+ * Compute
+ *  x      X     t1
+ *  y  =   Y  +  t2
+ *  z      Z     t3
```

Review comment:
`T *= (1.0f / 4);` ?
**File:** modules/calib3d/src/ptsetreg.cpp
**Change Type:** modified
**Context:** PR #16614: added estimateTranslation3D to calib3d/ptsetreg

**Code Changes:**
```diff
@@ -505,6 +505,86 @@ class Affine3DEstimatorCallback : public PointSetRegistrator::Callback
     }
 };
 
+
+/*
+ * Compute
+ *  x      X     t1
+ *  y  =   Y  +  t2
+ *  z      Z     t3
```

Review comment:
Done! Also required modifying `test_translation3d_estimator` to use the new data type
**File:** modules/imgproc/src/thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -1125,31 +1125,24 @@ static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size
 }
 #endif
 
-static double
-getThreshVal_Otsu_8u( const Mat& _src )
+template<typename T, size_t BinsOnStack = 0u>
+static double getThreshVal_Otsu( const Mat& _src, const Size& size)
 {
-    Size size = _src.size();
```

Review comment:
You are working with garbage uninitialized data. Use `std::vector<int>` instead or `cv::AutoBuffer`.
**File:** modules/imgproc/test/test_thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -46,7 +46,7 @@ namespace opencv_test { namespace {
 class CV_ThreshTest : public cvtest::ArrayTest
 {
 public:
-    CV_ThreshTest();
+    CV_ThreshTest(int test_type = 0);
 
 protected:
     void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
@@ -57,16 +57,22 @@ class CV_ThreshTest : public cvtest::ArrayTest
```

Review comment:
"C" asserts are banned in OpenCV including test code. Use `CV_Assert()` instead.
**File:** modules/imgproc/src/thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -1125,31 +1125,24 @@ static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size
 }
 #endif
 
-static double
-getThreshVal_Otsu_8u( const Mat& _src )
+template<typename T, size_t BinsOnStack = 0u>
+static double getThreshVal_Otsu( const Mat& _src, const Size& size)
 {
-    Size size = _src.size();
```

Review comment:
Huge amount of duplicated code: >50 lines Template should be used.
**File:** modules/imgproc/src/thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -1125,31 +1125,24 @@ static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size
 }
 #endif
 
-static double
-getThreshVal_Otsu_8u( const Mat& _src )
+template<typename T, size_t BinsOnStack = 0u>
+static double getThreshVal_Otsu( const Mat& _src, const Size& size)
 {
-    Size size = _src.size();
```

Review comment:
Avoid emitting of unclear messages from `CV_Assert()`. ``` int src_type = src.type(); CV_CheckType(src_type, src_type == CV_8UC1 || src_type == CV_16UC1, "THRESH_OTSU mode"); ```
**File:** modules/imgproc/src/thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -1125,31 +1125,24 @@ static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size
 }
 #endif
 
-static double
-getThreshVal_Otsu_8u( const Mat& _src )
+template<typename T, size_t BinsOnStack = 0u>
+static double getThreshVal_Otsu( const Mat& _src, const Size& size)
 {
-    Size size = _src.size();
```

Review comment:
It is initialized to 0 on line 1222, but switching to `cv::AutoBuffer` sounds like a good idea, especially if I'm to combine 8-bit and 16-bit Otsu
**File:** modules/imgproc/src/thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -1125,31 +1125,24 @@ static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size
 }
 #endif
 
-static double
-getThreshVal_Otsu_8u( const Mat& _src )
+template<typename T, size_t BinsOnStack = 0u>
+static double getThreshVal_Otsu( const Mat& _src, const Size& size)
 {
-    Size size = _src.size();
```

Review comment:
Please add one more explicit template parameter for this code block: ``` #if CV_ENABLE_UNROLLED AutoBuffer<int, 4 * BinsOnStack> hBuf(4 * N); #else AutoBuffer<int, BinsOnStack> hBuf(N); #endif ``` Usage: - `getThreshVal_Otsu<uchar, 256>(_src, size)` - `getThreshVal_Otsu<ushort, 0>(_src, size)`
**File:** modules/imgproc/src/thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -1125,31 +1125,24 @@ static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size
 }
 #endif
 
-static double
-getThreshVal_Otsu_8u( const Mat& _src )
+template<typename T, size_t BinsOnStack = 0u>
+static double getThreshVal_Otsu( const Mat& _src, const Size& size)
 {
-    Size size = _src.size();
```

Review comment:
```.diff -&_src.at<T> +_src.ptr<T> ```
**File:** modules/imgproc/src/thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -1125,31 +1125,24 @@ static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size
 }
 #endif
 
-static double
-getThreshVal_Otsu_8u( const Mat& _src )
+template<typename T, size_t BinsOnStack = 0u>
+static double getThreshVal_Otsu( const Mat& _src, const Size& size)
 {
-    Size size = _src.size();
```

Review comment:
``` #else CV_UNUSED(step); #endif ``` and remove `#ifdef HAVE_IPP` guards above.
**File:** modules/imgproc/src/thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -1125,31 +1125,24 @@ static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size
 }
 #endif
 
-static double
-getThreshVal_Otsu_8u( const Mat& _src )
+template<typename T, size_t BinsOnStack = 0u>
+static double getThreshVal_Otsu( const Mat& _src, const Size& size)
 {
-    Size size = _src.size();
```

Review comment:
Please add "static" and one more template parameter (see below): ``` template<typename T, int BinsOnStack = 0> static double getThreshVal_Otsu(const Mat& src_, const Size& size) ```
**File:** modules/imgproc/src/thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -1125,31 +1125,24 @@ static bool ipp_getThreshVal_Otsu_8u( const unsigned char* _src, int step, Size
 }
 #endif
 
-static double
-getThreshVal_Otsu_8u( const Mat& _src )
+template<typename T, size_t BinsOnStack = 0u>
+static double getThreshVal_Otsu( const Mat& _src, const Size& size)
 {
-    Size size = _src.size();
```

Review comment:
`;;` - remove one
**File:** modules/imgproc/test/test_thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -46,7 +46,7 @@ namespace opencv_test { namespace {
 class CV_ThreshTest : public cvtest::ArrayTest
 {
 public:
-    CV_ThreshTest();
+    CV_ThreshTest(int test_type = 0);
 
 protected:
     void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
@@ -57,16 +57,22 @@ class CV_ThreshTest : public cvtest::ArrayTest
```

Review comment:
Please use 4 spaces for indentation
**File:** modules/imgproc/test/test_thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -46,7 +46,7 @@ namespace opencv_test { namespace {
 class CV_ThreshTest : public cvtest::ArrayTest
 {
 public:
-    CV_ThreshTest();
+    CV_ThreshTest(int test_type = 0);
 
 protected:
     void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
@@ -57,16 +57,22 @@ class CV_ThreshTest : public cvtest::ArrayTest
```

Review comment:
cv::Mat looks like overkill here. ``` std::vector<int> h(N, 0); ```
**File:** modules/imgproc/test/test_thresh.cpp
**Change Type:** modified
**Context:** PR #16640: Enable Otsu thresholding for CV_16UC1 images - Add getThreshVal_Otsu_16u, which is almost a literal copy of getThreshVal_Otsu_8u, except th...

**Code Changes:**
```diff
@@ -46,7 +46,7 @@ namespace opencv_test { namespace {
 class CV_ThreshTest : public cvtest::ArrayTest
 {
 public:
-    CV_ThreshTest();
+    CV_ThreshTest(int test_type = 0);
 
 protected:
     void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
@@ -57,16 +57,22 @@ class CV_ThreshTest : public cvtest::ArrayTest
```

Review comment:
Consider casting both parts to the same type explicitly. ```.diff -const ushort val = depth == CV_16UC1 ? _src.at<ushort>(i, j) : _src.at<uchar>(i,j); +const int val = depth == CV_16UC1 ? (int)_src.at<ushort>(i, j) : (int)_src.at<uchar>(i,j); ``` (int => unsigned should work too)
**File:** cmake/OpenCVFindLibsGrfmt.cmake
**Change Type:** modified
**Context:** PR #16494: RFC: Jpeg2000 OpenJPEG port - resolves #5849 relates #14058 Currently missing/incomplete: - [x] Write support - [ ] Reading of "signed" com...

**Code Changes:**
```diff
@@ -153,8 +153,23 @@ if(NOT WEBP_VERSION AND WEBP_INCLUDE_DIR)
   endif()
 endif()
 
+# --- libopenjp2 (optional, check before libjasper) ---
+if(WITH_OPENJPEG)
+  find_package(OpenJPEG QUIET)
+
+  if(NOT OpenJPEG_FOUND OR OPENJPEG_MAJOR_VERSION LESS 2)
+    set(HAVE_OPENJPEG NO)
```

Review comment:
> find_package(OpenJPEG QUIET) > message(...) > message(...) What if we remove QUIET and following `message()` lines? What is the difference?
**File:** cmake/OpenCVFindLibsGrfmt.cmake
**Change Type:** modified
**Context:** PR #16494: RFC: Jpeg2000 OpenJPEG port - resolves #5849 relates #14058 Currently missing/incomplete: - [x] Write support - [ ] Reading of "signed" com...

**Code Changes:**
```diff
@@ -153,8 +153,23 @@ if(NOT WEBP_VERSION AND WEBP_INCLUDE_DIR)
   endif()
 endif()
 
+# --- libopenjp2 (optional, check before libjasper) ---
+if(WITH_OPENJPEG)
+  find_package(OpenJPEG QUIET)
+
+  if(NOT OpenJPEG_FOUND OR OPENJPEG_MAJOR_VERSION LESS 2)
+    set(HAVE_OPENJPEG NO)
```

Review comment:
The QUIET actually has no effect, OpenJPEGConfig.cmake has no message()s at all.
**File:** cmake/OpenCVFindLibsGrfmt.cmake
**Change Type:** modified
**Context:** PR #16494: RFC: Jpeg2000 OpenJPEG port - resolves #5849 relates #14058 Currently missing/incomplete: - [x] Write support - [ ] Reading of "signed" com...

**Code Changes:**
```diff
@@ -153,8 +153,23 @@ if(NOT WEBP_VERSION AND WEBP_INCLUDE_DIR)
   endif()
 endif()
 
+# --- libopenjp2 (optional, check before libjasper) ---
+if(WITH_OPENJPEG)
+  find_package(OpenJPEG QUIET)
+
+  if(NOT OpenJPEG_FOUND OR OPENJPEG_MAJOR_VERSION LESS 2)
+    set(HAVE_OPENJPEG NO)
```

Review comment:
Removed the "QUIET"
**File:** cmake/OpenCVFindLibsGrfmt.cmake
**Change Type:** modified
**Context:** PR #16494: RFC: Jpeg2000 OpenJPEG port - resolves #5849 relates #14058 Currently missing/incomplete: - [x] Write support - [ ] Reading of "signed" com...

**Code Changes:**
```diff
@@ -153,8 +153,23 @@ if(NOT WEBP_VERSION AND WEBP_INCLUDE_DIR)
   endif()
 endif()
 
+# --- libopenjp2 (optional, check before libjasper) ---
+if(WITH_OPENJPEG)
+  find_package(OpenJPEG QUIET)
+
+  if(NOT OpenJPEG_FOUND OR OPENJPEG_MAJOR_VERSION LESS 2)
+    set(HAVE_OPENJPEG NO)
```

Review comment:
Please return "QUIET" and messages back (OpenJPEG is not a regular CMake module, so large warning are showed if it is not available)