instruction
stringclasses
9 values
input
stringlengths
279
5.47k
output
stringlengths
6
9.58k
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_animation.cpp **Change Type:** modified **Context:** PR #26688: Animated GIF APNG WEBP AVIF revisions **Review Line:** 402 **Code Changes:** ```diff + + // Read back the still images into a vector of Mats. + EXPECT_TRUE(imreadmulti(output, apng_frames)); + + // Expect all frames written as multi-page image + EXPECT_EQ(expected_frame_count, apng_frames.size()); + + // Clean up by removing the temporary file. + EXPECT_EQ(0, remove(output.c_str())); +} + ```
CV_16U Mats converted to CV_8U internally. so i did not do frames comparison. frankly handling CV_16U probably crude and need extra work if needed. i did not find 16U APNGs to test well.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #26714: fix for png durations and memory leak **Code Changes:** ```diff @@ -404,7 +404,6 @@ bool PngDecoder::readData( Mat& img ) fseek(m_f, -8, SEEK_CUR); else m_buf_pos -= 8; - } else m_mat_next.copyTo(mat_cur); @@ -437,9 +436,9 @@ bool PngDecoder::readData( Mat& img ) memcpy(frameNext.getPixels(), frameCur.getPixels(), imagesize); ```
Please cite your source, there are several implementations: https://github.com/davidmz/apng-js/blob/e5272dcd6900cbea2c341ce259c206a162cedec8/src/library/parser.js#L64 https://github.com/FFmpeg/FFmpeg/blob/19c95ecbff84eebca254d200c941ce07868ee707/libavformat/apngdec.c#L259 I believe the spec says differently though: https://wiki.mozilla.org/APNG_Specification#%60fcTL%60:_The_Frame_Control_Chunk There is a difference between storing things in an animation and giving values to delays for display. I think you should simply do: ```cxx if (!delay_den) delay_den = 100; m_animation.durations.push_back(cvRound(1000.*delay_num/delay_den));
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #26714: fix for png durations and memory leak **Code Changes:** ```diff @@ -404,7 +404,6 @@ bool PngDecoder::readData( Mat& img ) fseek(m_f, -8, SEEK_CUR); else m_buf_pos -= 8; - } else m_mat_next.copyTo(mat_cur); @@ -437,9 +436,9 @@ bool PngDecoder::readData( Mat& img ) memcpy(frameNext.getPixels(), frameCur.getPixels(), imagesize); ```
for example delaynum 1 delayden 24 it means 1000 / 24 40 ms for example delaynum 4 delayden 100 it means 1000 / 100 * 4 40 ms
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #26714: fix for png durations and memory leak **Code Changes:** ```diff @@ -404,7 +404,6 @@ bool PngDecoder::readData( Mat& img ) fseek(m_f, -8, SEEK_CUR); else m_buf_pos -= 8; - } else m_mat_next.copyTo(mat_cur); @@ -437,9 +436,9 @@ bool PngDecoder::readData( Mat& img ) memcpy(frameNext.getPixels(), frameCur.getPixels(), imagesize); ```
when saving for example 80 ms delay num 80 delayden 1000 it means 1000 / 1000 * 80 80 ms
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/videoio/src/cap_android_mediandk.cpp **Change Type:** modified **Context:** PR #26656: AndroidMediaNdkCapture pixel format enhancement **Review Line:** 65 **Code Changes:** ```diff sawInputEOS(false), sawOutputEOS(false), - frameStride(0), frameWidth(0), frameHeight(0), colorFormat(0), - videoWidth(0), videoHeight(0), - videoFrameCount(0), + frameStride(0), frameWidth(0), frameHeight(0), + colorFormat(COLOR_FormatUnknown), fourCC(FOURCC_BGR), + videoWidth(0), videoHeight(0), videoFrameCount(0), videoRotation(0), videoRotationCode(-1), videoOrientationAuto(false) {} @@ -65,6 +75,7 @@ class AndroidMediaNdkCapture : public IVideoCapture ```
Attention: default output become BGR for Android too.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/src/hough.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -120,7 +120,7 @@ static void HoughLinesStandard( InputArray src, OutputArray lines, int type, float rho, float theta, int threshold, int linesMax, - double min_theta, double max_theta ) + double min_theta, double max_theta, bool use_edgeval = false ) { CV_CheckType(type, type == CV_32FC2 || type == CV_32FC3, "Internal error"); @@ -184,17 +184,31 @@ HoughLinesStandard( InputArray src, OutputArray lines, int type, ```
`if` in inner loops is slow.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/include/opencv2/imgproc.hpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -2165,11 +2165,13 @@ Must fall between 0 and max_theta. @param max_theta For standard and multi-scale Hough transform, an upper bound for the angle. Must fall between min_theta and CV_PI. The actual maximum angle in the accumulator may be slightly less than max_theta, depending on the parameters min_theta and theta. +@param use_edgeval True if you want to use weighted Hough transform. */ CV_EXPORTS_W void HoughLines( InputArray image, OutputArray lines, double rho, double theta, int threshold, double srn = 0, double stn = 0, - double min_theta = 0, double max_theta = CV_PI ); ```
No such params.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/src/hough.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -120,7 +120,7 @@ static void HoughLinesStandard( InputArray src, OutputArray lines, int type, float rho, float theta, int threshold, int linesMax, - double min_theta, double max_theta ) + double min_theta, double max_theta, bool use_edgeval = false ) { CV_CheckType(type, type == CV_32FC2 || type == CV_32FC3, "Internal error"); @@ -184,17 +184,31 @@ HoughLinesStandard( InputArray src, OutputArray lines, int type, ```
I moved if(use_edgeval) to outside of for loop. But I still remain to use this bool; use_edgeval to avoid code duplication, instead of defining another Hough function.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/include/opencv2/imgproc.hpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -2165,11 +2165,13 @@ Must fall between 0 and max_theta. @param max_theta For standard and multi-scale Hough transform, an upper bound for the angle. Must fall between min_theta and CV_PI. The actual maximum angle in the accumulator may be slightly less than max_theta, depending on the parameters min_theta and theta. +@param use_edgeval True if you want to use weighted Hough transform. */ CV_EXPORTS_W void HoughLines( InputArray image, OutputArray lines, double rho, double theta, int threshold, double srn = 0, double stn = 0, - double min_theta = 0, double max_theta = CV_PI ); ```
I'm sorry, it was my mistake. I updated it.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -15,22 +15,27 @@ using namespace std; /// Global variables /** General variables */ -Mat src, edges; +Mat src, canny_edge, sobel_edge; Mat src_gray; -Mat standard_hough, probabilistic_hough; +Mat standard_hough, probabilistic_hough, weighted_hough; int min_threshold = 50; ```
No need to use sprintf here.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.markdown **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -83,7 +83,7 @@ Arranging the terms: \f$r = x \cos \theta + y \sin \theta\f$ ### Standard and Probabilistic Hough Line Transform -OpenCV implements two kind of Hough Line Transforms: +OpenCV implements three kind of Hough Line Transforms: a. **The Standard Hough Transform** @@ -97,6 +97,12 @@ b. **The Probabilistic Hough Line Transform** ```
Better wording: ``` - Uses edge intensity instead binary 0 or 1 values in standard Hough transform. ```
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.markdown **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Review Line:** 100 **Code Changes:** ```diff @@ -97,6 +97,12 @@ b. **The Probabilistic Hough Line Transform** of the detected lines \f$(x_{0}, y_{0}, x_{1}, y_{1})\f$ - In OpenCV it is implemented with the function **HoughLinesP()** +c. **The Weighted Hough Transform** + +- Uses edge intensity instead binary 0 or 1 values in standard Hough transform. +- In OpenCV it is implemented with the function **HoughLines()** with use_edgeval=true. +- See the example in samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp. + ```
Line 86 should be "OpenCV implements three kind of Hough Line Transforms:"
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -15,22 +15,27 @@ using namespace std; /// Global variables /** General variables */ -Mat src, edges; +Mat src, canny_edge, sobel_edge; Mat src_gray; -Mat standard_hough, probabilistic_hough; +Mat standard_hough, probabilistic_hough, weighted_hough; int min_threshold = 50; ```
I want to add Edge threshold slider as this figure ( ![image](https://user-images.githubusercontent.com/13181036/208776678-94512916-044d-41b4-b8aa-81c52d06ddb9.png) ), because weighted Hough depends on edge amount.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/test/test_houghlines.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -340,6 +340,53 @@ TEST(HoughLines, regression_21983) EXPECT_NEAR(lines[0][1], 1.57179642, 1e-4); } +TEST(WeightedHoughLines, horizontal) +{ + Mat img(25, 25, CV_8UC1, Scalar(0)); + // draw lines. from top to bottom, stronger to weaker. + line(img, Point(0, 6), Point(25, 6), Scalar(240)); + line(img, Point(0, 12), Point(25, 12), Scalar(255)); ```
Signature for `_EQ` is `ASSERT_EQ(expected_reference, actual_result);`. Correct order of parameters are required to emit valid error messages. Reference: https://github.com/opencv/opencv/blob/4.0.0/modules/ts/include/opencv2/ts/ts_gtest.h#L8196-L8200 ``` GTEST_API_ AssertionResult EqFailure(const char* expected_expression, const char* actual_expression, const std::string& expected_value, const std::string& actual_value, bool ignoring_case); ```
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/test/test_houghlines.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Review Line:** 355 **Code Changes:** ```diff + + // detect lines + std::vector<Vec2f> lines; + int threshold{220*25-1}; + bool use_edgeval{true}; + HoughLines(img, lines, 1, CV_PI/180, threshold, 0, 0, 0.0, CV_PI, use_edgeval); + + // check results + ASSERT_EQ(3U, lines.size()); + // detected lines is assumed sorted from stronger to weaker. + EXPECT_EQ(12, lines[0][0]); ```
BTW, test doesn't look representative. ``` int threshold{25-1}; HoughLines(img, lines, 1, CV_PI/180, threshold, 0, 0, 0.0, CV_PI); ``` works well without this patch. if HoughLines() input comes from Canny() then this input is in set of `[0, 255]` without intermediate values. How is intermediate values could be prepared on edges?
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/test/test_houghlines.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -340,6 +340,53 @@ TEST(HoughLines, regression_21983) EXPECT_NEAR(lines[0][1], 1.57179642, 1e-4); } +TEST(WeightedHoughLines, horizontal) +{ + Mat img(25, 25, CV_8UC1, Scalar(0)); + // draw lines. from top to bottom, stronger to weaker. + line(img, Point(0, 6), Point(25, 6), Scalar(240)); + line(img, Point(0, 12), Point(25, 12), Scalar(255)); ```
I'm sorry. I fixed it.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/test/test_houghlines.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Review Line:** 355 **Code Changes:** ```diff + + // detect lines + std::vector<Vec2f> lines; + int threshold{220*25-1}; + bool use_edgeval{true}; + HoughLines(img, lines, 1, CV_PI/180, threshold, 0, 0, 0.0, CV_PI, use_edgeval); + + // check results + ASSERT_EQ(3U, lines.size()); + // detected lines is assumed sorted from stronger to weaker. + EXPECT_EQ(12, lines[0][0]); ```
Just a moment please for the fixation. I'm still struggling to build latest 4.x branch. I reported my error [here](https://github.com/opencv/opencv/issues/26620)
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgproc/test/test_houghlines.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Review Line:** 355 **Code Changes:** ```diff + + // detect lines + std::vector<Vec2f> lines; + int threshold{220*25-1}; + bool use_edgeval{true}; + HoughLines(img, lines, 1, CV_PI/180, threshold, 0, 0, 0.0, CV_PI, use_edgeval); + + // check results + ASSERT_EQ(3U, lines.size()); + // detected lines is assumed sorted from stronger to weaker. + EXPECT_EQ(12, lines[0][0]); ```
Now I fixed the unit test. and confirmed it. If I set " use_edgeval{false}" for both TEST(WeightedHoughLines, horizontal), and TEST(WeightedHoughLines, diagonal), and run the command; ```bash $ ./ext/sensyn-opencv/bin/opencv_test_imgproc --gtest_filter=WeightedHoughLines.* ``` , it fails as below; ```test_log [==========] Running 2 tests from 1 test case. [----------] Global test environment set-up. [----------] 2 tests from WeightedHoughLines [ RUN ] WeightedHoughLines.horizontal /home/mas/proj/sensyn/sensyn-vision/ext/sensyn-opencv/modules/imgproc/test/test_houghlines.cpp:358: Failure Expected equality of these values: 3 lines.size() Which is: 0 [ FAILED ] WeightedHoughLines.horizontal (1 ms) [ RUN ] WeightedHoughLines.diagonal /home/mas/proj/sensyn/sensyn-vision/ext/sensyn-opencv/modules/imgproc/test/test_houghlines.cpp:382: Failure Expected equality of these values: 2 lines.size() Which is: 0 [ FAILED ] WeightedHoughLines.diagonal (0 ms) [----------] 2 tests from WeightedHoughLines (1 ms total) [----------] Global test environment tear-down [==========] 2 tests from 1 test case ran. (1 ms total) [ PASSED ] 0 tests. [ FAILED ] 2 tests, listed below: [ FAILED ] WeightedHoughLines.horizontal [ FAILED ] WeightedHoughLines.diagonal 2 FAILED TESTS ``` But when I revised to "use_edgeval{true}" again as the pushed code, the result become success as below. ```test_log [==========] Running 2 tests from 1 test case. [----------] Global test environment set-up. [----------] 2 tests from WeightedHoughLines [ RUN ] WeightedHoughLines.horizontal [ OK ] WeightedHoughLines.horizontal (1 ms) [ RUN ] WeightedHoughLines.diagonal [ OK ] WeightedHoughLines.diagonal (0 ms) [----------] 2 tests from WeightedHoughLines (1 ms total) [----------] Global test environment tear-down [==========] 2 tests from 1 test case ran. (1 ms total) [ PASSED ] 2 tests. ```
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Review Line:** 176 **Code Changes:** ```diff + double x0 = r*cos_t, y0 = r*sin_t; + double alpha = 1000; + + Point pt1( cvRound(x0 + alpha*(-sin_t)), cvRound(y0 + alpha*cos_t) ); + Point pt2( cvRound(x0 - alpha*(-sin_t)), cvRound(y0 - alpha*cos_t) ); + line( weighted_hough, pt1, pt2, Scalar(255,0,0), 3, LINE_AA ); + } + + imshow( weighted_name, weighted_hough ); +} ```
Classic Hough transform and probablistic versions return lines in Cartesian coordinate system. You version implements polar version. I propose to return back to Cartesian and I'll merge the patch.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Review Line:** 176 **Code Changes:** ```diff + double x0 = r*cos_t, y0 = r*sin_t; + double alpha = 1000; + + Point pt1( cvRound(x0 + alpha*(-sin_t)), cvRound(y0 + alpha*cos_t) ); + Point pt2( cvRound(x0 - alpha*(-sin_t)), cvRound(y0 - alpha*cos_t) ); + line( weighted_hough, pt1, pt2, Scalar(255,0,0), 3, LINE_AA ); + } + + imshow( weighted_name, weighted_hough ); +} ```
I'm very sorry for not being able to fix nor respond. When I have time, I will definitely fix based on your request.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -15,22 +15,27 @@ using namespace std; /// Global variables /** General variables */ -Mat src, edges; +Mat src, canny_edge, sobel_edge; Mat src_gray; -Mat standard_hough, probabilistic_hough; +Mat standard_hough, probabilistic_hough, weighted_hough; int min_threshold = 50; ```
MS Visual Studio reports warning here. Please use 100000. See CI logs for details.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -15,22 +15,27 @@ using namespace std; /// Global variables /** General variables */ -Mat src, edges; +Mat src, canny_edge, sobel_edge; Mat src_gray; -Mat standard_hough, probabilistic_hough; +Mat standard_hough, probabilistic_hough, weighted_hough; int min_threshold = 50; ```
Oh I'm very sorry. Now I'm fixing and checking the build procedure. I will push after I confirmed it build without error.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/tutorial_code/ImgTrans/HoughLines_Demo.cpp **Change Type:** modified **Context:** PR #21407: Feature: weighted hough **Code Changes:** ```diff @@ -15,22 +15,27 @@ using namespace std; /// Global variables /** General variables */ -Mat src, edges; +Mat src, canny_edge, sobel_edge; Mat src_gray; -Mat standard_hough, probabilistic_hough; +Mat standard_hough, probabilistic_hough, weighted_hough; int min_threshold = 50; ```
I think I fixed the 2 errors in the CI. But github workflow seems only run on branch 4.x, so I couldn't confirmed the fixation. Could you check it by running CI?
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback.
**File:** platforms/android/default.config.py **Change Type:** added **Context:** PR #26057: Android builds update **Code Changes:** ```diff @@ -0,0 +1,6 @@ +ABIs = [ + ABI("2", "armeabi-v7a", None, 21, cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')), + ABI("3", "arm64-v8a", None, 21, cmake_vars=dict(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES='ON')), + ABI("5", "x86_64", None, 21, cmake_vars=dict(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES='ON')), + ABI("4", "x86", None, 21), +] ```
Makes sense for "Android NDK r27 and higher" according to documentation. Why do not enable that by default in the main build_sdk.py script?
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** platforms/android/default.config.py **Change Type:** added **Context:** PR #26057: Android builds update **Code Changes:** ```diff @@ -0,0 +1,6 @@ +ABIs = [ + ABI("2", "armeabi-v7a", None, 21, cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')), + ABI("3", "arm64-v8a", None, 21, cmake_vars=dict(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES='ON')), + ABI("5", "x86_64", None, 21, cmake_vars=dict(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES='ON')), + ABI("4", "x86", None, 21), +] ```
I want to switch CI to the default configuration and always build SDK and AAR packages with 16kb pages support. The packages will work with both old and new memory configuration. It just tunes ELF sections alignment a bit. The option will be ignored with NDK before 27.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** platforms/android/default.config.py **Change Type:** added **Context:** PR #26057: Android builds update **Code Changes:** ```diff @@ -0,0 +1,6 @@ +ABIs = [ + ABI("2", "armeabi-v7a", None, 21, cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')), + ABI("3", "arm64-v8a", None, 21, cmake_vars=dict(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES='ON')), + ABI("5", "x86_64", None, 21, cmake_vars=dict(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES='ON')), + ABI("4", "x86", None, 21), +] ```
```suggestion ABI("3", "arm64-v8a", None, 21, cmake_vars=dict(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES='ON')), ```
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** platforms/android/default.config.py **Change Type:** added **Context:** PR #26057: Android builds update **Code Changes:** ```diff @@ -0,0 +1,6 @@ +ABIs = [ + ABI("2", "armeabi-v7a", None, 21, cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')), + ABI("3", "arm64-v8a", None, 21, cmake_vars=dict(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES='ON')), + ABI("5", "x86_64", None, 21, cmake_vars=dict(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES='ON')), + ABI("4", "x86", None, 21), +] ```
Same issue here: ```suggestion ABI("5", "x86_64", None, 21, cmake_vars=dict(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES='ON')), ```
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVCompilerOptions.cmake **Change Type:** modified **Context:** PR #26057: Android builds update **Review Line:** 409 **Code Changes:** ```diff endif() endif() +# For 16k pages support with NDK prior 27 +# Details: https://developer.android.com/guide/practices/page-sizes?hl=en +if(ANDROID AND ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES AND (ANDROID_ABI STREQUAL arm64-v8a OR ANDROID_ABI STREQUAL x86_64)) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,max-page-size=16384") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size=16384") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,max-page-size=16384") +endif() + ```
> ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES `OPENCV_ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES` to avoid possible conflicts
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.hpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -47,34 +47,124 @@ #include "grfmt_base.hpp" #include "bitstrm.hpp" +#include <png.h> +#include <zlib.h> namespace cv { ```
Shouldn't this function be static? Does it even need to be a member function?
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.hpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -47,34 +47,124 @@ #include "grfmt_base.hpp" #include "bitstrm.hpp" +#include <png.h> +#include <zlib.h> namespace cv { ```
Isn't it the case for the .cpp file though?
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
If you have a commented block, put it in an `#If 0` and please explain why it is now commented out.
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
Some of those members are unset right now because the user does not send them. The writemulti API is not good enough to write an animation.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
this part was for only test
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
please sort the headers. iostream is most likely useless.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
those functions belong to an anonymous namespace.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
Please use CV_LOG_DEBUG instead of printf
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
Please use `!isalpha()`
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
Please do not use new as it makes its hard to track memory. Use std::vector<char> if you can.
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.hpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -47,34 +47,124 @@ #include "grfmt_base.hpp" #include "bitstrm.hpp" +#include <png.h> +#include <zlib.h> namespace cv { ```
It's ok to keep this API for now, for debugging, but I'd like to see a proper animation API, maybe in private, that starts taking into account the frame durations.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.hpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -47,34 +47,124 @@ #include "grfmt_base.hpp" #include "bitstrm.hpp" +#include <png.h> +#include <zlib.h> namespace cv { ```
this is not standard, please use `unsigned int` or `uint32_t`
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.hpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -47,34 +47,124 @@ #include "grfmt_base.hpp" #include "bitstrm.hpp" +#include <png.h> +#include <zlib.h> namespace cv { ```
please use `unsigned char`
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
mf is not checked.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
fread may read less bytes than expected. Imread should close the file and return false in the case.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
I propose ``` uint32_t PngDecoder::read_chunk(CHUNK& pChunk) ``` NULL is not possible then.
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
I propose to use `std::vector` or `cv::AutoBuffer` to prevent memory leaks.
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
The same to prevent leaks.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Review Line:** 1341 **Code Changes:** ```diff + { + *dp++ = 0; + memcpy(dp, row, rowbytes); + dp += rowbytes; + row += stride; + } + } + else + processRect(row, rowbytes, bpp, stride, op[n].h, rows); + + z_stream fin_zstream; ```
For asmorkalov: Need to check.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
Print error with CV_LOG_ERROR and return false from imread. There should not be silent failures.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
It'll be great to use named constants here.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_png.cpp **Change Type:** modified **Context:** PR #25715: Animated PNG Support **Code Changes:** ```diff @@ -51,21 +51,66 @@ and png2bmp sample from libpng distribution (Copyright (C) 1999-2001 MIYASAKA Masaru) \****************************************************************************************/ +/****************************************************************************\ + * + * this file includes some modified part of apngasm and APNG Optimizer 1.4 + * both have zlib license. + * + ****************************************************************************/ ```
i think next line do the job ``` if (fread(sig, 1, 8, m_f)) id = read_chunk(m_chunkIHDR); if (!(id == id_IHDR && m_chunkIHDR.size == 25)) return false; ```
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.hpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 52 **Code Changes:** ```diff @@ -49,6 +49,8 @@ #include <fstream> +struct WebPAnimDecoder; + namespace cv { @@ -61,17 +63,24 @@ class WebPDecoder CV_FINAL : public BaseImageDecoder ```
If you forward declare the structs, no need to include the WebP headers.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
No need to forward declare.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVFindWebP.cmake **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -10,8 +10,6 @@ # Look for the header file. -unset(WEBP_FOUND) - FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h) if(NOT WEBP_INCLUDE_DIR) @@ -21,13 +19,14 @@ else() ```
You should only add webpmux and webpdemux if they are found. When building WebP from third_party, it is all bundled in one library. So: ```cmake if(WEBP_MUX_LIBRARY) SET(WEBP_LIBRARIES ${WEBP_LIBRARY} ${WEBP_MUX_LIBRARY}) endif() ```
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVFindWebP.cmake **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -10,8 +10,6 @@ # Look for the header file. -unset(WEBP_FOUND) - FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h) if(NOT WEBP_INCLUDE_DIR) @@ -21,13 +19,14 @@ else() ```
SET(WEBP_LIBRARIES ${WEBP_LIBRARY}) if(WEBP_MUX_LIBRARY) SET(WEBP_LIBRARIES ${WEBP_LIBRARIES} ${WEBP_MUX_LIBRARY} ${WEBP_DEMUX_LIBRARY}) endif()
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.hpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -49,6 +49,8 @@ #include <fstream> +struct WebPAnimDecoder; + namespace cv { @@ -61,17 +63,24 @@ class WebPDecoder CV_FINAL : public BaseImageDecoder ```
Do not include webp here, just forward declare `WebPAnimEncoder` and `WebPAnimDecoder` (`struct WebPAnimEncoder;`)
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVFindWebP.cmake **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 13 **Code Changes:** ```diff # Look for the header file. -unset(WEBP_FOUND) - FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h) if(NOT WEBP_INCLUDE_DIR) @@ -21,13 +19,14 @@ else() # Look for the library. ```
do not unset that if you want the CI to pass.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVFindWebP.cmake **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 13 **Code Changes:** ```diff # Look for the header file. -unset(WEBP_FOUND) - FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h) if(NOT WEBP_INCLUDE_DIR) @@ -21,13 +19,14 @@ else() # Look for the library. ```
i think Webp version of buildbot should be updated.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVFindLibsGrfmt.cmake **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 200 **Code Changes:** ```diff - if(EXISTS "${WEBP_INCLUDE_DIR}/enc/vp8enci.h") - ocv_parse_header("${WEBP_INCLUDE_DIR}/enc/vp8enci.h" WEBP_VERSION_LINES ENC_MAJ_VERSION ENC_MIN_VERSION ENC_REV_VERSION) - set(WEBP_VERSION "${ENC_MAJ_VERSION}.${ENC_MIN_VERSION}.${ENC_REV_VERSION}") - elseif(EXISTS "${WEBP_INCLUDE_DIR}/webp/encode.h") + if(EXISTS "${WEBP_INCLUDE_DIR}/webp/encode.h") file(STRINGS "${WEBP_INCLUDE_DIR}/webp/encode.h" WEBP_ENCODER_ABI_VERSION REGEX "#define[ \t]+WEBP_ENCODER_ABI_VERSION[ \t]+([x0-9a-f]+)" ) if(WEBP_ENCODER_ABI_VERSION MATCHES "#define[ \t]+WEBP_ENCODER_ABI_VERSION[ \t]+([x0-9a-f]+)") set(WEBP_ENCODER_ABI_VERSION "${CMAKE_MATCH_1}") - set(WEBP_VERSION "encoder: ${WEBP_ENCODER_ABI_VERSION}") else() unset(WEBP_ENCODER_ABI_VERSION) ```
Indeed, that check should go, this is from WebP 0.5.2 (2017).... https://chromium.googlesource.com/webm/libwebp/+/668e1dd44f7594610b805f8ef8b7d7964777d3e2 It is rather harmless though, did you have a problem with it?
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
You are missing a WebPAnimDecoderDelete. Either you create a destructor for WebPDecoder, either you wrap the pointer in a unique_ptr. E.g., create in the header, a private struct: ```cpp struct UniquePtrDeleter { void operator()(WebPAnimDecoder * decoder) const { WebPAnimDecoderDelete(decoder); } void operator()(WebpData * dara) const { WebPDataClear(decoder); } }; // Use these unique_ptr to ensure the structs are automatically destroyed. std::unique_ptr<WebPAnimDecoder, UniquePtrDeleter> anim_decoder; // or create a type: using DataPtr = std::unique_ptr<WebPData, UniquePtrDeleter>; ``` I'd go with this, so that you do not have to remember to call a destructor.
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
When calling the WebP API you need to get a pointer so if you have a `std::unique_ptr<WebPAnimDecoder, UniquePtrDeleter> anim_decoder;`, just call `anim_decoder.get()`
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVFindWebP.cmake **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -10,8 +10,6 @@ # Look for the header file. -unset(WEBP_FOUND) - FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h) if(NOT WEBP_INCLUDE_DIR) @@ -21,13 +19,14 @@ else() ```
What are you trying to check here? How old is an invalid WebP version?
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -7,23 +7,9 @@ namespace opencv_test { namespace { #ifdef HAVE_WEBP -TEST(Imgcodecs_WebP, encode_decode_lossless_webp) +static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf) { - const string root = cvtest::TS::ptr()->get_data_path(); - string filename = root + "../cv/shared/lena.png"; - cv::Mat img = cv::imread(filename); ```
Also compare the bgcolor and all the other members.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVFindWebP.cmake **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -10,8 +10,6 @@ # Look for the header file. -unset(WEBP_FOUND) - FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h) if(NOT WEBP_INCLUDE_DIR) @@ -21,13 +19,14 @@ else() ```
It will be clearer to use https://cmake.org/cmake/help/latest/module/CheckCXXSourceCompiles.html here, instead of adding a new file to the source tree.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
Just to reduce the imbricated `if` , write it as: ```cpp if (VP8_STATUS_OK == WebPGetFeatures(header, sizeof(header), &features)) return false; ``` And then you can remove the big `{}` below.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 188 **Code Changes:** ```diff @@ -155,7 +185,7 @@ bool WebPDecoder::readData(Mat &img) CV_CheckEQ(img.cols, m_width, ""); CV_CheckEQ(img.rows, m_height, ""); - if (m_buf.empty()) + if (data.empty()) { fs.seekg(0, std::ios::beg); CV_Assert(fs && "File stream error"); data.create(1, validateToInt(fs_size), CV_8UC1); @@ -165,70 +195,96 @@ bool WebPDecoder::readData(Mat &img) } ```
That should still be m_buf no ?
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
That is only if there is alpha. Otherwise, it should be BGR
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
should i mark this as resolved?
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 188 **Code Changes:** ```diff @@ -155,7 +185,7 @@ bool WebPDecoder::readData(Mat &img) CV_CheckEQ(img.cols, m_width, ""); CV_CheckEQ(img.rows, m_height, ""); - if (m_buf.empty()) + if (data.empty()) { fs.seekg(0, std::ios::beg); CV_Assert(fs && "File stream error"); data.create(1, validateToInt(fs_size), CV_8UC1); @@ -165,70 +195,96 @@ bool WebPDecoder::readData(Mat &img) } ```
if (m_buf.empty()) don't pass tests.. m_buf is related with imdecode and imencode which i did not focused yet.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVFindWebP.cmake **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -10,8 +10,6 @@ # Look for the header file. -unset(WEBP_FOUND) - FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h) if(NOT WEBP_INCLUDE_DIR) @@ -21,13 +19,14 @@ else() ```
Thx for checking ! Forget about that then.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.hpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -49,6 +49,8 @@ #include <fstream> +struct WebPAnimDecoder; + namespace cv { @@ -61,17 +63,24 @@ class WebPDecoder CV_FINAL : public BaseImageDecoder ```
Please add the same thing for data and encoder: ``` void operator()(WebPData* data) const { WebPDataClear(data); } ``` And you can then use it internally when creating a unique_ptr (or use a typedef to that) ``` typedef std::unique_ptr<WebPAnimDecoder, UniquePtrDeleter> AnimDecoder; ``` If you only use those once, no need indeed to create the UniquePtrDeleter and just do what you already did for the encoder.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
Just do the same thing for data and encoder (or maybe simply do what you did for the encoder, by using a full unique_ptr definition if you only use those once in the code.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
I'd say the second one.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.hpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -49,6 +49,8 @@ #include <fstream> +struct WebPAnimDecoder; + namespace cv { @@ -61,17 +63,24 @@ class WebPDecoder CV_FINAL : public BaseImageDecoder ```
animinfo -> anim
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -7,23 +7,9 @@ namespace opencv_test { namespace { #ifdef HAVE_WEBP -TEST(Imgcodecs_WebP, encode_decode_lossless_webp) +static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf) { - const string root = cvtest::TS::ptr()->get_data_path(); - string filename = root + "../cv/shared/lena.png"; - cv::Mat img = cv::imread(filename); ```
Is that image standard ?
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
This is the reason why I think writemulti should not support AVIF and WebP. Those are not multi-page formats (and yes, I added it for AVIF but now think that it should be removed)
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.hpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -49,6 +49,8 @@ #include <fstream> +struct WebPAnimDecoder; + namespace cv { @@ -61,17 +63,24 @@ class WebPDecoder CV_FINAL : public BaseImageDecoder ```
Defining `operator()` forces you to include the WebP headers here. Can you instead define it in the `.cpp` file ? And therefore forward declare `WebPAnimDecoder` in the header
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags { //! @} imgcodecs_flags +/** @brief Represents an animation with multiple frames. +The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP). +It provides support for looping, background color settings, frame timing, and frame storage. +*/ +struct CV_EXPORTS_W_SIMPLE Animation +{ ```
Let's stick to struct, they are easier to bind. Animations do not have 100 frames.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -7,23 +7,9 @@ namespace opencv_test { namespace { #ifdef HAVE_WEBP -TEST(Imgcodecs_WebP, encode_decode_lossless_webp) +static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf) { - const string root = cvtest::TS::ptr()->get_data_path(); - string filename = root + "../cv/shared/lena.png"; - cv::Mat img = cv::imread(filename); ```
here is the link of image https://opencv.org/wp-content/uploads/2020/07/OpenCV_logo_white_.png i resized it to speed up tests
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags { //! @} imgcodecs_flags +/** @brief Represents an animation with multiple frames. +The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP). +It provides support for looping, background color settings, frame timing, and frame storage. +*/ +struct CV_EXPORTS_W_SIMPLE Animation +{ ```
M.b. `cv::Scalar`? We use it everywhere for the same purpose. There is no issue with big-little endianess.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags { //! @} imgcodecs_flags +/** @brief Represents an animation with multiple frames. +The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP). +It provides support for looping, background color settings, frame timing, and frame storage. +*/ +struct CV_EXPORTS_W_SIMPLE Animation +{ ```
Does it affect decoding? Please add note to the description.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -7,23 +7,9 @@ namespace opencv_test { namespace { #ifdef HAVE_WEBP -TEST(Imgcodecs_WebP, encode_decode_lossless_webp) +static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf) { - const string root = cvtest::TS::ptr()->get_data_path(); - string filename = root + "../cv/shared/lena.png"; - cv::Mat img = cv::imread(filename); ```
use OpenCV theRNG.
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags { //! @} imgcodecs_flags +/** @brief Represents an animation with multiple frames. +The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP). +It provides support for looping, background color settings, frame timing, and frame storage. +*/ +struct CV_EXPORTS_W_SIMPLE Animation +{ ```
That should be an extra parameter in imwriteanimation because it is not filled by imreadanimation
You are an expert OpenCV code reviewer specializing in header file design and interface. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/include/opencv2/imgcodecs.hpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -218,6 +218,36 @@ enum ImwriteHDRCompressionFlags { //! @} imgcodecs_flags +/** @brief Represents an animation with multiple frames. +The `Animation` struct is designed to store and manage data for animated sequences such as those from animated formats (e.g., GIF, AVIF, APNG, WebP). +It provides support for looping, background color settings, frame timing, and frame storage. +*/ +struct CV_EXPORTS_W_SIMPLE Animation +{ ```
i will remove it. IMWRITE_WEBP_QUALITY parameter does the job.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -7,23 +7,9 @@ namespace opencv_test { namespace { #ifdef HAVE_WEBP -TEST(Imgcodecs_WebP, encode_decode_lossless_webp) +static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf) { - const string root = cvtest::TS::ptr()->get_data_path(); - string filename = root + "../cv/shared/lena.png"; - cv::Mat img = cv::imread(filename); ```
Please create PR in opencv_extra with the same branch name.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -7,23 +7,9 @@ namespace opencv_test { namespace { #ifdef HAVE_WEBP -TEST(Imgcodecs_WebP, encode_decode_lossless_webp) +static void readFileBytes(const std::string& fname, std::vector<unsigned char>& buf) { - const string root = cvtest::TS::ptr()->get_data_path(); - string filename = root + "../cv/shared/lena.png"; - cv::Mat img = cv::imread(filename); ```
I propose to switch to some existing file in opencv_extra. It grows too fast this days.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** cmake/OpenCVFindWebP.cmake **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -10,8 +10,6 @@ # Look for the header file. -unset(WEBP_FOUND) - FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h) if(NOT WEBP_INCLUDE_DIR) @@ -21,13 +19,14 @@ else() ```
The check is redundant.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 461 **Code Changes:** ```diff + std::unique_ptr<WebPAnimEncoder, void (*)(WebPAnimEncoder*)> anim_encoder( + WebPAnimEncoderNew(width, height, &anim_config), WebPAnimEncoderDelete); + + pic.width = width; + pic.height = height; + pic.use_argb = 1; + pic.argb_stride = width; + WebPEncode(&config, &pic); + + bool is_input_rgba = animation.frames[0].channels() == 4; + Size canvas_size = Size(animation.frames[0].cols,animation.frames[0].rows); ```
Looks like the sanitizer issue is related to the flag. The encoder always expects alpha channel, even, ig input matrices have CV_8UC3 type.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 461 **Code Changes:** ```diff + std::unique_ptr<WebPAnimEncoder, void (*)(WebPAnimEncoder*)> anim_encoder( + WebPAnimEncoderNew(width, height, &anim_config), WebPAnimEncoderDelete); + + pic.width = width; + pic.height = height; + pic.use_argb = 1; + pic.argb_stride = width; + WebPEncode(&config, &pic); + + bool is_input_rgba = animation.frames[0].channels() == 4; + Size canvas_size = Size(animation.frames[0].cols,animation.frames[0].rows); ```
> Looks like the sanitizer issue is related to the flag. The encoder always expects alpha channel, even, ig input matrices have CV_8UC3 type. There are two possible solutions: either assert if the input is 8UC3, or convert 8UC3 to 8UC4. I believe converting 8UC3 to 8UC4 is the better approach.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/python/tutorial_code/imgcodecs/animations.py **Change Type:** added **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -0,0 +1,52 @@ +import cv2 as cv +import numpy as np + +def main(filename): + ## [write_animation] + if filename == "animated_image.webp": + # Create an Animation instance to save + animation_to_save = cv.Animation() + ```
timestamp is not incremented in the loop
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** samples/cpp/tutorial_code/imgcodecs/animations.cpp **Change Type:** added **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -0,0 +1,51 @@ +#include <opencv2/highgui.hpp> +#include <opencv2/imgcodecs.hpp> +#include <opencv2/imgproc.hpp> +#include <iostream> + +using namespace cv; + +int main( int argc, const char** argv ) +{ ```
Timestamp is not incremented.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/test/test_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 210 **Code Changes:** ```diff + EXPECT_EQ(0, cvtest::norm(l_animation.frames[5], l_animation.frames[14], NORM_INF)); + EXPECT_EQ(0, cvtest::norm(l_animation.frames[6], l_animation.frames[15], NORM_INF)); + EXPECT_EQ(0, cvtest::norm(l_animation.frames[7], l_animation.frames[16], NORM_INF)); + + // Verify whether the imread function successfully loads the first frame + Mat frame = imread(output, IMREAD_UNCHANGED); + EXPECT_EQ(0, cvtest::norm(l_animation.frames[0], frame, NORM_INF)); + + std::vector<uchar> buf; + readFileBytes(output, buf); + vector<Mat> webp_frames; ```
Let's extact it as another test case.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/loadsave.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -682,6 +682,116 @@ bool imreadmulti(const String& filename, std::vector<Mat>& mats, int start, int return imreadmulti_(filename, flags, mats, start, count); } +static bool +imreadanimation_(const String& filename, int flags, int start, int count, Animation& animation) +{ + bool success = false; + if (start < 0) { + start = 0; ```
CV_LOG_ERROR
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/loadsave.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 703 **Code Changes:** ```diff + decoder = findDecoder(filename); + + /// if no decoder was found, return false. + if (!decoder) { + CV_LOG_WARNING(NULL, "Decoder for " << filename << " not found!\n"); + return false; + } + + /// set the filename in the driver + decoder->setSource(filename); + // read the header to make sure it succeeds ```
Log message us useful here
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/loadsave.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 779 **Code Changes:** ```diff + } + + if (!decoder->nextPage()) + { + break; + } + ++current; + } + animation.bgcolor = decoder->animation().bgcolor; + animation.loop_count = decoder->animation().loop_count; + ```
Need to add check, if we do not have unexpected early exit. E.g. header reports 10 frames, but we get only 5 from the very beginning.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
Need to discuss it.
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
CV_LOG_ERROR
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -44,17 +44,15 @@ #include "precomp.hpp" -#include <webp/decode.h> -#include <webp/encode.h> - #include <stdio.h> #include <limits.h> - ```
Need to aandle both RGB(a) and BGR(a) here.
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 147 **Code Changes:** ```diff - m_type = CV_8UC3; - channels = 3; + fs.seekg(0, std::ios::beg); CV_Assert(fs && "File stream error"); + data.create(1, validateToInt(fs_size), CV_8UC1); + fs.read((char*)data.ptr(), fs_size); + CV_Assert(fs && "Can't read file data"); + fs.close(); } - return true; + CV_Assert(data.type() == CV_8UC1); CV_Assert(data.rows == 1); ```
Assert raises exception. The file is not closed on the next line.
You are an expert OpenCV code reviewer specializing in code quality and best practices. Review the provided code changes and provide specific, actionable feedback.
**File:** doc/tutorials/app/animations.markdown **Change Type:** added **Context:** PR #25608: Animated WebP and AVIF Support **Code Changes:** ```diff @@ -0,0 +1,91 @@ +Handling Animated Image Files {#tutorial_animations} +=========================== + +@tableofcontents + +| | | +| -: | :- | +| Original author | Suleyman Turkmen (with help of ChatGPT) | +| Compatibility | OpenCV >= 4.11 | ```
Aninmated PNG (APNG)
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
**File:** modules/imgcodecs/src/grfmt_webp.cpp **Change Type:** modified **Context:** PR #25608: Animated WebP and AVIF Support **Review Line:** 147 **Code Changes:** ```diff - m_type = CV_8UC3; - channels = 3; + fs.seekg(0, std::ios::beg); CV_Assert(fs && "File stream error"); + data.create(1, validateToInt(fs_size), CV_8UC1); + fs.read((char*)data.ptr(), fs_size); + CV_Assert(fs && "Can't read file data"); + fs.close(); } - return true; + CV_Assert(data.type() == CV_8UC1); CV_Assert(data.rows == 1); ```
ifstream destructor closes the file. fs is decoder field, no need to wary about it here.