nareshmlx/opencv-pr huggingface dataset:
**File:** modules/dnn/src/onnx/onnx_importer2.cpp
**Change Type:** modified
**Context:** PR #27527: Trilu layer

**Code Changes:**
```diff
@@ -204,6 +204,7 @@ class ONNXImporter2
     void parseRange                (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseReduce               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseRelu                 (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
+    void parseTrilu                (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseResize               (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseReshape              (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
     void parseScatter              (LayerParams& layerParams, const opencv_onnx::NodeProto& node_proto);
@@ -1554,6 +1555,14 @@ void ONNXImporter2::parseResize(LayerParams& layerParams, const opencv_onnx::Nod
     addLayer(layerParams, node_proto, ninputs);
```

Review comment:
Please remove redundant empty lines.
**File:** modules/imgcodecs/src/exif.hpp
**Change Type:** modified
**Context:** PR #27499: Extend image I/O API with metadata support
**Review Line:** 181

**Code Changes:**
```diff
     ExifEntry_t getTag( const ExifTagName tag ) const;
 
+    /**
+     * @brief Get the whole exif buffer
+     */
+    const std::vector<unsigned char>& getData() const;
 
 private:
     std::vector<unsigned char> m_data;
```

Review comment:
m.b. `getRaw()`. Semantic is not clear now.
**File:** modules/imgcodecs/src/grfmt_base.cpp
**Change Type:** modified
**Context:** PR #27499: Extend image I/O API with metadata support

**Code Changes:**
```diff
@@ -58,11 +58,30 @@ BaseImageDecoder::BaseImageDecoder()
     m_frame_count = 1;
 }
 
+bool BaseImageDecoder::haveMetadata(ImageMetadataType type) const
+{
+    if (type == IMAGE_METADATA_EXIF)
+        return !m_exif.getData().empty();
+    return false;
+}
```

Review comment:
The function does not return false in any branch. Is it expected? Is the return value redundant?
**File:** modules/imgcodecs/src/loadsave.cpp
**Change Type:** modified
**Context:** PR #27499: Extend image I/O API with metadata support
**Review Line:** 501

**Code Changes:**
```diff
     ImageDecoder decoder;
 
+    if (metadata_types)
+        metadata_types->clear();
+
 #ifdef HAVE_GDAL
     if(flags != IMREAD_UNCHANGED && (flags & IMREAD_LOAD_GDAL) == IMREAD_LOAD_GDAL ){
         decoder = GdalDecoder().newDecoder();
@@ -509,6 +583,8 @@ imread_( const String& filename, int flags, OutputArray mat )
             CV_CheckTrue(original_ptr == real_mat.data, "Internal imread issue");
             success = true;
```

Review comment:
Need a warning, that GDAL does not support metadata for now.
**File:** modules/imgcodecs/src/grfmt_base.cpp
**Change Type:** modified
**Context:** PR #27499: Extend image I/O API with metadata support
**Review Line:** 77

**Code Changes:**
```diff
+        if (!exif.empty()) {
+            Mat exifmat(1, (int)exif.size(), CV_8U, (void*)exif.data());
+            return exifmat;
+        }
+    }
+    return Mat();
+}
 
 ExifEntry_t BaseImageDecoder::getExifTag(const ExifTagName tag) const
 {
     return m_exif.getTag(tag);
```

Review comment:
I propose to add warning to the else branch that metadata of the type other than EXIF is not supported.
**File:** modules/imgcodecs/src/exif.hpp
**Change Type:** modified
**Context:** PR #27499: Extend image I/O API with metadata support
**Review Line:** 181

**Code Changes:**
```diff
     ExifEntry_t getTag( const ExifTagName tag ) const;
 
+    /**
+     * @brief Get the whole exif buffer
+     */
+    const std::vector<unsigned char>& getData() const;
 
 private:
     std::vector<unsigned char> m_data;
```

Review comment:
it's inside ExifReader, so getData() is quite good name
**File:** modules/imgcodecs/src/grfmt_base.cpp
**Change Type:** modified
**Context:** PR #27499: Extend image I/O API with metadata support

**Code Changes:**
```diff
@@ -58,11 +58,30 @@ BaseImageDecoder::BaseImageDecoder()
     m_frame_count = 1;
 }
 
+bool BaseImageDecoder::haveMetadata(ImageMetadataType type) const
+{
+    if (type == IMAGE_METADATA_EXIF)
+        return !m_exif.getData().empty();
+    return false;
+}
```

