nareshmlx/opencv-pr huggingface dataset:
**File:** modules/imgcodecs/src/grfmt_png.cpp
**Change Type:** modified
**Context:** PR #26835: Corrections on bKGD chunk writing and reading in PNG
**Review Line:** 726

**Code Changes:**
```diff
+        // 8=HDR+size, (1, 2 or 6)=size of bKGD chunk, 4=CRC
         // The spec is actually more complex:
         // http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD
-        // TODO: we only check that 4 bytes can be read from &chunk.p[8]. Fix.
-        if (size < 8 + 4)
+        if (size != 8 + 1 + 4 && size != 8 + 2 + 4 && size != 8 + 6 + 4)
             return 0;
     } else if (id != id_fdAT && id != id_IDAT && id != id_IEND && id != id_PLTE && id != id_tRNS) {
         if (size > PNG_USER_CHUNK_MALLOC_MAX)
@@ -1533,13 +1531,13 @@ bool PngEncoder::writeanimation(const Animation& animation, const std::vector<in
         if (palsize > 0)
```

Review comment:
Thx, I had forgotten the CRC !
**File:** modules/imgcodecs/perf/perf_decode_encode.cpp
**Change Type:** added
**Context:** PR #26872: Performance tests for image encoders and decoders and code cleanup
**Review Line:** 70

**Code Changes:**
```diff
+
+PERF_TEST_P(Decode, bgr, testing::ValuesIn(exts))
+{
+    String filename = getDataPath("perf/1920x1080.png");
+
+    Mat src = imread(filename);
+    EXPECT_FALSE(src.empty()) << "Cannot open test image perf/1920x1080.png";
+    vector<uchar> buf;
+    EXPECT_TRUE(imencode(GetParam(), src, buf));
+
+    TEST_CYCLE() imdecode(buf, IMREAD_UNCHANGED);
```

Review comment:
`EXPECT_FALSE(src.empty()) << Cannot open test image perf/1920x1080.png`;
**File:** modules/imgcodecs/perf/perf_decode_encode.cpp
**Change Type:** added
**Context:** PR #26872: Performance tests for image encoders and decoders and code cleanup
**Review Line:** 84

**Code Changes:**
```diff
+
+PERF_TEST_P(Decode, rgb, testing::ValuesIn(exts))
+{
+    String filename = getDataPath("perf/1920x1080.png");
+
+    Mat src = imread(filename);
+    EXPECT_FALSE(src.empty()) << "Cannot open test image perf/1920x1080.png";
+    vector<uchar> buf;
+    EXPECT_TRUE(imencode(GetParam(), src, buf));
+
+    TEST_CYCLE() imdecode(buf, IMREAD_COLOR_RGB);
```

Review comment:
`EXPECT_FALSE(src.empty()) << Cannot open test image perf/1920x1080.png;`
**File:** modules/imgcodecs/perf/perf_decode_encode.cpp
**Change Type:** added
**Context:** PR #26872: Performance tests for image encoders and decoders and code cleanup

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

Review comment:
Add sanity check if the file read correctly.
**File:** modules/core/src/norm.cpp
**Change Type:** modified
**Context:** PR #26804: Add RISC-V HAL implementation for cv::norm and cv::normalize
**Review Line:** 630

**Code Changes:**
```diff
     Mat src = _src.getMat(), mask = _mask.getMat();
+    int depth = src.depth(), cn = src.channels();
+    if( src.dims <= 2 )
+    {
+        double result;
+        CALL_HAL_RET(norm, cv_hal_norm, result, src.data, src.step, mask.data, mask.step, src.cols, src.rows, src.type(), normType);
+    }
+    else if( src.isContinuous() && mask.isContinuous() )
+    {
+        double result;
+        CALL_HAL_RET(norm, cv_hal_norm, result, src.data, 0, mask.data, 0, (int)src.total(), 1, src.type(), normType);
```

Review comment:
Usually we have HAL call before IPP branch (and after OCL).
**File:** modules/core/src/norm.cpp
**Change Type:** modified
**Context:** PR #26804: Add RISC-V HAL implementation for cv::norm and cv::normalize
**Review Line:** 1127

