Trait CUDA_VideoReaderTrait

Source
pub trait CUDA_VideoReaderTrait: CUDA_VideoReaderTraitConst {
    // Required method
    fn as_raw_mut_CUDA_VideoReader(&mut self) -> *mut c_void;

    // Provided methods
    fn next_frame(
        &mut self,
        frame: &mut impl GpuMatTrait,
        stream: &mut impl StreamTrait,
    ) -> Result<bool> { ... }
    fn next_frame_def(&mut self, frame: &mut impl GpuMatTrait) -> Result<bool> { ... }
    fn next_frame_with_hist(
        &mut self,
        frame: &mut impl GpuMatTrait,
        histogram: &mut impl GpuMatTrait,
        stream: &mut impl StreamTrait,
    ) -> Result<bool> { ... }
    fn next_frame_with_hist_def(
        &mut self,
        frame: &mut impl GpuMatTrait,
        histogram: &mut impl GpuMatTrait,
    ) -> Result<bool> { ... }
    fn grab(&mut self, stream: &mut impl StreamTrait) -> Result<bool> { ... }
    fn grab_def(&mut self) -> Result<bool> { ... }
    fn set(
        &mut self,
        property_id: CUDA_VideoReaderProps,
        property_val: f64,
    ) -> Result<bool> { ... }
    fn set_video_reader_props(
        &mut self,
        property_id: CUDA_VideoReaderProps,
        property_val: f64,
    ) -> Result<bool> { ... }
    fn set_1(
        &mut self,
        color_format: CUDA_ColorFormat,
        bit_depth: CUDA_BitDepth,
        planar: bool,
    ) -> Result<bool> { ... }
    fn set_def(&mut self, color_format: CUDA_ColorFormat) -> Result<bool> { ... }
}
Expand description

Required Methods§

Provided Methods§

Source

fn next_frame( &mut self, frame: &mut impl GpuMatTrait, stream: &mut impl StreamTrait, ) -> Result<bool>

Grabs, decodes and returns the next video frame.

§Parameters
  • frame:[out] The video frame.
  • stream: Stream for the asynchronous version.
§Returns

false if no frames have been grabbed.

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.

§C++ default parameters
  • stream: cuda::Stream::Null()
Source

fn next_frame_def(&mut self, frame: &mut impl GpuMatTrait) -> Result<bool>

Grabs, decodes and returns the next video frame.

§Parameters
  • frame:[out] The video frame.
  • stream: Stream for the asynchronous version.
§Returns

false if no frames have been grabbed.

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

This alternative version of CUDA_VideoReaderTrait::next_frame function uses the following default values for its arguments:

  • stream: cuda::Stream::Null()
Source

fn next_frame_with_hist( &mut self, frame: &mut impl GpuMatTrait, histogram: &mut impl GpuMatTrait, stream: &mut impl StreamTrait, ) -> Result<bool>

Grabs, decodes and returns the next video frame and frame luma histogram.

§Parameters
  • frame:[out] The video frame.
  • histogram:[out] 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.

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.

§C++ default parameters
  • stream: cuda::Stream::Null()
Source

fn next_frame_with_hist_def( &mut self, frame: &mut impl GpuMatTrait, histogram: &mut impl GpuMatTrait, ) -> Result<bool>

Grabs, decodes and returns the next video frame and frame luma histogram.

§Parameters
  • frame:[out] The video frame.
  • histogram:[out] 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.

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.

§Note

This alternative version of CUDA_VideoReaderTrait::next_frame_with_hist function uses the following default values for its arguments:

  • stream: cuda::Stream::Null()
Source

fn grab(&mut self, stream: &mut impl StreamTrait) -> Result<bool>

Grabs the next frame from the video source.

§Parameters
  • stream: Stream for the asynchronous version.
§Returns

true (non-zero) in the case of success.

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.

§C++ default parameters
  • stream: cuda::Stream::Null()
Source

fn grab_def(&mut self) -> Result<bool>

Grabs the next frame from the video source.

§Parameters
  • stream: Stream for the asynchronous version.
§Returns

true (non-zero) in the case of success.

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.

§Note

This alternative version of CUDA_VideoReaderTrait::grab function uses the following default values for its arguments:

  • stream: cuda::Stream::Null()
Source

fn set( &mut self, property_id: CUDA_VideoReaderProps, property_val: f64, ) -> Result<bool>

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.

Source

fn set_video_reader_props( &mut self, property_id: CUDA_VideoReaderProps, property_val: f64, ) -> Result<bool>

Source

fn set_1( &mut self, color_format: CUDA_ColorFormat, bit_depth: CUDA_BitDepth, planar: bool, ) -> Result<bool>

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.

§C++ default parameters
  • bit_depth: BitDepth::UNCHANGED
  • planar: false
Source

fn set_def(&mut self, color_format: CUDA_ColorFormat) -> Result<bool>

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.

§Note

This alternative version of CUDA_VideoReaderTrait::set function uses the following default values for its arguments:

  • bit_depth: BitDepth::UNCHANGED
  • planar: false

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§