Review comment:
added checks in the new commits
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 77

**Code Changes:**
```diff
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
+    Mat img(sz, CV_32FC7);
+    img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125;
+    img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500;
```

Review comment:
How will it work in case of BGR or GRAYSCALE input?
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 77

**Code Changes:**
```diff
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
+    Mat img(sz, CV_32FC7);
+    img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125;
+    img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500;
```

Review comment:
The message looks cryptic. I propose to use CV_CheckXXX macro and add meaningful error message.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 77

**Code Changes:**
```diff
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
+    Mat img(sz, CV_32FC7);
+    img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125;
+    img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500;
```

Review comment:
> How will it work in case of BGR or GRAYSCALE input? It leaves it on previous implementation when channels <= 4
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 77

**Code Changes:**
```diff
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
+    Mat img(sz, CV_32FC7);
+    img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125;
+    img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500;
```

Review comment:
Took a bit more time :-( I probably found a bug in previous code. In ExrDecoder::readData(); when m_native_depth != justcopy, it produce some non-initialized values in the matrix. I will publish that bug later with more details.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 77

**Code Changes:**
```diff
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
+    Mat img(sz, CV_32FC7);
+    img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125;
+    img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500;
```

Review comment:
I propose some change in calcType but it change some behaviour with 2/4-channel images and IMREAD_ANYCOLOR so left it commented out. I did some imread tests with several mode combinations for 1-5 channels. Commited version had the same results for <5 channels as the previous code.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 77

**Code Changes:**
```diff
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
+    Mat img(sz, CV_32FC7);
+    img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125;
+    img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500;
```

Review comment:
I won't do anything new in this request. It works as intended. The found bug I will publish as an issue.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 77

**Code Changes:**
```diff
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
+    Mat img(sz, CV_32FC7);
+    img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125;
+    img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500;
```

Review comment:
I believe we need to test BGR and grayscale modes too. Even if expected behavior is an exception.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 77

**Code Changes:**
```diff
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
+    Mat img(sz, CV_32FC7);
+    img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125;
+    img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500;
```

Review comment:
I did tests with several mode combinations (IMREAD_GRAYSCALE, IMREAD_COLOR, IMREAD_ANYCOLOR, IMREAD_ANYCOLOR | cv::IMREAD_COLOR, IMREAD_ANYDEPTH, IMREAD_ANYDEPTH | cv::IMREAD_COLOR, IMREAD_ANYDEPTH | cv::IMREAD_ANYCOLOR, IMREAD_ANYDEPTH | cv::IMREAD_ANYCOLOR | cv::IMREAD_COLOR, IMREAD_UNCHANGED), up to four channels it behaves as previous version; from five channels it supports only CV_32F and more channels, so IMREAD_UNCHANGED is suggested to use.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 77

**Code Changes:**
```diff
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
+    Mat img(sz, CV_32FC7);
+    img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125;
+    img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500;
```

Review comment:
I can add tests for IMREAD_GRAYSCALE, IMREAD_COLOR.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support

**Code Changes:**
```diff
@@ -68,6 +68,36 @@ TEST(Imgcodecs_EXR, readWrite_32FC3)
     EXPECT_EQ(0, remove(filenameOutput.c_str()));
 }
 
+TEST(Imgcodecs_EXR, readWrite_32FC7)
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
```

Review comment:
Temporary file will not be removed if test fail on this or previous asserts. We need to use `EXPECT`.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support

**Code Changes:**
```diff
@@ -68,6 +68,36 @@ TEST(Imgcodecs_EXR, readWrite_32FC3)
     EXPECT_EQ(0, remove(filenameOutput.c_str()));
 }
 
+TEST(Imgcodecs_EXR, readWrite_32FC7)
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
```

Review comment:
I am new to gtest so I don't know that EXPECT should be used. I copied the pattern which was in previous tests: readWrite_32FC1, readWrite_32FC3.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support

**Code Changes:**
```diff
@@ -68,6 +68,36 @@ TEST(Imgcodecs_EXR, readWrite_32FC3)
     EXPECT_EQ(0, remove(filenameOutput.c_str()));
 }
 
+TEST(Imgcodecs_EXR, readWrite_32FC7)
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
```

Review comment:
``` EXPECT_EQ(img2.type(), img.type()); EXPECT_EQ(img2.size(), img.size()); ```
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support

**Code Changes:**
```diff
@@ -68,6 +68,36 @@ TEST(Imgcodecs_EXR, readWrite_32FC3)
     EXPECT_EQ(0, remove(filenameOutput.c_str()));
 }
 
+TEST(Imgcodecs_EXR, readWrite_32FC7)
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
```

Review comment:
I changed that only in my test readWrite_32FC7, but the same is in several other tests.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 74

**Code Changes:**
```diff
 }
 
+TEST(Imgcodecs_EXR, readWrite_32FC7)
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
```

Review comment:
imho using a generated cv::Mat here instead of adding an extra test file to opencv_extra is better.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 74

**Code Changes:**
```diff
 }
 
+TEST(Imgcodecs_EXR, readWrite_32FC7)
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
```

Review comment:
> ``` > EXPECT_EQ(0, remove(filename.c_str())); > const Mat img3 = cv::imread(filename, IMREAD_GRAYSCALE); > ASSERT_TRUE(img3.empty()); > const Mat img4 = cv::imread(filename, IMREAD_COLOR); > ASSERT_TRUE(img4.empty()); > } > ``` Removing file is before testing grayscale and color in current branch. It prints error message as you can't load multispectral image as GRAYSCALE or COLOR.
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 74

**Code Changes:**
```diff
 }
 
+TEST(Imgcodecs_EXR, readWrite_32FC7)
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
```

Review comment:
> > ``` > > EXPECT_EQ(0, remove(filename.c_str())); > > const Mat img3 = cv::imread(filename, IMREAD_GRAYSCALE); > > ASSERT_TRUE(img3.empty()); > > const Mat img4 = cv::imread(filename, IMREAD_COLOR); > > ASSERT_TRUE(img4.empty()); > > } > > ``` > > Removing file is before testing grayscale and color in current branch. It prints error message as you can't load multispectral image as GRAYSCALE or COLOR. i fixed it on my code
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 74

**Code Changes:**
```diff
 }
 
+TEST(Imgcodecs_EXR, readWrite_32FC7)
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
```

Review comment:
i suggest using this ``` TEST(Imgcodecs_EXR, readWrite_32FC7) { // 0-6 channels (multispectral) const string filename = cv::tempfile(".exr"); const Size sz(3, 5); Mat img = Mat::zeros(sz, CV_MAKETYPE(CV_32F, 7)); img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125; img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500; img.at<cv::Vec<float, 7>>(4, 2)[6] = 305.875; ASSERT_TRUE(cv::imwrite(filename, img)); const Mat img2 = cv::imread(filename, IMREAD_UNCHANGED); EXPECT_EQ(img2.type(), img.type()); EXPECT_EQ(img2.size(), img.size()); EXPECT_LE(cvtest::norm(img, img2, NORM_INF | NORM_RELATIVE), 1e-3); const Mat img3 = cv::imread(filename, IMREAD_GRAYSCALE); ASSERT_TRUE(img3.empty()); const Mat img4 = cv::imread(filename, IMREAD_COLOR); ASSERT_TRUE(img4.empty()); EXPECT_EQ(0, remove(filename.c_str())); } ```
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 74

**Code Changes:**
```diff
 }
 
+TEST(Imgcodecs_EXR, readWrite_32FC7)
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
```

Review comment:
``` const Size sz(3, 5); Mat img = Mat::zeros(sz, CV_MAKETYPE(CV_32F, 7)); img.at<cv::Vec<float, 7>>(0, 0)[0] = 101.125; img.at<cv::Vec<float, 7>>(2, 1)[3] = 203.500; img.at<cv::Vec<float, 7>>(4, 2)[6] = 305.875; ASSERT_TRUE(cv::imwrite(filename, img)); ``` generates the same file at https://github.com/opencv/opencv_extra/pull/1262
**File:** modules/imgcodecs/test/test_exr.impl.hpp
**Change Type:** modified
**Context:** PR #27485: imgcodecs: OpenEXR multispectral read/write support
**Review Line:** 74

**Code Changes:**
```diff
 }
 
+TEST(Imgcodecs_EXR, readWrite_32FC7)
+{ // 0-6 channels (multispectral)
+    const string root = cvtest::TS::ptr()->get_data_path();
+    const string filenameInput = root + "readwrite/test32FC7.exr";
+    const string filenameOutput = cv::tempfile(".exr");
+#ifndef GENERATE_DATA
+    const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
+#else
+    const Size sz(3, 5);
```

Review comment:
I use the same pattern as tests readWrite_32FC1, readWrite_32FC3, readWrite_32FC1_half, readWrite_32FC3_half. It's generate image file upon GENERATE_DATA define. I don't know when it was called with this define so I do the new test readWrite_32FC7 same way.
**File:** apps/interactive-calibration/main.cpp
**Change Type:** modified
**Context:** PR #27546: Added command line option to select VideoCapture backend
**Review Line:** 29

**Code Changes:**
```diff
 
-const std::string keys  =
+static std::string getVideoIoBackendsString()
+{
+    std::string result;
+    auto backs = cv::videoio_registry::getBackends();
+    for (const auto& b: backs)
+    {
+        if (!result.empty())
+            result += ", ";
+
```

Review comment:
Not all backends support cameras.
**File:** apps/interactive-calibration/main.cpp
**Change Type:** modified
**Context:** PR #27546: Added command line option to select VideoCapture backend

**Code Changes:**
```diff
@@ -6,7 +6,7 @@
 #include <opencv2/calib3d.hpp>
 #include <opencv2/cvconfig.h>
 #include <opencv2/highgui.hpp>
-
+#include <opencv2/videoio/registry.hpp>
 
 #include <string>
 #include <vector>
@@ -23,9 +23,25 @@
```

Review comment:
There are backends for video files too. `cb` => `vb`
**File:** apps/interactive-calibration/main.cpp
**Change Type:** modified
**Context:** PR #27546: Added command line option to select VideoCapture backend
**Review Line:** 29

**Code Changes:**
```diff
 
-const std::string keys  =
+static std::string getVideoIoBackendsString()
+{
+    std::string result;
+    auto backs = cv::videoio_registry::getBackends();
+    for (const auto& b: backs)
+    {
+        if (!result.empty())
+            result += ", ";
+
```

Review comment:
I renamed the command line parameter to `vb` and added it to video branch too. Some It could be useful for real videos and cameras available with gstreamer, e.g. pipeline string, IP cameras (ffmpeg rtsp), etc.
**File:** modules/imgcodecs/src/grfmt_spng.cpp
**Change Type:** modified
**Context:** PR #27113: Fixing imread() function 16 bit reading png problem with libspng
**Review Line:** 648

**Code Changes:**
```diff
-        for (i = 0; i < size.width; i++, bgr += 3)
+        for (i = 0; i < size.width; i++, bgr += ncn)
         {
-            int t = static_cast<int>(cBGR0 * bgr[0] + 0.5869750977 * bgr[1] + cBGR2 * bgr[2]);
-            gray[i] = (uchar)t;
+            if (bgr[0] != bgr[1] || bgr[0] != bgr[2])
+            {
+                gray[i] = (uchar)((cBGR0 * bgr[0] + cBGR1 * bgr[1] + cBGR2 * bgr[2]) >> 15);
+            }
+            else
+            {
```

Review comment:
libpng code is like ``` if (red != green || red != blue) { rgb_error |= 1; /* NOTE: this is the historical approach which simply * truncates the results. */ *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); } else *(dp++) = red; ``` let me check any performans difference with `gray[i] = (uchar)((cBGR0 * bgr[0] + cBGR1 * bgr[1] + cBGR2 * bgr[2]) >> 15);`
**File:** modules/imgcodecs/test/test_animation.cpp
**Change Type:** modified
**Context:** PR #27113: Fixing imread() function 16 bit reading png problem with libspng

**Code Changes:**
```diff
@@ -676,7 +676,7 @@ TEST(Imgcodecs_APNG, imread_animation_16u)
     img = imread(filename, IMREAD_ANYDEPTH);
     ASSERT_FALSE(img.empty());
     EXPECT_TRUE(img.type() == CV_16UC1);
-    EXPECT_EQ(19519, img.at<ushort>(0, 0));
+    EXPECT_EQ(19517, img.at<ushort>(0, 0));
 
     img = imread(filename, IMREAD_COLOR | IMREAD_ANYDEPTH);
     ASSERT_FALSE(img.empty());
```

Review comment:
Sounds like wrong rounding somewhere in libspng.