**Code Changes:**
```diff
+    Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
+    int depth = src1.depth(), cn = src1.channels();
+    if( src1.dims <= 2 )
+    {
+        double result;
+        CALL_HAL_RET(normDiff, cv_hal_normDiff, result, src1.data, src1.step, src2.data, src2.step, mask.data, mask.step, src1.cols, src1.rows, src1.type(), normType);
+    }
+    else if( src1.isContinuous() && src2.isContinuous() && mask.isContinuous() )
+    {
+        double result;
+        CALL_HAL_RET(normDiff, cv_hal_normDiff, result, src1.data, 0, src2.data, 0, mask.data, 0, (int)src1.total(), 1, src1.type(), normType);
```

Review comment:
Usually we have HAL call before IPP branch (and after OCL).
**File:** modules/core/src/norm.cpp
**Change Type:** modified
**Context:** PR #26804: Add RISC-V HAL implementation for cv::norm and cv::normalize
**Review Line:** 1127

**Code Changes:**
```diff
+    Mat src1 = _src1.getMat(), src2 = _src2.getMat(), mask = _mask.getMat();
+    int depth = src1.depth(), cn = src1.channels();
+    if( src1.dims <= 2 )
+    {
+        double result;
+        CALL_HAL_RET(normDiff, cv_hal_normDiff, result, src1.data, src1.step, src2.data, src2.step, mask.data, mask.step, src1.cols, src1.rows, src1.type(), normType);
+    }
+    else if( src1.isContinuous() && src2.isContinuous() && mask.isContinuous() )
+    {
+        double result;
+        CALL_HAL_RET(normDiff, cv_hal_normDiff, result, src1.data, 0, src2.data, 0, mask.data, 0, (int)src1.total(), 1, src1.type(), normType);
```

Review comment:
Fixed. `ipp_norm` supports CV_RELATIVE, so I have to modify HAL implement to move CALL_HAL before IPP.
**File:** modules/core/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #26789: Add RISC-V HAL implementation for minMaxIdx
**Review Line:** 912

**Code Changes:**
```diff
@@ -911,8 +911,26 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s
 inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, int depth, double* minVal, double* maxVal,
                             int* minIdx, int* maxIdx, uchar* mask) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
 
+/**
+   @brief Finds the global minimum and maximum in an array.
+   @param src_data Source image
+   @param src_step Source image
```

Review comment:
It breaks existing HAL implementations.
**File:** modules/core/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #26789: Add RISC-V HAL implementation for minMaxIdx
**Review Line:** 912

**Code Changes:**
```diff
@@ -911,8 +911,26 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s
 inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, int depth, double* minVal, double* maxVal,
                             int* minIdx, int* maxIdx, uchar* mask) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
 
+/**
+   @brief Finds the global minimum and maximum in an array.
+   @param src_data Source image
+   @param src_step Source image
```

Review comment:
Should I create a new HAL interface, or just simply remove these lines below? https://github.com/opencv/opencv/blob/133fda3c56bc7199de86c94f1522d56d7253bc6a/modules/core/src/minmax.cpp#L1515-L1519 Without `mask_step` argument, it is impossible to implement the HAL when mask is not continuous.
**File:** modules/core/src/hal_replacement.hpp
**Change Type:** modified
**Context:** PR #26789: Add RISC-V HAL implementation for minMaxIdx
**Review Line:** 912

**Code Changes:**
```diff
@@ -911,8 +911,26 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s
 inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, int height, int depth, double* minVal, double* maxVal,
                             int* minIdx, int* maxIdx, uchar* mask) { return CV_HAL_ERROR_NOT_IMPLEMENTED; }
 
+/**
+   @brief Finds the global minimum and maximum in an array.
+   @param src_data Source image
+   @param src_step Source image
```

Review comment:
I have tried to keep the ABI by creating a new interface.
**File:** 3rdparty/hal_rvv/hal_rvv_1p0/minmax.hpp
**Change Type:** added
**Context:** PR #26789: Add RISC-V HAL implementation for minMaxIdx

**Code Changes:**
```diff
@@ -0,0 +1,335 @@
+// This file is part of OpenCV project.
+// It is subject to the license terms in the LICENSE file found in the top-level directory
+// of this distribution and at http://opencv.org/license.html.
+#ifndef OPENCV_HAL_RVV_MINMAXIDX_HPP_INCLUDED
+#define OPENCV_HAL_RVV_MINMAXIDX_HPP_INCLUDED
+
+#include <riscv_vector.h>
+
+namespace cv { namespace cv_hal_rvv {
```

