Skip to content

VideoCapture test to ensure that cv::VideoCapture does not share output buffers#19364

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
asmorkalov:as/capture_buffer_safety_test
Jan 22, 2021
Merged

VideoCapture test to ensure that cv::VideoCapture does not share output buffers#19364
opencv-pushbot merged 1 commit intoopencv:masterfrom
asmorkalov:as/capture_buffer_safety_test

Conversation

@asmorkalov
Copy link
Copy Markdown
Contributor

Related work: #18377

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

}

for(int i = 0; i < 10; i+=2)
frames[i].setTo(cv::Scalar(255,255,255));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a bad idea to require changing of such buffers.
They can be allocated as read-only (any write attempt will raise a failure).
For example, OpenCL read-only "map" from GPU decoder.


Suggestion:

  • remove this block
  • rename test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the test and removed Mat modification as you suggested, but it's not what OpenCV users expect. Documentation does not provide any cases with read-only Mat object and a lot of examples do camera Mat modification.

@asmorkalov asmorkalov force-pushed the as/capture_buffer_safety_test branch 2 times, most recently from 3619894 to 49cbc0c Compare January 21, 2021 13:13
@asmorkalov
Copy link
Copy Markdown
Contributor Author

@alalek It's ready.

hardCopies[i] = frames[i].clone();
}

for(int i = 1; i < 10; i++)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i = 0

Comment on lines +647 to +650
Mat diff;
absdiff(frames[i], hardCopies[i], diff);
auto outilers = countNonZero(diff.reshape(1));
EXPECT_EQ(outilers, 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One line check:

EXPECT_EQ(0, cv::norm(frames[i], hardCopies[i], NORM_INF)) << i;

@asmorkalov asmorkalov force-pushed the as/capture_buffer_safety_test branch 2 times, most recently from e075548 to b4e941d Compare January 22, 2021 13:42
@asmorkalov asmorkalov requested a review from alalek January 22, 2021 13:43
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

@opencv-pushbot opencv-pushbot merged commit 1a3a25f into opencv:master Jan 22, 2021
@alalek alalek mentioned this pull request Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants