instruction
stringclasses 9
values | input
stringlengths 279
5.47k
| output
stringlengths 6
9.58k
|
|---|---|---|
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/calib3d/include/opencv2/calib3d.hpp
**Change Type:** modified
**Context:** PR #26669: solvePnPRansac implementation for Fisheye camera model
**Code Changes:**
```diff
@@ -4075,6 +4075,40 @@ optimization. It is the \f$max(width,height)/\pi\f$ or the provided \f$f_x\f$, \
the provided rvec and tvec values as initial approximations of the rotation and translation
vectors, respectively, and further optimizes them.
@param flags Method for solving a PnP problem: see @ref calib3d_solvePnP_flags
+ @param criteria Termination criteria for internal undistortPoints call.
+ The function interally undistorts points with @ref undistortPoints and call @ref cv::solvePnP,
+ thus the input are very similar. More information about Perspective-n-Points is described in @ref calib3d_solvePnP
+ for more information.
+ */
+ CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints,
```
|
I propose to use the same description as for cv::solvePnpRansac with fisheye model reference and add reference to SOLVEPNP_XXX constants instead of copy.
|
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/opencv.bib
**Change Type:** modified
**Context:** PR #26754: Add direct pdf links in the bibliography
**Review Line:** 1100
**Code Changes:**
```diff
number = {5},
pages = {717-721},
doi = {10.1109/70.326576},
- issn = {1042-296X}
+ issn = {1042-296X},
+ url = {https://drive.google.com/file/d/1t1uoki3_qOXHMmWq5ixqQcALlEIJzTMh/view}
}
@inproceedings{PM03,
author = {P{\'e}rez, Patrick and Gangnet, Michel and Blake, Andrew},
@@ -867,15 +1107,17 @@ @inproceedings{PM03
pages = {313--318},
```
|
This link comes from: https://sites.google.com/robotics.snu.ac.kr/fcp/publications/articles See: 
|
You are an expert OpenCV code reviewer specializing in API design and compatibility. Review the provided code changes and provide specific, actionable feedback.
|
**File:** doc/opencv.bib
**Change Type:** modified
**Context:** PR #26754: Add direct pdf links in the bibliography
**Code Changes:**
```diff
@@ -15,7 +15,7 @@ @article{ANB13
pages = {13.1--13.11},
publisher = {{BMVA} Press},
year = {2013},
- url = {https://doi.org/10.5244/C.27.13},
+ url = {https://projet.liris.cnrs.fr/imagine/pub/proceedings/BMVC-2013/Papers/paper0013/paper0013.pdf},
doi = {10.5244/C.27.13},
timestamp = {Sat, 09 Apr 2022 12:44:13 +0200},
biburl = {https://dblp.org/rec/conf/bmvc/AlcantarillaNB13.bib},
@@ -31,7 +31,7 @@ @inproceedings{Andreff99
```
|
Lukas and Kanade are names. Capital letters.
|
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/opencv.bib
**Change Type:** modified
**Context:** PR #26754: Add direct pdf links in the bibliography
**Review Line:** 369
**Code Changes:**
```diff
journal = {International Journal of Robotics Research},
year = {1998},
volume = {18},
- pages = {286--298}
+ pages = {286--298},
+ url = {https://typeset.io/pdf/hand-eye-calibration-using-dual-quaternions-1boiebmyns.pdf}
}
@inproceedings{DM03,
author = {Drago, Fr{\'e}d{\'e}ric and Myszkowski, Karol and Annen, Thomas and Chiba, Norishige},
@@ -276,7 +377,7 @@ @inproceedings{DM03
volume = {22},
```
|
The link returns 403
|
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/opencv.bib
**Change Type:** modified
**Context:** PR #26754: Add direct pdf links in the bibliography
**Review Line:** 369
**Code Changes:**
```diff
journal = {International Journal of Robotics Research},
year = {1998},
volume = {18},
- pages = {286--298}
+ pages = {286--298},
+ url = {https://typeset.io/pdf/hand-eye-calibration-using-dual-quaternions-1boiebmyns.pdf}
}
@inproceedings{DM03,
author = {Drago, Fr{\'e}d{\'e}ric and Myszkowski, Karol and Annen, Thomas and Chiba, Norishige},
@@ -276,7 +377,7 @@ @inproceedings{DM03
volume = {22},
```
|
In my location, the link is OK. I don't know how to proceed. 
|
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/opencv.bib
**Change Type:** modified
**Context:** PR #26754: Add direct pdf links in the bibliography
**Review Line:** 1500
**Code Changes:**
```diff
journal = {Image and Vision Computing},
volume = {8},
number = {1},
- publisher = {Elsevier}
+ publisher = {Elsevier},
+ url = {https://typeset.io/pdf/a-comparative-study-of-hough-transform-methods-for-circle-2mzwteha3d.pdf}
}
@incollection{Zach2007,
author = {Zach, Christopher and Pock, Thomas and Bischof, Horst},
title = {A duality based approach for realtime TV-L 1 optical flow},
booktitle = {Pattern Recognition},
```
|
Same, the link is ok for me: 
|
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/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Code Changes:**
```diff
@@ -94,17 +94,20 @@ FOREACH(SEARCH_PATH ${SEARCH_PATHS})
IF (${contents} MATCHES "#define OPENEXR_VERSION_MINOR ([0-9]+)")
SET(OPENEXR_VERSION_MINOR "${CMAKE_MATCH_1}")
ENDIF ()
+ FILE (STRINGS ${OPENEXR_VERSION_FILE} contents REGEX "#define OPENEXR_VERSION_PATCH ")
+ IF (${contents} MATCHES "#define OPENEXR_VERSION_PATCH ([0-9]+)")
+ SET(OPENEXR_VERSION_PATCH "${CMAKE_MATCH_1}")
+ ENDIF ()
ENDIF ()
ENDIF ()
```
|
> `STRLESS` > `"2_3"` Why is not `VERSION_LESS`? > OPENEXR_VERSION=2.3.0
|
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/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 154
**Code Changes:**
```diff
if(NOT OPENEXR_VERSION)
SET(OPENEXR_VERSION "Unknown")
+ else()
+ if(HAVE_CXX17 AND OPENEXR_VERSION VERSION_LESS "2.3.0")
+ message(STATUS " OpenEXR(ver ${OPENEXR_VERSION}) doesn't support C++17 and higher. Updating OpenEXR 2.3.0+ is required.")
+ SET(OPENEXR_FOUND FALSE)
+ endif()
endif()
ELSE()
IF(OPENEXR_FIND_REQUIRED)
```
|
This may be a fix for 4.x but definitely not for https://github.com/opencv/opencv/issues/26673 or 5.x. Compile standard of 5.x has been switched to C++17.
|
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/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Code Changes:**
```diff
@@ -94,17 +94,20 @@ FOREACH(SEARCH_PATH ${SEARCH_PATHS})
IF (${contents} MATCHES "#define OPENEXR_VERSION_MINOR ([0-9]+)")
SET(OPENEXR_VERSION_MINOR "${CMAKE_MATCH_1}")
ENDIF ()
+ FILE (STRINGS ${OPENEXR_VERSION_FILE} contents REGEX "#define OPENEXR_VERSION_PATCH ")
+ IF (${contents} MATCHES "#define OPENEXR_VERSION_PATCH ([0-9]+)")
+ SET(OPENEXR_VERSION_PATCH "${CMAKE_MATCH_1}")
+ ENDIF ()
ENDIF ()
ENDIF ()
```
|
I fixed it. Currently `OPENEXR_VERSION` had been also used to search libraries. So I split it into `OPENEXR_VERSION_MM` to search and `OPENEXR_VERSION` to show and comparing. ``` -- PNG: /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.6.43) -- TIFF: /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42 / 4.5.1) -- JPEG 2000: OpenJPEG (ver 2.5.0) -- OpenEXR: /usr/local/lib/libImath-2_2.so /usr/local/lib/libIlmImf-2_2.so /usr/local/lib/libIex-2_2.so /usr/local/lib/libHalf.so /usr/local/lib/libIlmThread-2_2.so (ver 2.2.0) ``` And I also fixed potential problem. ``` IF (OPENEXR_VERSION_MAJOR AND OPENEXR_VERSION_MINOR) set(OPENEXR_VERSION "${OPENEXR_VERSION_MAJOR}_${OPENEXR_VERSION_MINOR}") ENDIF () ``` If OpenEXR Ver x.0.y is used, this `set(OPENEXR_VERSION)` statement will not be executed. ``` IF (OPENEXR_VERSION_MAJOR AND OPENEXR_VERSION_MINOR) IF (4 AND 0) IF (TRUE AND FALSE) # non-zero means TRUE, zero means FALSE IF (FALSE) ```
|
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
|
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 154
**Code Changes:**
```diff
if(NOT OPENEXR_VERSION)
SET(OPENEXR_VERSION "Unknown")
+ else()
+ if(HAVE_CXX17 AND OPENEXR_VERSION VERSION_LESS "2.3.0")
+ message(STATUS " OpenEXR(ver ${OPENEXR_VERSION}) doesn't support C++17 and higher. Updating OpenEXR 2.3.0+ is required.")
+ SET(OPENEXR_FOUND FALSE)
+ endif()
endif()
ELSE()
IF(OPENEXR_FIND_REQUIRED)
```
|
Yes, and this problem is existed not only 5.x branch but also 4.x branch. I think after accepting pull request for 4.x branch, it will be merged into 5.x branch. https://github.com/opencv/opencv/wiki/How_to_contribute#before-you-start-contributing-you-should > If you are going to fix a bug, check that it still exists. This can be done by building the latest [4.x](https://github.com/opencv/opencv/tree/4.x)/[5.x](https://github.com/opencv/opencv/tree/5.x) branch or the [latest master branch](https://github.com/opencv/opencv), and make sure that the error is still reproducible there.
|
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/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 154
**Code Changes:**
```diff
if(NOT OPENEXR_VERSION)
SET(OPENEXR_VERSION "Unknown")
+ else()
+ if(HAVE_CXX17 AND OPENEXR_VERSION VERSION_LESS "2.3.0")
+ message(STATUS " OpenEXR(ver ${OPENEXR_VERSION}) doesn't support C++17 and higher. Updating OpenEXR 2.3.0+ is required.")
+ SET(OPENEXR_FOUND FALSE)
+ endif()
endif()
ELSE()
IF(OPENEXR_FIND_REQUIRED)
```
|
> I think after accepting pull request for 4.x branch, it will be merged into 5.x branch. Yes, I understand that. But my point is 5.x is now based on C++17 and integrated OpenEXR is 2.3.0 which supports C++17, so solution for 5.x should be: 1. Detect system OpenEXR version. 2. If the system one is below the integrated one, which is 2.3.0, the integrated one should be enabled; that is to build with flag `-DBUILD_OPENEXR=ON`. 3. If the system one is equal to or higher than the integrated one, build should go with the system one. Now you are basically turning off building with OpenEXR, right?
|
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/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 154
**Code Changes:**
```diff
if(NOT OPENEXR_VERSION)
SET(OPENEXR_VERSION "Unknown")
+ else()
+ if(HAVE_CXX17 AND OPENEXR_VERSION VERSION_LESS "2.3.0")
+ message(STATUS " OpenEXR(ver ${OPENEXR_VERSION}) doesn't support C++17 and higher. Updating OpenEXR 2.3.0+ is required.")
+ SET(OPENEXR_FOUND FALSE)
+ endif()
endif()
ELSE()
IF(OPENEXR_FIND_REQUIRED)
```
|
I'm sorry but it is diffuclt to agree about this change request for me. Even If system OpenEXR is older than v2.3.0 it doesn't means OpenCV user requests to use bundled OpenEXR(it is slightly old too). If needed, we can set enable with `-DBUILD_OPENEXR=ON` manually. Forcing ‘BUILD_OPENEXR`=`ON` losts user-selectability and it looks like bug. Related: https://github.com/opencv/opencv/issues/21326
|
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/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 99
**Code Changes:**
```diff
IF (${contents} MATCHES "#define OPENEXR_VERSION_MINOR ([0-9]+)")
SET(OPENEXR_VERSION_MINOR "${CMAKE_MATCH_1}")
ENDIF ()
+ FILE (STRINGS ${OPENEXR_VERSION_FILE} contents REGEX "#define OPENEXR_VERSION_PATCH ")
+ IF (${contents} MATCHES "#define OPENEXR_VERSION_PATCH ([0-9]+)")
+ SET(OPENEXR_VERSION_PATCH "${CMAKE_MATCH_1}")
+ ENDIF ()
ENDIF ()
ENDIF ()
- IF (OPENEXR_VERSION_MAJOR AND OPENEXR_VERSION_MINOR)
```
|
There is something wrong with code indentation.
|
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/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 154
**Code Changes:**
```diff
if(NOT OPENEXR_VERSION)
SET(OPENEXR_VERSION "Unknown")
+ else()
+ if(HAVE_CXX17 AND OPENEXR_VERSION VERSION_LESS "2.3.0")
+ message(STATUS " OpenEXR(ver ${OPENEXR_VERSION}) doesn't support C++17 and higher. Updating OpenEXR 2.3.0+ is required.")
+ SET(OPENEXR_FOUND FALSE)
+ endif()
endif()
ELSE()
IF(OPENEXR_FIND_REQUIRED)
```
|
> Forcing ‘BUILD_OPENEXR=ON` losts user-selectability and it looks like bug. I am quite open to this. But for your solution, you should add a message saying bundled OpenEXR is available for building 5.x for 5.x branch.
|
You are an expert OpenCV code reviewer specializing in documentation and code clarity. Review the provided code changes and provide specific, actionable feedback.
|
**File:** cmake/OpenCVFindOpenEXR.cmake
**Change Type:** modified
**Context:** PR #26678: build(4.x) OpenEXR 2.2 or earlier cannot be used with C++17 or later
**Review Line:** 154
**Code Changes:**
```diff
if(NOT OPENEXR_VERSION)
SET(OPENEXR_VERSION "Unknown")
+ else()
+ if(HAVE_CXX17 AND OPENEXR_VERSION VERSION_LESS "2.3.0")
+ message(STATUS " OpenEXR(ver ${OPENEXR_VERSION}) doesn't support C++17 and higher. Updating OpenEXR 2.3.0+ is required.")
+ SET(OPENEXR_FOUND FALSE)
+ endif()
endif()
ELSE()
IF(OPENEXR_FIND_REQUIRED)
```
|
OpenCV members seems do not consider to support/update bundled OpenEXR. I think bundled OpenEXR third party library will be dropped for 5.x branch in the furure. So this is hard to be solution for combination C++ Standard and OpenEXR version. See https://github.com/opencv/opencv/pull/21324#issuecomment-1305925279
|
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 #26815: Replaced sprintf with snprintf
**Code Changes:**
```diff
@@ -71,8 +71,7 @@ int main( int argc, char** argv )
namedWindow( probabilistic_name, WINDOW_AUTOSIZE );
createTrackbar( thresh_label, probabilistic_name, &p_trackbar, max_trackbar, Probabilistic_Hough );
- char edge_thresh_label[50];
- sprintf( edge_thresh_label, "Edge Thres: input" );
+ const char* edge_thresh_label = "Edge Thres: input";
namedWindow( weighted_name, WINDOW_AUTOSIZE);
createTrackbar( edge_thresh_label, weighted_name, &e_trackbar, max_trackbar, Weighted_Hough);
createTrackbar( thresh_label, weighted_name, &w_trackbar, weightedhough_max_trackbar, Weighted_Hough);
```
|
The string does not contain formatting options. It means that sprintf may be thrown away and the string constant used as is here.
|
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 #26815: Replaced sprintf with snprintf
**Code Changes:**
```diff
@@ -71,8 +71,7 @@ int main( int argc, char** argv )
namedWindow( probabilistic_name, WINDOW_AUTOSIZE );
createTrackbar( thresh_label, probabilistic_name, &p_trackbar, max_trackbar, Probabilistic_Hough );
- char edge_thresh_label[50];
- sprintf( edge_thresh_label, "Edge Thres: input" );
+ const char* edge_thresh_label = "Edge Thres: input";
namedWindow( weighted_name, WINDOW_AUTOSIZE);
createTrackbar( edge_thresh_label, weighted_name, &e_trackbar, max_trackbar, Weighted_Hough);
createTrackbar( thresh_label, weighted_name, &w_trackbar, weightedhough_max_trackbar, Weighted_Hough);
```
|
just `const char* edge_thresh_label = "Edge Thres: input";` should be enough
|
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/test/test_orientation.cpp
**Change Type:** modified
**Context:** PR #26800: fix default cap_prop_orientation_auto behaviour
**Code Changes:**
```diff
@@ -8,69 +8,80 @@ using namespace std;
namespace opencv_test { namespace {
-typedef TestWithParam<cv::VideoCaptureAPIs> VideoCaptureAPITests;
+// PR: https://github.com/opencv/opencv/pull/26800
+// TODO: Enable the tests back on Windows after FFmpeg plugin rebuild
+#ifndef _WIN32
-// related issue: https://github.com/opencv/opencv/issues/15499
```
|
This test largely repeats the previous one, can we unify them?
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/test/test_orientation.cpp
**Change Type:** modified
**Context:** PR #26800: fix default cap_prop_orientation_auto behaviour
**Code Changes:**
```diff
@@ -8,69 +8,80 @@ using namespace std;
namespace opencv_test { namespace {
-typedef TestWithParam<cv::VideoCaptureAPIs> VideoCaptureAPITests;
+// PR: https://github.com/opencv/opencv/pull/26800
+// TODO: Enable the tests back on Windows after FFmpeg plugin rebuild
+#ifndef _WIN32
-// related issue: https://github.com/opencv/opencv/issues/15499
```
|
I think this will do. Good night
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/test/test_orientation.cpp
**Change Type:** modified
**Context:** PR #26800: fix default cap_prop_orientation_auto behaviour
**Code Changes:**
```diff
@@ -8,69 +8,80 @@ using namespace std;
namespace opencv_test { namespace {
-typedef TestWithParam<cv::VideoCaptureAPIs> VideoCaptureAPITests;
+// PR: https://github.com/opencv/opencv/pull/26800
+// TODO: Enable the tests back on Windows after FFmpeg plugin rebuild
+#ifndef _WIN32
-// related issue: https://github.com/opencv/opencv/issues/15499
```
|
Maybe it would be better to remove extra stdout prints.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/test/test_orientation.cpp
**Change Type:** modified
**Context:** PR #26800: fix default cap_prop_orientation_auto behaviour
**Review Line:** 68
**Code Changes:**
```diff
- EXPECT_EQ(480, actual.width);
- EXPECT_EQ(270, actual.height);
+TEST_P(VideoCaptureAPITests, mp4_orientation_switch)
+{
+ SCOPED_TRACE("Initial orientation with autorotation");
+ orientationCheck(90., 270, 480);
+ SCOPED_TRACE("Disabled autorotation");
+ EXPECT_TRUE(cap.set(CAP_PROP_ORIENTATION_AUTO, false));
+ EXPECT_FALSE(cap.get(CAP_PROP_ORIENTATION_AUTO));
+ orientationCheck(90., 480, 270);
+}
```
|
We should use `SCOPED_TRACE` to distinguish between failures before and after orientation switch.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/test/test_orientation.cpp
**Change Type:** modified
**Context:** PR #26800: fix default cap_prop_orientation_auto behaviour
**Review Line:** 37
**Code Changes:**
```diff
- EXPECT_TRUE(cap.set(CAP_PROP_ORIENTATION_AUTO, true));
+ void orientationCheck(double angle, int width, int height)
+ {
+ EXPECT_EQ(angle, cap.get(CAP_PROP_ORIENTATION_META));
+ EXPECT_EQ(width, (int)cap.get(CAP_PROP_FRAME_WIDTH));
+ EXPECT_EQ(height, (int)cap.get(CAP_PROP_FRAME_HEIGHT));
- Size actual;
- EXPECT_NO_THROW(actual = Size((int)cap.get(CAP_PROP_FRAME_WIDTH),
- (int)cap.get(CAP_PROP_FRAME_HEIGHT)));
```
|
Perhaps we can use cv::Size: ``` EXPECT_EQ(expectedSize, Size(cap.get(CAP_PROP_FRAME_WIDTH), cap.get(CAP_PROP_FRAME_HEIGHT)));
|
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/src/shapedescr.cpp
**Change Type:** modified
**Context:** PR #26773: Improve robustness for ellipse fitting
**Code Changes:**
```diff
@@ -340,9 +340,10 @@ double cv::contourArea( InputArray _contour, bool oriented )
namespace cv
{
-static inline Point2f getOfs(int i, float eps)
+static inline Point2f getOfs(float eps)
{
- return Point2f(((i & 1)*2 - 1)*eps, ((i & 2) - 1)*eps);
+ RNG& rng = theRNG();
+ return Point2f(rng.uniform(-eps, eps), rng.uniform(-eps, eps));
```
|
I propose to use cv::RNG for it to make it manageable outside: - User may set seed to get deterministic behaviour - OpenCV test system fixes cv::RNG seed for each test independently.
|
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/shapedescr.cpp
**Change Type:** modified
**Context:** PR #26773: Improve robustness for ellipse fitting
**Code Changes:**
```diff
@@ -340,9 +340,10 @@ double cv::contourArea( InputArray _contour, bool oriented )
namespace cv
{
-static inline Point2f getOfs(int i, float eps)
+static inline Point2f getOfs(float eps)
{
- return Point2f(((i & 1)*2 - 1)*eps, ((i & 2) - 1)*eps);
+ RNG& rng = theRNG();
+ return Point2f(rng.uniform(-eps, eps), rng.uniform(-eps, eps));
```
|
Used `cv::RNG`
|
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/filter.dispatch.cpp
**Change Type:** modified
**Context:** PR #26806: removal of unused variable `kernalDataUMat`
**Code Changes:**
```diff
@@ -592,7 +592,6 @@ static bool ocl_filter2D( InputArray _src, OutputArray _dst, int ddepth,
// For smaller filter kernels, there is a special kernel that is more
// efficient than the general one.
- UMat kernalDataUMat;
if (device.isIntel() && (device.type() & ocl::Device::TYPE_GPU) &&
((ksize.width < 5 && ksize.height < 5) ||
(ksize.width == 5 && ksize.height == 5 && cn == 1)))
```
|
it seems that the variable is unused. what about removing 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_jpegxl.cpp
**Change Type:** modified
**Context:** PR #26788: imgcodecs: jpegxl: support cv::IMREAD_UNCHANGED and other ImreadFlags
**Code Changes:**
```diff
@@ -12,6 +12,19 @@
namespace cv
{
+// Callback functions for JpegXLDecoder
+static void cbRGBtoBGR_8U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBAtoBGRA_8U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBtoBGR_16U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBAtoBGRA_16U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBtoBGR_32F(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
```
|
It should be platform specific, right?
|
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_jpegxl.cpp
**Change Type:** modified
**Context:** PR #26788: imgcodecs: jpegxl: support cv::IMREAD_UNCHANGED and other ImreadFlags
**Code Changes:**
```diff
@@ -12,6 +12,19 @@
namespace cv
{
+// Callback functions for JpegXLDecoder
+static void cbRGBtoBGR_8U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBAtoBGRA_8U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBtoBGR_16U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBAtoBGRA_16U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBtoBGR_32F(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
```
|
The function behaviour depends on emptiness of the input Mat. For now it's not true, even if user mat is empty and allocated by caller side. IMHO the approach is dangerous and may be broken during refactoring or some redesign. I propose to split the concerns and introduce bool flag. It's almost free and makes the code more readable.
|
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_jpegxl.cpp
**Change Type:** modified
**Context:** PR #26788: imgcodecs: jpegxl: support cv::IMREAD_UNCHANGED and other ImreadFlags
**Code Changes:**
```diff
@@ -12,6 +12,19 @@
namespace cv
{
+// Callback functions for JpegXLDecoder
+static void cbRGBtoBGR_8U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBAtoBGRA_8U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBtoBGR_16U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBAtoBGRA_16U(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
+static void cbRGBtoBGR_32F(void *opaque, size_t x, size_t y, size_t num_pixels, const void *pixels);
```
|
Yes, I agree with you. And I refactor to remove argument variable for read() function. There are many changes, but I think it makes easier to fix and to modify.
|
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/introduction/macos_install/macos_install.markdown
**Change Type:** modified
**Context:** PR #26564: Improvement of macOS installation guide in documentation
**Review Line:** 80
**Code Changes:**
```diff
-@code{.bash}
-cd ~/<my_working_directory>
-git clone https://github.com/opencv/opencv.git
-git clone https://github.com/opencv/opencv_contrib.git
-@endcode
Building OpenCV from Source Using CMake
---------------------------------------
-# Create a temporary directory, which we denote as `build_opencv`, where you want to put
the generated Makefiles, project files as well the object files and output binaries and enter
there.
```
|
Please restore empty 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/introduction/macos_install/macos_install.markdown
**Change Type:** modified
**Context:** PR #26564: Improvement of macOS installation guide in documentation
**Code Changes:**
```diff
@@ -9,41 +9,49 @@ Installation in MacOS {#tutorial_macos_install}
| Original author | `@sajarindider` |
| Compatibility | OpenCV >= 3.4 |
-The following steps have been tested for MacOSX (Mavericks) but should work with other versions as well.
+The following steps have been tested for macOS (Mavericks) but should work with other versions as well.
Required Packages
-----------------
```
|
SIFT is included
|
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/introduction/macos_install/macos_install.markdown
**Change Type:** modified
**Context:** PR #26564: Improvement of macOS installation guide in documentation
**Code Changes:**
```diff
@@ -9,41 +9,49 @@ Installation in MacOS {#tutorial_macos_install}
| Original author | `@sajarindider` |
| Compatibility | OpenCV >= 3.4 |
-The following steps have been tested for MacOSX (Mavericks) but should work with other versions as well.
+The following steps have been tested for macOS (Mavericks) but should work with other versions as well.
Required Packages
-----------------
```
|
maybe just mention pip install opencv-contrib-python to use the extra modules
|
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/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -719,6 +719,25 @@ enum VideoCaptureOBSensorProperties{
//! @} videoio_flags_others
+/** @brief Read data stream interface
+ */
+class CV_EXPORTS_W IStreamReader
+{
+public:
+ virtual ~IStreamReader();
```
|
I would suggest to avoid this simple overload - functionality is advanced initially.
|
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/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -719,6 +719,25 @@ enum VideoCaptureOBSensorProperties{
//! @} videoio_flags_others
+/** @brief Read data stream interface
+ */
+class CV_EXPORTS_W IStreamReader
+{
+public:
+ virtual ~IStreamReader();
```
|
The same, drop simplified overload.
|
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/videoio/src/plugin_capture_api.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -13,7 +13,7 @@
/// increased for backward-compatible changes, e.g. add new function
/// Caller API <= Plugin API -> plugin is fully compatible
/// Caller API > Plugin API -> plugin is not fully compatible, caller should use extra checks to use plugins with older API
-#define CAPTURE_API_VERSION 1
+#define CAPTURE_API_VERSION 2
/// increased for incompatible changes, e.g. remove function argument
/// Caller ABI == Plugin ABI -> plugin is compatible
@@ -121,6 +121,29 @@ struct OpenCV_VideoIO_Capture_Plugin_API_v1_1_api_entries
```
|
Do we really need to handle all 3 parameters for the source in a single method of API? As we keep the previous version of the method, then we don't need to duplicate its functionality.
|
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/src/plugin_capture_api.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -13,7 +13,7 @@
/// increased for backward-compatible changes, e.g. add new function
/// Caller API <= Plugin API -> plugin is fully compatible
/// Caller API > Plugin API -> plugin is not fully compatible, caller should use extra checks to use plugins with older API
-#define CAPTURE_API_VERSION 1
+#define CAPTURE_API_VERSION 2
/// increased for incompatible changes, e.g. remove function argument
/// Caller ABI == Plugin ABI -> plugin is compatible
@@ -121,6 +121,29 @@ struct OpenCV_VideoIO_Capture_Plugin_API_v1_1_api_entries
```
|
Sorry for delay. Changed to a method which accepts only buffer. Wanted to add GStreamer backend but couldn't make it work for now.
|
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/videoio/src/plugin_capture_api.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -13,7 +13,7 @@
/// increased for backward-compatible changes, e.g. add new function
/// Caller API <= Plugin API -> plugin is fully compatible
/// Caller API > Plugin API -> plugin is not fully compatible, caller should use extra checks to use plugins with older API
-#define CAPTURE_API_VERSION 1
+#define CAPTURE_API_VERSION 2
/// increased for incompatible changes, e.g. remove function argument
/// Caller ABI == Plugin ABI -> plugin is compatible
@@ -121,6 +121,29 @@ struct OpenCV_VideoIO_Capture_Plugin_API_v1_1_api_entries
```
|
We should not pass C++ objects through low level plugin API. They are not usable in general. Different C++ ABIs are possible for OpenCV and plugin parts: - MSVS vs MinGW - GCC/Clang with different C++ standards - libc++ (GCC) / libstdc++ (Clang)
|
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/videoio/misc/python/pyopencv_videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -31,4 +31,114 @@ template<> bool pyopencv_to(PyObject* obj, cv::VideoCapture& stream, const ArgIn
return true;
}
+class PythonStreamReader : public cv::IStreamReader
+{
+public:
+ PythonStreamReader(PyObject* _obj = nullptr) : obj(_obj)
+ {
+ if (obj)
```
|
Is that ok to have relative import path? I don't want to move `CvStream` to public API
|
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/videoio/misc/python/pyopencv_videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -31,4 +31,114 @@ template<> bool pyopencv_to(PyObject* obj, cv::VideoCapture& stream, const ArgIn
return true;
}
+class PythonStreamReader : public cv::IStreamReader
+{
+public:
+ PythonStreamReader(PyObject* _obj = nullptr) : obj(_obj)
+ {
+ if (obj)
```
|
This approach might not work with [standalone](https://github.com/opencv/opencv/blob/4.x/modules/python/standalone.cmake) python bindings build or some other special configuration. As an alternative you can make it "technically" public by moving class declaration to a `.private.hpp` header like we do with [avi container](https://github.com/opencv/opencv/blob/4.x/modules/videoio/include/opencv2/videoio/container_avi.private.hpp) - symbols will be exported, but header will not be installed.
|
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/videoio/src/plugin_capture_api.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -13,7 +13,7 @@
/// increased for backward-compatible changes, e.g. add new function
/// Caller API <= Plugin API -> plugin is fully compatible
/// Caller API > Plugin API -> plugin is not fully compatible, caller should use extra checks to use plugins with older API
-#define CAPTURE_API_VERSION 1
+#define CAPTURE_API_VERSION 2
/// increased for incompatible changes, e.g. remove function argument
/// Caller ABI == Plugin ABI -> plugin is compatible
@@ -121,6 +121,29 @@ struct OpenCV_VideoIO_Capture_Plugin_API_v1_1_api_entries
```
|
- [x] Update docstring with new arguments
|
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/videoio/include/opencv2/videoio/utils.private.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -10,6 +10,37 @@
namespace cv {
CV_EXPORTS std::string icvExtractPattern(const std::string& filename, unsigned *offset);
+
+class PluginStreamReader : public IStreamReader
+{
+public:
+ PluginStreamReader(void* _opaque,
+ long long (*_read)(void* opaque, char* buffer, long long size),
```
|
`Cv` is a prefix of legacy C-API.
|
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/videoio/misc/python/pyopencv_videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -31,4 +31,114 @@ template<> bool pyopencv_to(PyObject* obj, cv::VideoCapture& stream, const ArgIn
return true;
}
+class PythonStreamReader : public cv::IStreamReader
+{
+public:
+ PythonStreamReader(PyObject* _obj = nullptr) : obj(_obj)
+ {
+ if (obj)
```
|
We don't really want to investigate problems caused by this. It looks like `#define true false` Python generator should be adopted instead.
|
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/videoio/src/backend_plugin.cpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -208,6 +208,7 @@ class PluginBackend: public IBackend
Ptr<IVideoCapture> createCapture(int camera, const VideoCaptureParameters& params) const CV_OVERRIDE;
Ptr<IVideoCapture> createCapture(const std::string &filename) const;
Ptr<IVideoCapture> createCapture(const std::string &filename, const VideoCaptureParameters& params) const CV_OVERRIDE;
+ Ptr<IVideoCapture> createCapture(const Ptr<IStreamReader>& stream, const VideoCaptureParameters& params) const CV_OVERRIDE;
Ptr<IVideoWriter> createWriter(const std::string& filename, int fourcc, double fps,
const cv::Size& sz, const VideoWriterParameters& params) const CV_OVERRIDE;
@@ -447,16 +448,52 @@ class PluginCapture : public cv::IVideoCapture
{
```
|
No need to use `std::streambuf` anywhere in API. We need to use internally just simplified class which provides seek/read **interface**. Public API should have simple converter from this.
|
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_ffmpeg.cpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -74,6 +74,11 @@ class CvCapture_FFMPEG_proxy CV_FINAL : public cv::VideoCaptureBase
{
open(filename, params);
}
+ CvCapture_FFMPEG_proxy(const Ptr<IStreamReader>& stream, const cv::VideoCaptureParameters& params)
+ : ffmpegCapture(NULL)
+ {
+ open(stream, params);
+ }
virtual ~CvCapture_FFMPEG_proxy() { close(); }
```
|
Where do we seek to zero after this check?
|
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/videoio/src/videoio_registry.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -14,6 +14,7 @@ namespace cv
enum BackendMode {
MODE_CAPTURE_BY_INDEX = 1 << 0, //!< device index
MODE_CAPTURE_BY_FILENAME = 1 << 1, //!< filename or device path (v4l2)
+ MODE_CAPTURE_BY_STREAM = 1 << 2, //!< data stream
MODE_WRITER = 1 << 4, //!< writer
MODE_CAPTURE_ALL = MODE_CAPTURE_BY_INDEX + MODE_CAPTURE_BY_FILENAME,
@@ -38,6 +39,7 @@ namespace videoio_registry {
```
|
`BY_STREAM`
|
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_ffmpeg.cpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -74,6 +74,11 @@ class CvCapture_FFMPEG_proxy CV_FINAL : public cv::VideoCaptureBase
{
open(filename, params);
}
+ CvCapture_FFMPEG_proxy(const Ptr<IStreamReader>& stream, const cv::VideoCaptureParameters& params)
+ : ffmpegCapture(NULL)
+ {
+ open(stream, params);
+ }
virtual ~CvCapture_FFMPEG_proxy() { close(); }
```
|
`sgetc` does not modify sequence position. I also worried about that but checked again
|
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_ffmpeg.cpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -74,6 +74,11 @@ class CvCapture_FFMPEG_proxy CV_FINAL : public cv::VideoCaptureBase
{
open(filename, params);
}
+ CvCapture_FFMPEG_proxy(const Ptr<IStreamReader>& stream, const cv::VideoCaptureParameters& params)
+ : ffmpegCapture(NULL)
+ {
+ open(stream, params);
+ }
virtual ~CvCapture_FFMPEG_proxy() { close(); }
```
|
Removed completely
|
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/videoio/misc/python/pyopencv_videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -31,4 +31,114 @@ template<> bool pyopencv_to(PyObject* obj, cv::VideoCapture& stream, const ArgIn
return true;
}
+class PythonStreamReader : public cv::IStreamReader
+{
+public:
+ PythonStreamReader(PyObject* _obj = nullptr) : obj(_obj)
+ {
+ if (obj)
```
|
Added an alias like done for std::string in python generator. However std:: prefix is still missed somewhere
|
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/include/opencv2/videoio/registry.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -35,6 +35,9 @@ CV_EXPORTS_W std::vector<VideoCaptureAPIs> getCameraBackends();
/** @brief Returns list of available backends which works via `cv::VideoCapture(filename)` */
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getStreamBackends();
+/** @brief Returns list of available backends which works via `cv::VideoCapture(buffer)` */
+CV_EXPORTS_W std::vector<VideoCaptureAPIs> getStreamBufferedBackends();
+
/** @brief Returns list of available backends which works via `cv::VideoWriter()` */
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getWriterBackends();
```
|
Buffer => Stream
|
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/include/opencv2/videoio/registry.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -35,6 +35,9 @@ CV_EXPORTS_W std::vector<VideoCaptureAPIs> getCameraBackends();
/** @brief Returns list of available backends which works via `cv::VideoCapture(filename)` */
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getStreamBackends();
+/** @brief Returns list of available backends which works via `cv::VideoCapture(buffer)` */
+CV_EXPORTS_W std::vector<VideoCaptureAPIs> getStreamBufferedBackends();
+
/** @brief Returns list of available backends which works via `cv::VideoWriter()` */
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getWriterBackends();
```
|
Buffer => Stream
|
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_ffmpeg.cpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -74,6 +74,11 @@ class CvCapture_FFMPEG_proxy CV_FINAL : public cv::VideoCaptureBase
{
open(filename, params);
}
+ CvCapture_FFMPEG_proxy(const Ptr<IStreamReader>& stream, const cv::VideoCaptureParameters& params)
+ : ffmpegCapture(NULL)
+ {
+ open(stream, params);
+ }
virtual ~CvCapture_FFMPEG_proxy() { close(); }
```
|
> `Ptr<IReadStream>(new ...` `makePtr` / `std::make_shared`
|
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -719,6 +719,25 @@ enum VideoCaptureOBSensorProperties{
//! @} videoio_flags_others
+/** @brief Read data stream interface
+ */
+class CV_EXPORTS_W IStreamReader
+{
+public:
+ virtual ~IStreamReader();
```
|
> in memory buffer Opens a video using data stream.
|
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/videoio/include/opencv2/videoio/utils.private.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -10,6 +10,37 @@
namespace cv {
CV_EXPORTS std::string icvExtractPattern(const std::string& filename, unsigned *offset);
+
+class PluginStreamReader : public IStreamReader
+{
+public:
+ PluginStreamReader(void* _opaque,
+ long long (*_read)(void* opaque, char* buffer, long long size),
```
|
`ReadStreamPluginProvider` Usually `Callback` means abstract interface description. We already have the `IReadStream` for that.
|
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/videoio/misc/python/pyopencv_videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -31,4 +31,114 @@ template<> bool pyopencv_to(PyObject* obj, cv::VideoCapture& stream, const ArgIn
return true;
}
+class PythonStreamReader : public cv::IStreamReader
+{
+public:
+ PythonStreamReader(PyObject* _obj = nullptr) : obj(_obj)
+ {
+ if (obj)
```
|
Check `len < n`
|
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/videoio/misc/python/pyopencv_videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Review Line:** 116
**Code Changes:**
```diff
+ CV_Error(cv::Error::StsError, "Python .seek() result => long long conversion error");
+ return pos;
+ }
+
+private:
+ PyObject* obj;
+};
+
+template<>
+bool pyopencv_to(PyObject* obj, Ptr<cv::IStreamReader>& p, const ArgInfo&)
+{
```
|
Who calls `Py_DECREF` ?
|
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/videoio/src/cap.cpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -65,6 +65,10 @@ static bool param_VIDEOWRITER_DEBUG = utils::getConfigurationParameterBool("OPEN
void DefaultDeleter<CvCapture>::operator ()(CvCapture* obj) const { cvReleaseCapture(&obj); }
void DefaultDeleter<CvVideoWriter>::operator ()(CvVideoWriter* obj) const { cvReleaseVideoWriter(&obj); }
+IStreamReader::~IStreamReader()
+{
+ // nothing
+}
VideoCapture::VideoCapture() : throwOnFail(false)
```
|
Who performs `seek(0, 0)` between trials? Perhaps we should not allow `CAP_ANY` in this API.
|
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/videoio/include/opencv2/videoio/utils.private.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -10,6 +10,37 @@
namespace cv {
CV_EXPORTS std::string icvExtractPattern(const std::string& filename, unsigned *offset);
+
+class PluginStreamReader : public IStreamReader
+{
+public:
+ PluginStreamReader(void* _opaque,
+ long long (*_read)(void* opaque, char* buffer, long long size),
```
|
There is no guarantee for lifetime of this. Perhaps we need to pass `std::shared_ptr<std::streambuf>` in public API.
|
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/videoio/include/opencv2/videoio/utils.private.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -10,6 +10,37 @@
namespace cv {
CV_EXPORTS std::string icvExtractPattern(const std::string& filename, unsigned *offset);
+
+class PluginStreamReader : public IStreamReader
+{
+public:
+ PluginStreamReader(void* _opaque,
+ long long (*_read)(void* opaque, char* buffer, long long size),
```
|
Looks useless because it could not (and should not) create independent objects (at least seek pointer is shared). See below comment about lifetime.
|
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/videoio_registry.cpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -47,7 +47,12 @@ namespace {
#define DECLARE_STATIC_BACKEND(cap, name, mode, createCaptureFile, createCaptureCamera, createWriter) \
{ \
- cap, (BackendMode)(mode), 1000, name, createBackendFactory(createCaptureFile, createCaptureCamera, createWriter) \
+ cap, (BackendMode)(mode), 1000, name, createBackendFactory(createCaptureFile, createCaptureCamera, 0, createWriter) \
+},
+
+#define DECLARE_STATIC_BACKEND_WITH_STREAM_SUPPORT(cap, name, mode, createCaptureStream) \
+{ \
```
|
Please add new macro instead of massive refactoring: `DECLARE_STATIC_BACKEND_WITH_STREAM_SUPPORT`
|
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/videoio/src/videoio_registry.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -14,6 +14,7 @@ namespace cv
enum BackendMode {
MODE_CAPTURE_BY_INDEX = 1 << 0, //!< device index
MODE_CAPTURE_BY_FILENAME = 1 << 1, //!< filename or device path (v4l2)
+ MODE_CAPTURE_BY_STREAM = 1 << 2, //!< data stream
MODE_WRITER = 1 << 4, //!< writer
MODE_CAPTURE_ALL = MODE_CAPTURE_BY_INDEX + MODE_CAPTURE_BY_FILENAME,
@@ -38,6 +39,7 @@ namespace videoio_registry {
```
|
need to update comment too.
|
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/videoio/src/videoio_registry.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -14,6 +14,7 @@ namespace cv
enum BackendMode {
MODE_CAPTURE_BY_INDEX = 1 << 0, //!< device index
MODE_CAPTURE_BY_FILENAME = 1 << 1, //!< filename or device path (v4l2)
+ MODE_CAPTURE_BY_STREAM = 1 << 2, //!< data stream
MODE_WRITER = 1 << 4, //!< writer
MODE_CAPTURE_ALL = MODE_CAPTURE_BY_INDEX + MODE_CAPTURE_BY_FILENAME,
@@ -38,6 +39,7 @@ namespace videoio_registry {
```
|
`getAvailableBackends_CaptureByStream`
|
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/videoio/include/opencv2/videoio/registry.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -35,6 +35,9 @@ CV_EXPORTS_W std::vector<VideoCaptureAPIs> getCameraBackends();
/** @brief Returns list of available backends which works via `cv::VideoCapture(filename)` */
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getStreamBackends();
+/** @brief Returns list of available backends which works via `cv::VideoCapture(buffer)` */
+CV_EXPORTS_W std::vector<VideoCaptureAPIs> getStreamBufferedBackends();
+
/** @brief Returns list of available backends which works via `cv::VideoWriter()` */
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getWriterBackends();
```
|
Oh, seems like `getStreamBackends` is busy (see above)
|
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/videoio/include/opencv2/videoio/utils.private.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -10,6 +10,37 @@
namespace cv {
CV_EXPORTS std::string icvExtractPattern(const std::string& filename, unsigned *offset);
+
+class PluginStreamReader : public IStreamReader
+{
+public:
+ PluginStreamReader(void* _opaque,
+ long long (*_read)(void* opaque, char* buffer, long long size),
```
|
Removed `clone` method completely in last commit. As I understand, `struct CvCapture_FFMPEG` cannot hold a copy of `Ptr<IReadStream>` because there is no default constructor to allocate it: https://github.com/opencv/opencv/blob/b42075f3e2c7eca4a12e55b32cfc95fa90982a21/modules/videoio/src/cap_ffmpeg_impl.hpp#L3296 So I used `CvCapture_FFMPEG_proxy` to increase a counter
|
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/videoio/misc/python/pyopencv_videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Review Line:** 116
**Code Changes:**
```diff
+ CV_Error(cv::Error::StsError, "Python .seek() result => long long conversion error");
+ return pos;
+ }
+
+private:
+ PyObject* obj;
+};
+
+template<>
+bool pyopencv_to(PyObject* obj, Ptr<cv::IStreamReader>& p, const ArgInfo&)
+{
```
|
Added `Py_INCREF` as well
|
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/videoio/include/opencv2/videoio/utils.private.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -10,6 +10,37 @@
namespace cv {
CV_EXPORTS std::string icvExtractPattern(const std::string& filename, unsigned *offset);
+
+class PluginStreamReader : public IStreamReader
+{
+public:
+ PluginStreamReader(void* _opaque,
+ long long (*_read)(void* opaque, char* buffer, long long size),
```
|
Agree, I think it can simplify other bindings addition in future.
|
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/videoio/src/cap.cpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -65,6 +65,10 @@ static bool param_VIDEOWRITER_DEBUG = utils::getConfigurationParameterBool("OPEN
void DefaultDeleter<CvCapture>::operator ()(CvCapture* obj) const { cvReleaseCapture(&obj); }
void DefaultDeleter<CvVideoWriter>::operator ()(CvVideoWriter* obj) const { cvReleaseVideoWriter(&obj); }
+IStreamReader::~IStreamReader()
+{
+ // nothing
+}
VideoCapture::VideoCapture() : throwOnFail(false)
```
|
Good point, there is no explicit seek. Added a check that `apiPref != CAP_ANY`
|
You are an expert OpenCV code reviewer specializing in memory management. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/include/opencv2/videoio/registry.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -35,6 +35,9 @@ CV_EXPORTS_W std::vector<VideoCaptureAPIs> getCameraBackends();
/** @brief Returns list of available backends which works via `cv::VideoCapture(filename)` */
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getStreamBackends();
+/** @brief Returns list of available backends which works via `cv::VideoCapture(buffer)` */
+CV_EXPORTS_W std::vector<VideoCaptureAPIs> getStreamBufferedBackends();
+
/** @brief Returns list of available backends which works via `cv::VideoWriter()` */
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getWriterBackends();
```
|
`getStreamBufferedBackends` ?
|
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/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -719,6 +719,25 @@ enum VideoCaptureOBSensorProperties{
//! @} videoio_flags_others
+/** @brief Read data stream interface
+ */
+class CV_EXPORTS_W IStreamReader
+{
+public:
+ virtual ~IStreamReader();
```
|
`const reference` here and below (or we should use `std::move()` massively)
|
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/videoio/misc/python/pyopencv_videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -31,4 +31,114 @@ template<> bool pyopencv_to(PyObject* obj, cv::VideoCapture& stream, const ArgIn
return true;
}
+class PythonStreamReader : public cv::IStreamReader
+{
+public:
+ PythonStreamReader(PyObject* _obj = nullptr) : obj(_obj)
+ {
+ if (obj)
```
|
`CV_Error` doesn't call cleanup (release GIL and release `type`). ``` if (...) has_error = true; ... cleanup ... if (has_error) CV_Error(...); ```
|
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_ffmpeg.cpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -74,6 +74,11 @@ class CvCapture_FFMPEG_proxy CV_FINAL : public cv::VideoCaptureBase
{
open(filename, params);
}
+ CvCapture_FFMPEG_proxy(const Ptr<IStreamReader>& stream, const cv::VideoCaptureParameters& params)
+ : ffmpegCapture(NULL)
+ {
+ open(stream, params);
+ }
virtual ~CvCapture_FFMPEG_proxy() { close(); }
```
|
> `makePtr<ReadStreamPluginProvider>(opaque, read, seek)` Released right after this call because it is not saved anywhere.
|
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_ffmpeg.cpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -74,6 +74,11 @@ class CvCapture_FFMPEG_proxy CV_FINAL : public cv::VideoCaptureBase
{
open(filename, params);
}
+ CvCapture_FFMPEG_proxy(const Ptr<IStreamReader>& stream, const cv::VideoCaptureParameters& params)
+ : ffmpegCapture(NULL)
+ {
+ open(stream, params);
+ }
virtual ~CvCapture_FFMPEG_proxy() { close(); }
```
|
As a workaround, `readStream = stream` for now
|
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/videoio/include/opencv2/videoio/registry.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -35,6 +35,9 @@ CV_EXPORTS_W std::vector<VideoCaptureAPIs> getCameraBackends();
/** @brief Returns list of available backends which works via `cv::VideoCapture(filename)` */
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getStreamBackends();
+/** @brief Returns list of available backends which works via `cv::VideoCapture(buffer)` */
+CV_EXPORTS_W std::vector<VideoCaptureAPIs> getStreamBufferedBackends();
+
/** @brief Returns list of available backends which works via `cv::VideoWriter()` */
CV_EXPORTS_W std::vector<VideoCaptureAPIs> getWriterBackends();
```
|
Changed locally, can commit with https://github.com/opencv/opencv/pull/25584#discussion_r1896904920 if actual
|
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -719,6 +719,25 @@ enum VideoCaptureOBSensorProperties{
//! @} videoio_flags_others
+/** @brief Read data stream interface
+ */
+class CV_EXPORTS_W IStreamReader
+{
+public:
+ virtual ~IStreamReader();
```
|
Do we really need methods with `std::streambuf`? Maybe it would be better to make `StreambufReadStream` or similar class or just its factory public instead? For example: ```.cpp shared_ptr<IStreamReader> source = createStdStream(filename); // can accept filename or &&filebuf or &&istream or &&ifstream VideoCapture cap(source, ...); ```
|
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Code Changes:**
```diff
@@ -719,6 +719,25 @@ enum VideoCaptureOBSensorProperties{
//! @} videoio_flags_others
+/** @brief Read data stream interface
+ */
+class CV_EXPORTS_W IStreamReader
+{
+public:
+ virtual ~IStreamReader();
```
|
Good point. But I think we can even remove it completely. `std::streambuf` might introduce more limitations than just seek/read interface. So I can move `class StreambufReadStream : public IStreamReader` example to the tests for now and remove option from public API.
|
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/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Review Line:** 735
**Code Changes:**
```diff
+ virtual long long read(char* buffer, long long size) = 0;
+
+ /** @brief Sets the stream position
+ *
+ * @param offset Seek offset
+ * @param origin SEEK_SET / SEEK_END / SEEK_CUR
+ *
+ * @see fseek
+ */
+ virtual long long seek(long long offset, int origin) = 0;
+};
```
|
Wouldn't it be better to completely avoid C/C++ constants in public interface and introduce our own?
|
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/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Review Line:** 735
**Code Changes:**
```diff
+ virtual long long read(char* buffer, long long size) = 0;
+
+ /** @brief Sets the stream position
+ *
+ * @param offset Seek offset
+ * @param origin SEEK_SET / SEEK_END / SEEK_CUR
+ *
+ * @see fseek
+ */
+ virtual long long seek(long long offset, int origin) = 0;
+};
```
|
FFmpeg (basically) and Python use them too (with same values). IMHO, it is not necessary to introduce extra conversions to/from own values.
|
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/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Review Line:** 735
**Code Changes:**
```diff
+ virtual long long read(char* buffer, long long size) = 0;
+
+ /** @brief Sets the stream position
+ *
+ * @param offset Seek offset
+ * @param origin SEEK_SET / SEEK_END / SEEK_CUR
+ *
+ * @see fseek
+ */
+ virtual long long seek(long long offset, int origin) = 0;
+};
```
|
Agree, we can add such enum but potential user will still cast to integer or introduce long if/else/switch
|
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/videoio/include/opencv2/videoio.hpp
**Change Type:** modified
**Context:** PR #25584: Open VideoCapture from data stream
**Review Line:** 735
**Code Changes:**
```diff
+ virtual long long read(char* buffer, long long size) = 0;
+
+ /** @brief Sets the stream position
+ *
+ * @param offset Seek offset
+ * @param origin SEEK_SET / SEEK_END / SEEK_CUR
+ *
+ * @see fseek
+ */
+ virtual long long seek(long long offset, int origin) = 0;
+};
```
|
My concern was that user would be required to include `<stdio.h>`/`<cstdio>` in order to use this seemingly unrelated class. Though perhaps it's fine.
|
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_gif.cpp
**Change Type:** modified
**Context:** PR #26738: fix bugs in GIF decoding
**Review Line:** 438
**Code Changes:**
```diff
+ CV_LOG_WARNING(NULL, "found Unknown Extension Type: " + std::to_string(extension));
+ }
+ int len = m_strm.getByte();
+ while (len) {
+ m_strm.skip(len);
+ len = m_strm.getByte();
}
}
} else if (!(type ^ 0x2C)) {
```
|
I propose to print info/warning message about skipped extensions with CV_LOG_INFO/CV_LOG_WARNING. It helps to highlight unexpected behaviour in some cases.
|
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_gif.cpp
**Change Type:** modified
**Context:** PR #26738: fix bugs in GIF decoding
**Code Changes:**
```diff
@@ -4,6 +4,7 @@
#include "precomp.hpp"
#include "grfmt_gif.hpp"
+#include "opencv2/core/utils/logger.hpp"
#ifdef HAVE_IMGCODEC_GIF
namespace cv
@@ -293,11 +294,12 @@ void GifDecoder::code2pixel(Mat& img, int start, int k){
bool GifDecoder::lzwDecode() {
```
|
I propose to use local len variable here and in the else branch like `int len = m_strm.getByte();`. It allows to get rid of "uninitialized varible" warnings by compiler and some tools like valgrind/asan, etc.
|
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_gif.cpp
**Change Type:** modified
**Context:** PR #26738: fix bugs in GIF decoding
**Code Changes:**
```diff
@@ -4,6 +4,7 @@
#include "precomp.hpp"
#include "grfmt_gif.hpp"
+#include "opencv2/core/utils/logger.hpp"
#ifdef HAVE_IMGCODEC_GIF
namespace cv
@@ -293,11 +294,12 @@ void GifDecoder::code2pixel(Mat& img, int start, int k){
bool GifDecoder::lzwDecode() {
```
|
Why not `lzwTableSize`?
|
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_gif.cpp
**Change Type:** modified
**Context:** PR #26738: fix bugs in GIF decoding
**Code Changes:**
```diff
@@ -4,6 +4,7 @@
#include "precomp.hpp"
#include "grfmt_gif.hpp"
+#include "opencv2/core/utils/logger.hpp"
#ifdef HAVE_IMGCODEC_GIF
namespace cv
@@ -293,11 +294,12 @@ void GifDecoder::code2pixel(Mat& img, int start, int k){
bool GifDecoder::lzwDecode() {
```
|
because (1<<12) is the maximum size of lzwtable, thus i use (1<<12)+1 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_gif.cpp
**Change Type:** modified
**Context:** PR #26738: fix bugs in GIF decoding
**Review Line:** 438
**Code Changes:**
```diff
+ CV_LOG_WARNING(NULL, "found Unknown Extension Type: " + std::to_string(extension));
+ }
+ int len = m_strm.getByte();
+ while (len) {
+ m_strm.skip(len);
+ len = m_strm.getByte();
}
}
} else if (!(type ^ 0x2C)) {
```
|
> I propose to print info/warning message about skipped extensions with CV_LOG_INFO/CV_LOG_WARNING. It helps to highlight unexpected behaviour in some cases. i think no need. ( probably we see lots of warning )
|
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_gif.cpp
**Change Type:** modified
**Context:** PR #26738: fix bugs in GIF decoding
**Code Changes:**
```diff
@@ -4,6 +4,7 @@
#include "precomp.hpp"
#include "grfmt_gif.hpp"
+#include "opencv2/core/utils/logger.hpp"
#ifdef HAVE_IMGCODEC_GIF
namespace cv
@@ -293,11 +294,12 @@ void GifDecoder::code2pixel(Mat& img, int start, int k){
bool GifDecoder::lzwDecode() {
```
|
Not variable, but constant.
|
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_gif.cpp
**Change Type:** modified
**Context:** PR #26738: fix bugs in GIF decoding
**Review Line:** 438
**Code Changes:**
```diff
+ CV_LOG_WARNING(NULL, "found Unknown Extension Type: " + std::to_string(extension));
+ }
+ int len = m_strm.getByte();
+ while (len) {
+ m_strm.skip(len);
+ len = m_strm.getByte();
}
}
} else if (!(type ^ 0x2C)) {
```
|
> > I propose to print info/warning message about skipped extensions with CV_LOG_INFO/CV_LOG_WARNING. It helps to highlight unexpected behaviour in some cases. > > i think no need. ( probably we see lots of warning ) i just pick those not mentioned in GIF spec, which may not occur in normal cases (but actually allowed)
|
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_gif.cpp
**Change Type:** modified
**Context:** PR #26738: fix bugs in GIF decoding
**Code Changes:**
```diff
@@ -4,6 +4,7 @@
#include "precomp.hpp"
#include "grfmt_gif.hpp"
+#include "opencv2/core/utils/logger.hpp"
#ifdef HAVE_IMGCODEC_GIF
namespace cv
@@ -293,11 +294,12 @@ void GifDecoder::code2pixel(Mat& img, int start, int k){
bool GifDecoder::lzwDecode() {
```
|
maybe `const int lzwMaxSize = 1 << 12; // 4096 is the maximum code width`
|
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_gif.cpp
**Change Type:** modified
**Context:** PR #26738: fix bugs in GIF decoding
**Code Changes:**
```diff
@@ -4,6 +4,7 @@
#include "precomp.hpp"
#include "grfmt_gif.hpp"
+#include "opencv2/core/utils/logger.hpp"
#ifdef HAVE_IMGCODEC_GIF
namespace cv
@@ -293,11 +294,12 @@ void GifDecoder::code2pixel(Mat& img, int start, int k){
bool GifDecoder::lzwDecode() {
```
|
well actually here i mean the bit width, but i will modify this later to avoid misunderstanding
|
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_gif.cpp
**Change Type:** modified
**Context:** PR #26738: fix bugs in GIF decoding
**Code Changes:**
```diff
@@ -4,6 +4,7 @@
#include "precomp.hpp"
#include "grfmt_gif.hpp"
+#include "opencv2/core/utils/logger.hpp"
#ifdef HAVE_IMGCODEC_GIF
namespace cv
@@ -293,11 +294,12 @@ void GifDecoder::code2pixel(Mat& img, int start, int k){
bool GifDecoder::lzwDecode() {
```
|
i suggest (ChatGPT's suggestion) const int lzwMaxSize = 1 << 12; // 4096 is the maximum size of the LZW table (12 bits)
|
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 #26748: Fix remaining bugs in PNG reader
**Code Changes:**
```diff
@@ -339,6 +339,10 @@ bool PngDecoder::readHeader()
png_bytep trans;
png_color_16p trans_values;
+ // Free chunk in case png_read_info uses longjmp.
+ chunk.p.clear();
+ chunk.p.shrink_to_fit();
+
png_read_info( png_ptr, info_ptr );
png_get_IHDR(png_ptr, info_ptr, &wdth, &hght,
```
|
When the png_read_info( png_ptr, info_ptr ); function is called, if there are acTL and fcTL chunks, they will be skipped. For the ongoing manual chunk reading, it is necessary to get the file position back. btw i am not sure this change is necessary. old code returns false if there were a problem. if so there is no need to `png_read_info`
|
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 #26748: Fix remaining bugs in PNG reader
**Code Changes:**
```diff
@@ -339,6 +339,10 @@ bool PngDecoder::readHeader()
png_bytep trans;
png_color_16p trans_values;
+ // Free chunk in case png_read_info uses longjmp.
+ chunk.p.clear();
+ chunk.p.shrink_to_fit();
+
png_read_info( png_ptr, info_ptr );
png_get_IHDR(png_ptr, info_ptr, &wdth, &hght,
```
|
indeed, that was not the issue, I reverted
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/calib3d/src/fundam.cpp
**Change Type:** modified
**Context:** PR #26742: Bug fix for #25546 - Updating inliers for homography estimation
**Review Line:** 420
**Code Changes:**
```diff
if( result && npoints > 4 && method != RHO)
{
+ // save the original points before compressing
+ const int npoints_input = npoints;
+ const Mat src_input = src.clone();
+ const Mat dst_input = dst.clone();
+
compressElems( src.ptr<Point2f>(), tempMask.ptr<uchar>(), 1, npoints );
npoints = compressElems( dst.ptr<Point2f>(), tempMask.ptr<uchar>(), 1, npoints );
if( npoints > 0 )
@@ -427,6 +432,16 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2,
```
|
Why do you need copies here? HomographyEstimatorCallback::computeError() does not modify inputs.
|
You are an expert OpenCV code reviewer specializing in implementation quality. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/calib3d/src/fundam.cpp
**Change Type:** modified
**Context:** PR #26742: Bug fix for #25546 - Updating inliers for homography estimation
**Review Line:** 420
**Code Changes:**
```diff
if( result && npoints > 4 && method != RHO)
{
+ // save the original points before compressing
+ const int npoints_input = npoints;
+ const Mat src_input = src.clone();
+ const Mat dst_input = dst.clone();
+
compressElems( src.ptr<Point2f>(), tempMask.ptr<uchar>(), 1, npoints );
npoints = compressElems( dst.ptr<Point2f>(), tempMask.ptr<uchar>(), 1, npoints );
if( npoints > 0 )
@@ -427,6 +432,16 @@ cv::Mat cv::findHomography( InputArray _points1, InputArray _points2,
```
|
The copies are needed, because src and dst points are first compressed here: ``` compressElems( src.ptr<Point2f>(), tempMask.ptr<uchar>(), 1, npoints ); npoints = compressElems( dst.ptr<Point2f>(), tempMask.ptr<uchar>(), 1, npoints ); ``` and then are overwritten here: ``` Mat src1 = src.rowRange(0, npoints); Mat dst1 = dst.rowRange(0, npoints); src = src1; dst = dst1; ``` Basically, new src, dst become of size of number of inliers before LMSolver, but the errors must be computed on all original points.
|
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/objc/generator/gen_objc.py
**Change Type:** modified
**Context:** PR #26713: Ensure Obj-C header files are generated correctly if under /private/var
**Review Line:** 1665
**Code Changes:**
```diff
@@ -1662,7 +1662,9 @@ def sanitize_documentation_string(doc, type):
h_files += [os.path.join(root, filename) for filename in fnmatch.filter(filenames, '*.h')]
hpp_files += [os.path.join(root, filename) for filename in fnmatch.filter(filenames, '*.hpp')]
srcfiles = h_files + hpp_files
- srcfiles = [f for f in srcfiles if not re_bad.search(f.replace('\\', '/'))]
+ # Use relative paths to avoid being affected by the name of the parent directory.
+ # See https://github.com/opencv/opencv/issues/26712
+ srcfiles = [f for f in srcfiles if not re_bad.search(os.path.relpath(f, module_location).replace('\\', '/'))]
logging.info("\nFiles (%d):\n%s", len(srcfiles), pformat(srcfiles))
common_headers_fname = os.path.join(misc_location, 'filelist_common')
```
|
Could you add comment to the source code with the reason why you use relative path instead of absolute. Reference to the original Bazel issue will be useful too.
|
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/objc/generator/gen_objc.py
**Change Type:** modified
**Context:** PR #26713: Ensure Obj-C header files are generated correctly if under /private/var
**Review Line:** 1665
**Code Changes:**
```diff
@@ -1662,7 +1662,9 @@ def sanitize_documentation_string(doc, type):
h_files += [os.path.join(root, filename) for filename in fnmatch.filter(filenames, '*.h')]
hpp_files += [os.path.join(root, filename) for filename in fnmatch.filter(filenames, '*.hpp')]
srcfiles = h_files + hpp_files
- srcfiles = [f for f in srcfiles if not re_bad.search(f.replace('\\', '/'))]
+ # Use relative paths to avoid being affected by the name of the parent directory.
+ # See https://github.com/opencv/opencv/issues/26712
+ srcfiles = [f for f in srcfiles if not re_bad.search(os.path.relpath(f, module_location).replace('\\', '/'))]
logging.info("\nFiles (%d):\n%s", len(srcfiles), pformat(srcfiles))
common_headers_fname = os.path.join(misc_location, 'filelist_common')
```
|
I've added a comment. https://github.com/opencv/opencv/pull/26713/commits/ee7b9481461f6f23e9be61e35b1330601d114e0c Is it okay if I don't squash it into a single commit and force push?
|
You are an expert OpenCV code reviewer specializing in testing and validation. Review the provided code changes and provide specific, actionable feedback.
|
**File:** modules/objdetect/src/qrcode.cpp
**Change Type:** modified
**Context:** PR #26650: Use size_t when calculating size of all_points
**Code Changes:**
```diff
@@ -19,7 +19,6 @@
#include <limits>
#include <cmath>
#include <queue>
-#include <limits>
#include <map>
namespace cv
@@ -3709,7 +3708,11 @@ bool QRDetectMulti::checkSets(vector<vector<Point2f> >& true_points_group, vecto
vector<int> set_size(true_points_group.size());
```
|
3 asserts are overkill here. We have expression like (x-2)*(x-1)*x / 6. It means that single check `CV_Assert(x < limit)` or `CV_Assert(expr < std::numeric_limits<int>::max())` is enough.
|
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 #26715: Fixed some memory leaks in PNG/APNG implementation
**Code Changes:**
```diff
@@ -181,8 +181,8 @@ PngDecoder::PngDecoder()
{
m_signature = "\x89\x50\x4e\x47\xd\xa\x1a\xa";
m_color_type = 0;
- m_png_ptr = 0;
- m_info_ptr = m_end_info = 0;
+ m_png_ptr = nullptr;
+ m_info_ptr = m_end_info = nullptr;
m_f = 0;
m_buf_supported = true;
```
|
Extra added line
|
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 #26688: Animated GIF APNG WEBP AVIF revisions
**Review Line:** 391
**Code Changes:**
```diff
@@ -389,7 +388,7 @@ bool PngDecoder::readData( Mat& img )
{
if (m_frame_count > 1)
{
- Mat mat_cur = Mat(img.rows, img.cols, m_type);
+ Mat mat_cur = Mat::zeros(img.rows, img.cols, m_type);
uint32_t id = 0;
uint32_t j = 0;
uint32_t imagesize = m_width * m_height * mat_cur.channels();
@@ -437,7 +436,7 @@ bool PngDecoder::readData( Mat& img )
if (dop == 2)
```
|
setting to zeros is necessary ?
|
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 #26688: Animated GIF APNG WEBP AVIF revisions
**Code Changes:**
```diff
@@ -152,8 +152,7 @@ bool APNGFrame::setMat(const cv::Mat& src, unsigned delayNum, unsigned delayDen)
if (!src.empty())
{
- png_uint_32 rowbytes = src.cols * src.channels();
-
+ png_uint_32 rowbytes = src.depth() == CV_16U ? src.cols * src.channels() * 2 : src.cols * src.channels();
_width = src.cols;
_height = src.rows;
_colorType = src.channels() == 1 ? PNG_COLOR_TYPE_GRAY : src.channels() == 3 ? PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_RGB_ALPHA;
```
|
Cool ! Let's fix it first then: https://github.com/opencv/opencv/pull/26704
|
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()));
+}
+
```
|
how about also testing the frames are the same as the input ones ?
|
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 #26688: Animated GIF APNG WEBP AVIF revisions
**Review Line:** 391
**Code Changes:**
```diff
@@ -389,7 +388,7 @@ bool PngDecoder::readData( Mat& img )
{
if (m_frame_count > 1)
{
- Mat mat_cur = Mat(img.rows, img.cols, m_type);
+ Mat mat_cur = Mat::zeros(img.rows, img.cols, m_type);
uint32_t id = 0;
uint32_t j = 0;
uint32_t imagesize = m_width * m_height * mat_cur.channels();
@@ -437,7 +436,7 @@ bool PngDecoder::readData( Mat& img )
if (dop == 2)
```
|
 this file render garbage memory without Mat::zeros.
|
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 #26688: Animated GIF APNG WEBP AVIF revisions
**Review Line:** 391
**Code Changes:**
```diff
@@ -389,7 +388,7 @@ bool PngDecoder::readData( Mat& img )
{
if (m_frame_count > 1)
{
- Mat mat_cur = Mat(img.rows, img.cols, m_type);
+ Mat mat_cur = Mat::zeros(img.rows, img.cols, m_type);
uint32_t id = 0;
uint32_t j = 0;
uint32_t imagesize = m_width * m_height * mat_cur.channels();
@@ -437,7 +436,7 @@ bool PngDecoder::readData( Mat& img )
if (dop == 2)
```
|
like 
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.