Review comment:
In general it is hard to debug multi-line macros. C++ template-based approach is preferable.
**File:** 3rdparty/ippicv/ippicv.cmake
**Change Type:** modified
**Context:** PR #26463: Update IPP integration - Please merge together with https://github.com/opencv/opencv_3rdparty/pull/88 Supported IPP version was updated to ...
**Review Line:** 5

**Code Changes:**
```diff
@@ -2,7 +2,7 @@ function(download_ippicv root_var)
   set(${root_var} "" PARENT_SCOPE)
 
   # Commit SHA in the opencv_3rdparty repo
-  set(IPPICV_COMMIT "7f55c0c26be418d494615afca15218566775c725")
+  set(IPPICV_COMMIT "d1cbea44d326eb0421fedcdd16de4630fd8c7ed0")
   # Define actual ICV versions
   if(APPLE)
     set(IPPICV_COMMIT "0cc4aa06bf2bef4b05d237c69a5a96b9cd0cb85a")
@@ -14,19 +14,21 @@ function(download_ippicv root_var)
     set(OPENCV_ICV_PLATFORM "linux")
```

Review comment:
- [ ] Shouldn't it be different for x86 and x86_64 as only x86_64 ICV packages are available since IPP 2022.0.0?
**File:** modules/imgproc/src/filter.hpp
**Change Type:** modified
**Context:** PR #26850: Update includes in filter.hpp
**Review Line:** 47

**Code Changes:**
```diff
@@ -43,6 +43,9 @@
 #ifndef OPENCV_IMGPROC_FILTER_HPP
 #define OPENCV_IMGPROC_FILTER_HPP
 
+#include <opencv2/core.hpp>
+#include <vector>
+
 namespace cv
 {
 #ifdef HAVE_OPENCL
```

Review comment:
please add space before namespace.
**File:** modules/videoio/src/cap_android_camera.cpp
**Change Type:** modified
**Context:** PR #26837: Zoom functionality for Android native camera capture
**Review Line:** 433

**Code Changes:**
```diff
                 {
@@ -437,6 +430,12 @@ class AndroidCameraCapture : public IVideoCapture
                     return submitRequest(ACaptureRequest_setEntry_i32, ACAMERA_SENSOR_SENSITIVITY, sensitivity);
                 }
                 return false;
+            case CAP_PROP_ZOOM:
+                if (isOpened() && zoomRange.isValid()) {
+                    zoomRatio = zoomRange.clamp(static_cast<float>(value));
+                    return submitRequest(ACaptureRequest_setEntry_float, ACAMERA_CONTROL_ZOOM_RATIO, zoomRatio);
+                }
+                return true;
```

Review comment:
I propose to document the option for Android in https://github.com/opencv/opencv/blob/ab77e1cfc87d7908c09fa4d11cbeaac9e4c663fb/modules/videoio/include/opencv2/videoio.hpp#L171.
**File:** modules/imgproc/include/opencv2/imgproc.hpp
**Change Type:** modified
**Context:** PR #26836: Add cv::THRESH_DRYRUN flag to get adaptive threshold values without thresholding

**Code Changes:**
```diff
@@ -329,7 +329,8 @@ enum ThresholdTypes {
     THRESH_TOZERO_INV = 4, //!< \f[\texttt{dst} (x,y) =  \fork{0}{if \(\texttt{src}(x,y) > \texttt{thresh}\)}{\texttt{src}(x,y)}{otherwise}\f]
     THRESH_MASK       = 7,
     THRESH_OTSU       = 8, //!< flag, use Otsu algorithm to choose the optimal threshold value
-    THRESH_TRIANGLE   = 16 //!< flag, use Triangle algorithm to choose the optimal threshold value
+    THRESH_TRIANGLE   = 16, //!< flag, use Triangle algorithm to choose the optimal threshold value
+    THRESH_DRYRUN     = 128 //!< flag, compute threshold only (useful for OTSU/TRIANGLE) but does not actually run thresholding
 };
 
 //! adaptive threshold algorithm
```

Review comment:
The name is very controversial. I propose `THRESH_DRYRUN` or something similar.
**File:** modules/imgproc/test/ocl/test_imgproc.cpp
**Change Type:** modified
**Context:** PR #26836: Add cv::THRESH_DRYRUN flag to get adaptive threshold values without thresholding

**Code Changes:**
```diff
@@ -386,6 +386,40 @@ OCL_TEST_P(Threshold, Mat)
     }
 }
 
+struct Threshold_Dryrun :
+        public ImgprocTestBase
+{
+    int thresholdType;
+
+    virtual void SetUp()
```

Review comment:
Dryrun in naming too.
**File:** modules/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #26669: solvePnPRansac implementation for Fisheye camera model

**Code Changes:**
```diff
@@ -4075,6 +4075,40 @@ optimization. It is the \f$max(width,height)/\pi\f$ or the provided \f$f_x\f$, \
     the provided rvec and tvec values as initial approximations of the rotation and translation
     vectors, respectively, and further optimizes them.
     @param flags Method for solving a PnP problem: see @ref calib3d_solvePnP_flags
+    @param criteria Termination criteria for internal undistortPoints call.
+    The function interally undistorts points with @ref undistortPoints and call @ref cv::solvePnP,
+    thus the input are very similar. More information about Perspective-n-Points is described in @ref calib3d_solvePnP
+    for more information.
+    */
+    CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints,
```

Review comment:
I propose to use the same description as for cv::solvePnpRansac with fisheye model reference and add reference to SOLVEPNP_XXX constants instead of copy.
**File:** doc/opencv.bib
**Change Type:** modified
**Context:** PR #26754: Add direct pdf links in the bibliography
**Review Line:** 1100

**Code Changes:**
```diff
   number = {5},
   pages = {717-721},
   doi = {10.1109/70.326576},
-  issn = {1042-296X}
+  issn = {1042-296X},
+  url = {https://drive.google.com/file/d/1t1uoki3_qOXHMmWq5ixqQcALlEIJzTMh/view}
 }
 @inproceedings{PM03,
   author = {P{\'e}rez, Patrick and Gangnet, Michel and Blake, Andrew},
@@ -867,15 +1107,17 @@ @inproceedings{PM03
   pages = {313--318},
```

Review comment:
This link comes from: https://sites.google.com/robotics.snu.ac.kr/fcp/publications/articles See: ![image](https://github.com/user-attachments/assets/8d31ba70-6e0b-4c59-9cc8-428df9d4a91f)
**File:** doc/opencv.bib
**Change Type:** modified
**Context:** PR #26754: Add direct pdf links in the bibliography

**Code Changes:**
```diff
@@ -15,7 +15,7 @@ @article{ANB13
   pages = {13.1--13.11},
   publisher = {{BMVA} Press},
   year = {2013},
-  url = {https://doi.org/10.5244/C.27.13},
+  url = {https://projet.liris.cnrs.fr/imagine/pub/proceedings/BMVC-2013/Papers/paper0013/paper0013.pdf},
   doi = {10.5244/C.27.13},
   timestamp = {Sat, 09 Apr 2022 12:44:13 +0200},
   biburl = {https://dblp.org/rec/conf/bmvc/AlcantarillaNB13.bib},
@@ -31,7 +31,7 @@ @inproceedings{Andreff99
```

Review comment:
Lukas and Kanade are names. Capital letters.
**File:** doc/opencv.bib
**Change Type:** modified
**Context:** PR #26754: Add direct pdf links in the bibliography
**Review Line:** 369

**Code Changes:**
```diff
   journal = {International Journal of Robotics Research},
   year = {1998},
   volume = {18},
-  pages = {286--298}
+  pages = {286--298},
+  url = {https://typeset.io/pdf/hand-eye-calibration-using-dual-quaternions-1boiebmyns.pdf}
 }
 @inproceedings{DM03,
   author = {Drago, Fr{\'e}d{\'e}ric and Myszkowski, Karol and Annen, Thomas and Chiba, Norishige},
@@ -276,7 +377,7 @@ @inproceedings{DM03
   volume = {22},
```

Review comment:
The link returns 403
**File:** doc/opencv.bib
**Change Type:** modified
**Context:** PR #26754: Add direct pdf links in the bibliography
**Review Line:** 369

**Code Changes:**
```diff
   journal = {International Journal of Robotics Research},
   year = {1998},
   volume = {18},
-  pages = {286--298}
+  pages = {286--298},
+  url = {https://typeset.io/pdf/hand-eye-calibration-using-dual-quaternions-1boiebmyns.pdf}
 }
 @inproceedings{DM03,
   author = {Drago, Fr{\'e}d{\'e}ric and Myszkowski, Karol and Annen, Thomas and Chiba, Norishige},
@@ -276,7 +377,7 @@ @inproceedings{DM03
   volume = {22},
```

Review comment:
In my location, the link is OK. I don't know how to proceed. ![image](https://github.com/user-attachments/assets/c06f60cc-22f8-480c-a68d-05a361d14de1)
**File:** doc/opencv.bib
**Change Type:** modified
**Context:** PR #26754: Add direct pdf links in the bibliography
**Review Line:** 1500

**Code Changes:**
```diff
   journal = {Image and Vision Computing},
   volume = {8},
   number = {1},
-  publisher = {Elsevier}
+  publisher = {Elsevier},
+  url = {https://typeset.io/pdf/a-comparative-study-of-hough-transform-methods-for-circle-2mzwteha3d.pdf}
 }
 @incollection{Zach2007,
   author = {Zach, Christopher and Pock, Thomas and Bischof, Horst},
   title = {A duality based approach for realtime TV-L 1 optical flow},
   booktitle = {Pattern Recognition},
```

Review comment:
Same, the link is ok for me: ![image](https://github.com/user-attachments/assets/172fee9b-e079-4e4a-b67d-ff54557637b6)
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later

**Code Changes:**
```diff
@@ -94,17 +94,20 @@ FOREACH(SEARCH_PATH ${SEARCH_PATHS})
             IF (${contents} MATCHES "#define OPENEXR_VERSION_MINOR ([0-9]+)")
                 SET(OPENEXR_VERSION_MINOR "${CMAKE_MATCH_1}")
             ENDIF ()
+            FILE (STRINGS ${OPENEXR_VERSION_FILE} contents REGEX "#define OPENEXR_VERSION_PATCH ")
+            IF (${contents} MATCHES "#define OPENEXR_VERSION_PATCH ([0-9]+)")
+                SET(OPENEXR_VERSION_PATCH "${CMAKE_MATCH_1}")
+            ENDIF ()
         ENDIF ()
     ENDIF ()
```

Review comment:
> `STRLESS` > `"2_3"` Why is not `VERSION_LESS`? > OPENEXR_VERSION=2.3.0
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 154

**Code Changes:**
```diff
   if(NOT OPENEXR_VERSION)
     SET(OPENEXR_VERSION "Unknown")
+  else()
+    if(HAVE_CXX17 AND OPENEXR_VERSION VERSION_LESS "2.3.0")
+      message(STATUS "  OpenEXR(ver ${OPENEXR_VERSION}) doesn't support C++17 and higher. Updating OpenEXR 2.3.0+ is required.")
+      SET(OPENEXR_FOUND FALSE)
+    endif()
   endif()
 ELSE()
   IF(OPENEXR_FIND_REQUIRED)
```

Review comment:
This may be a fix for 4.x but definitely not for https://github.com/opencv/opencv/issues/26673 or 5.x. Compile standard of 5.x has been switched to C++17.
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later

**Code Changes:**
```diff
@@ -94,17 +94,20 @@ FOREACH(SEARCH_PATH ${SEARCH_PATHS})
             IF (${contents} MATCHES "#define OPENEXR_VERSION_MINOR ([0-9]+)")
                 SET(OPENEXR_VERSION_MINOR "${CMAKE_MATCH_1}")
             ENDIF ()
+            FILE (STRINGS ${OPENEXR_VERSION_FILE} contents REGEX "#define OPENEXR_VERSION_PATCH ")
+            IF (${contents} MATCHES "#define OPENEXR_VERSION_PATCH ([0-9]+)")
+                SET(OPENEXR_VERSION_PATCH "${CMAKE_MATCH_1}")
+            ENDIF ()
         ENDIF ()
     ENDIF ()
```

Review comment:
I fixed it. Currently `OPENEXR_VERSION` had been also used to search libraries. So I split it into `OPENEXR_VERSION_MM` to search and `OPENEXR_VERSION` to show and comparing. ``` -- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.43) -- TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.5.1) -- JPEG 2000: OpenJPEG (ver 2.5.0) -- OpenEXR: /usr/local/lib/libImath-2_2.so /usr/local/lib/libIlmImf-2_2.so /usr/local/lib/libIex-2_2.so /usr/local/lib/libHalf.so /usr/local/lib/libIlmThread-2_2.so (ver 2.2.0) ``` And I also fixed potential problem. ``` IF (OPENEXR_VERSION_MAJOR AND OPENEXR_VERSION_MINOR) set(OPENEXR_VERSION "${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}") ENDIF () ``` If OpenEXR Ver x.0.y is used, this `set(OPENEXR_VERSION)` statement will not be executed. ``` IF (OPENEXR_VERSION_MAJOR AND OPENEXR_VERSION_MINOR) IF (4 AND 0) IF (TRUE AND FALSE) # non-zero means TRUE, zero means FALSE IF (FALSE) ```
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 154

**Code Changes:**
```diff
   if(NOT OPENEXR_VERSION)
     SET(OPENEXR_VERSION "Unknown")
+  else()
+    if(HAVE_CXX17 AND OPENEXR_VERSION VERSION_LESS "2.3.0")
+      message(STATUS "  OpenEXR(ver ${OPENEXR_VERSION}) doesn't support C++17 and higher. Updating OpenEXR 2.3.0+ is required.")
+      SET(OPENEXR_FOUND FALSE)
+    endif()
   endif()
 ELSE()
   IF(OPENEXR_FIND_REQUIRED)
```

Review comment:
Yes, and this problem is existed not only 5.x branch but also 4.x branch. I think after accepting pull request for 4.x branch, it will be merged into 5.x branch. https://github.com/opencv/opencv/wiki/How_to_contribute#before-you-start-contributing-you-should > If you are going to fix a bug, check that it still exists. This can be done by building the latest [4.x](https://github.com/opencv/opencv/tree/4.x)/[5.x](https://github.com/opencv/opencv/tree/5.x) branch or the [latest master branch](https://github.com/opencv/opencv), and make sure that the error is still reproducible there.
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 154

**Code Changes:**
```diff
   if(NOT OPENEXR_VERSION)
     SET(OPENEXR_VERSION "Unknown")
+  else()
+    if(HAVE_CXX17 AND OPENEXR_VERSION VERSION_LESS "2.3.0")
+      message(STATUS "  OpenEXR(ver ${OPENEXR_VERSION}) doesn't support C++17 and higher. Updating OpenEXR 2.3.0+ is required.")
+      SET(OPENEXR_FOUND FALSE)
+    endif()
   endif()
 ELSE()
   IF(OPENEXR_FIND_REQUIRED)
```

Review comment:
> I think after accepting pull request for 4.x branch, it will be merged into 5.x branch. Yes, I understand that. But my point is 5.x is now based on C++17 and integrated OpenEXR is 2.3.0 which supports C++17, so solution for 5.x should be: 1. Detect system OpenEXR version. 2. If the system one is below the integrated one, which is 2.3.0, the integrated one should be enabled; that is to build with flag `-DBUILD_OPENEXR=ON`. 3. If the system one is equal to or higher than the integrated one, build should go with the system one. Now you are basically turning off building with OpenEXR, right?
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 154

**Code Changes:**
```diff
   if(NOT OPENEXR_VERSION)
     SET(OPENEXR_VERSION "Unknown")
+  else()
+    if(HAVE_CXX17 AND OPENEXR_VERSION VERSION_LESS "2.3.0")
+      message(STATUS "  OpenEXR(ver ${OPENEXR_VERSION}) doesn't support C++17 and higher. Updating OpenEXR 2.3.0+ is required.")
+      SET(OPENEXR_FOUND FALSE)
+    endif()
   endif()
 ELSE()
   IF(OPENEXR_FIND_REQUIRED)
```

Review comment:
I'm sorry but it is diffuclt to agree about this change request for me. Even If system OpenEXR is older than v2.3.0 it doesn't means OpenCV user requests to use bundled OpenEXR(it is slightly old too). If needed, we can set enable with `-DBUILD_OPENEXR=ON` manually. Forcing ‘BUILD_OPENEXR`=`ON` losts user-selectability and it looks like bug. Related: https://github.com/opencv/opencv/issues/21326
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 99

**Code Changes:**
```diff
             IF (${contents} MATCHES "#define OPENEXR_VERSION_MINOR ([0-9]+)")
                 SET(OPENEXR_VERSION_MINOR "${CMAKE_MATCH_1}")
             ENDIF ()
+            FILE (STRINGS ${OPENEXR_VERSION_FILE} contents REGEX "#define OPENEXR_VERSION_PATCH ")
+            IF (${contents} MATCHES "#define OPENEXR_VERSION_PATCH ([0-9]+)")
+                SET(OPENEXR_VERSION_PATCH "${CMAKE_MATCH_1}")
+            ENDIF ()
         ENDIF ()
     ENDIF ()
 
-    IF (OPENEXR_VERSION_MAJOR AND OPENEXR_VERSION_MINOR)
```

Review comment:
There is something wrong with code indentation.