Skip to content

Conversation

@cudawarped
Copy link
Contributor

@cudawarped cudawarped commented Mar 16, 2022

As mentioned in #3195 the frames returned from cudacodec::VideoReader::nextFrame/retrieve are always BGRA with a zero alpha channel. Regardless of the reason for this (likely memory optimization for previous generation gpu's and/or current OpenCV CUDA functions), GPU memory is at a premium and it seems like a reasonable idea to allow this to be changed to BGR and Gray if desired by the user.

It may impact performance of some CUDA routines if a BGR frame is used instead of BGRA but that would be up to the user to experiment with.

The default is left as BGRA for compatibility and the test has been updated.

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 another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the 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
force_builders=Custom
buildworker:Custom=linux-4,linux-6
build_image:Custom=ubuntu-cuda:18.04

…e produced by cudacodec::VideoReader.

Updated accompanying test.
/build/precommit-contrib_custom_linux64/4.x/opencv_contrib/modules/cudacodec/src/cuda/nv12_to_rgb.cu:187:6: warning: no previous declaration for 'void nv12ToBgra(const cv::cuda::GpuMat&, cv::cuda::GpuMat&, int, int, cudaStream_t)' [-Wmissing-declarations]
Copy link
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 👍

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.

2 participants