Class cv::cudacodec::VideoReader#
Video reader interface, see createVideoReader(). View details
#include <opencv2/cudacodec.hpp>Collaboration diagram for cv::cudacodec::VideoReader:
Detailed Description#
Video reader interface, see createVideoReader().
Available if Nvidia’s Video Codec SDK is installed.
Decoding support is dependent on the GPU, refer to the Nvidia Video Codec SDK Video Encode and Decode GPU Support Matrix for details.
Note
An example on how to use the VideoReader interface can be found at opencv_source_code/samples/gpu/video_reader.cpp
Constructor & Destructor Documentation#
~VideoReader()#
cv::cudacodec::VideoReader::~VideoReader()
Member Function Documentation#
format()#
FormatInfo cv::cudacodec::VideoReader::format()
Returns information about video file format.
get()#
bool cv::cudacodec::VideoReader::get(
const int propertyId,
double & propertyVal )
Retrieves the specified property used by the VideoSource.
Parameters
propertyId— Property identifier from cv::VideoCaptureProperties (eg. cv::CAP_PROP_POS_MSEC, cv::CAP_PROP_POS_FRAMES, …) or one from Additional flags for video I/O API backends.propertyVal— Value for the specified property.
Returns
true unless the property is unset set or not supported.
get()#
bool cv::cudacodec::VideoReader::get(
const VideoReaderProps propertyId,
double & propertyVal )
Returns the specified VideoReader property.
Parameters
propertyId— Property identifier from cv::cudacodec::VideoReaderProps (eg. cv::cudacodec::VideoReaderProps::PROP_DECODED_FRAME_IDX, cv::cudacodec::VideoReaderProps::PROP_EXTRA_DATA_INDEX, …).propertyVal— - In: Optional value required for querying specific propertyId’s, e.g. the index of the raw package to be checked for a key frame (cv::cudacodec::VideoReaderProps::PROP_LRF_HAS_KEY_FRAME).Out: Value of the property.
Returns
true unless the property is not supported.
getVideoReaderProps()#
bool cv::cudacodec::VideoReader::getVideoReaderProps(
const VideoReaderProps propertyId,
double & propertyValOut,
double propertyValIn = 0 )
grab()#
bool cv::cudacodec::VideoReader::grab(cuda::Stream & stream = cuda::Stream::Null())
Grabs the next frame from the video source.
The method/function grabs the next frame from video file or camera and returns true (non-zero) in the case of success.
The primary use of the function is for reading both the encoded and decoded video data when rawMode is enabled. With rawMode enabled retrieve() can be called following grab() to retrieve all the data associated with the current video source since the last call to grab() or the creation of the VideoReader.
Parameters
stream— Stream for the asynchronous version.
Returns
true (non-zero) in the case of success.
nextFrame()#
bool cv::cudacodec::VideoReader::nextFrame(
cuda::GpuMat & frame,
cuda::GpuMat & histogram,
cuda::Stream & stream = cuda::Stream::Null() )
Grabs, decodes and returns the next video frame and frame luma histogram.
If no frames have been grabbed (there are no more frames in video file), the methods return false. The method throws an Exception if error occurs.
Note
Histogram data is collected by NVDEC during the decoding process resulting in zero performance penalty. NVDEC computes the histogram data for only the luma component of decoded output, not on post-processed frame(i.e. when scaling, cropping, etc. applied). If the source is encoded using a limited range of luma values (FormatInfo::videoFullRangeFlag == false) then the histogram bin values will correspond to to this limited range of values and will need to be mapped to contain the same output as cuda::calcHist(). The MapHist() utility function can be used to perform this mapping on the host if required.
Parameters
frame— The video frame.histogram— Histogram of the luma component of the encoded frame, see note.stream— Stream for the asynchronous version.
Returns
false if no frames have been grabbed.
nextFrame()#
bool cv::cudacodec::VideoReader::nextFrame(
cuda::GpuMat & frame,
cuda::Stream & stream = cuda::Stream::Null() )
Grabs, decodes and returns the next video frame.
If no frames have been grabbed (there are no more frames in video file), the methods return false. The method throws an Exception if error occurs.
Parameters
frame— The video frame.stream— Stream for the asynchronous version.
Returns
false if no frames have been grabbed.
retrieve()#
bool cv::cudacodec::VideoReader::retrieve(cuda::GpuMat & frame)
Returns the next video frame.
The method returns data associated with the current video source since the last call to grab(). If no data is present the method returns false and the function returns an empty image.
Parameters
frame— The video frame. If grab() has not been called then this will be empty().
Returns
false if no frames have been grabbed
retrieve()#
bool cv::cudacodec::VideoReader::retrieve(
Mat & frame,
const size_t idx )
Returns previously grabbed encoded video data.
The method returns data associated with the current video source since the last call to grab() or the creation of the VideoReader. If no data is present the method returns false and the function returns an empty image.
Parameters
frame— The encoded video data.idx— Determines the returned data inside image. The returned data can be the:Extra data if available, idx = get(PROP_EXTRA_DATA_INDEX).
Raw encoded data package. To retrieve package i, idx = get(PROP_RAW_PACKAGES_BASE_INDEX) + i with i < get(PROP_NUMBER_OF_RAW_PACKAGES_SINCE_LAST_GRAB)
Returns
false if no frames have been grabbed
retrieve()#
bool cv::cudacodec::VideoReader::retrieve(
OutputArray frame,
const size_t idx = static_cast< size_t >(VideoReaderProps::PROP_DECODED_FRAME_IDX) )
Returns previously grabbed video data.
The method returns data associated with the current video source since the last call to grab() or the creation of the VideoReader. If no data is present the method returns false and the function returns an empty image.
Parameters
frame— The returned data which depends on the provided idx.idx— Determines the returned data inside image. The returned data can be the:Decoded frame, idx = get(PROP_DECODED_FRAME_IDX).
Extra data if available, idx = get(PROP_EXTRA_DATA_INDEX).
Raw encoded data package. To retrieve package i, idx = get(PROP_RAW_PACKAGES_BASE_INDEX) + i with i < get(PROP_NUMBER_OF_RAW_PACKAGES_SINCE_LAST_GRAB)
Returns
false if no frames have been grabbed
set()#
bool cv::cudacodec::VideoReader::set(
const ColorFormat colorFormat,
const BitDepth bitDepth = BitDepth::UNCHANGED,
const bool planar = false )
Set the desired ColorFormat for the frame returned by nextFrame()/retrieve().
Parameters
colorFormat— Value of the ColorFormat.bitDepth— Requested bit depth of the frame.planar— Set to true for planar and false for packed color format.
Returns
true unless the colorFormat is not supported.
set()#
bool cv::cudacodec::VideoReader::set(
const VideoReaderProps propertyId,
const double propertyVal )
Sets a property in the VideoReader.
Parameters
propertyId— Property identifier from cv::cudacodec::VideoReaderProps (eg. cv::cudacodec::VideoReaderProps::PROP_DECODED_FRAME_IDX, cv::cudacodec::VideoReaderProps::PROP_EXTRA_DATA_INDEX, …).propertyVal— Value of the property.
Returns
true if the property has been set.
setVideoReaderProps()#
bool cv::cudacodec::VideoReader::setVideoReaderProps(
const VideoReaderProps propertyId,
double propertyVal )
Source file#
The documentation for this class was generated from the following file:
opencv2/cudacodec.hpp