OpenCV  4.7.0
Open Source Computer Vision
Public Types | Public Member Functions | Static Public Member Functions | List of all members
cv::cuda::NvidiaOpticalFlow_2_0 Class Referenceabstract

Class for computing the optical flow vectors between two images using NVIDIA Optical Flow hardware and Optical Flow SDK 2.0. More...

#include <opencv2/cudaoptflow.hpp>

Inheritance diagram for cv::cuda::NvidiaOpticalFlow_2_0:
cv::cuda::NvidiaHWOpticalFlow cv::Algorithm

Public Types

enum  NVIDIA_OF_HINT_VECTOR_GRID_SIZE {
  NV_OF_HINT_VECTOR_GRID_SIZE_UNDEFINED,
  NV_OF_HINT_VECTOR_GRID_SIZE_1 = 1,
  NV_OF_HINT_VECTOR_GRID_SIZE_2 = 2,
  NV_OF_HINT_VECTOR_GRID_SIZE_4 = 4,
  NV_OF_HINT_VECTOR_GRID_SIZE_8 = 8,
  NV_OF_HINT_VECTOR_GRID_SIZE_MAX
}
 
enum  NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE {
  NV_OF_OUTPUT_VECTOR_GRID_SIZE_UNDEFINED,
  NV_OF_OUTPUT_VECTOR_GRID_SIZE_1 = 1,
  NV_OF_OUTPUT_VECTOR_GRID_SIZE_2 = 2,
  NV_OF_OUTPUT_VECTOR_GRID_SIZE_4 = 4,
  NV_OF_OUTPUT_VECTOR_GRID_SIZE_MAX
}
 
enum  NVIDIA_OF_PERF_LEVEL {
  NV_OF_PERF_LEVEL_UNDEFINED,
  NV_OF_PERF_LEVEL_SLOW = 5,
  NV_OF_PERF_LEVEL_MEDIUM = 10,
  NV_OF_PERF_LEVEL_FAST = 20,
  NV_OF_PERF_LEVEL_MAX
}
 

Public Member Functions

virtual void convertToFloat (InputArray flow, InputOutputArray floatFlow)=0
 convertToFloat() helper function converts the hardware-generated flow vectors to floating point representation (1 flow vector for gridSize). gridSize can be queried via function getGridSize(). More...
 
- Public Member Functions inherited from cv::cuda::NvidiaHWOpticalFlow
virtual void calc (InputArray inputImage, InputArray referenceImage, InputOutputArray flow, Stream &stream=Stream::Null(), InputArray hint=cv::noArray(), OutputArray cost=cv::noArray())=0
 Calculates Optical Flow using NVIDIA Optical Flow SDK. More...
 
virtual void collectGarbage ()=0
 Releases all buffers, contexts and device pointers. More...
 
virtual int getGridSize () const =0
 Returns grid size of output buffer as per the hardware's capability. More...
 
- Public Member Functions inherited from cv::Algorithm
 Algorithm ()
 
virtual ~Algorithm ()
 
virtual void clear ()
 Clears the algorithm state. More...
 
virtual bool empty () const
 Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read. More...
 
virtual String getDefaultName () const
 
virtual void read (const FileNode &fn)
 Reads algorithm parameters from a file storage. More...
 
virtual void save (const String &filename) const
 
virtual void write (FileStorage &fs) const
 Stores algorithm parameters in a file storage. More...
 
void write (FileStorage &fs, const String &name) const
 
void write (const Ptr< FileStorage > &fs, const String &name=String()) const
 

Static Public Member Functions

static Ptr< NvidiaOpticalFlow_2_0create (cv::Size imageSize, cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_PERF_LEVEL perfPreset=cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_PERF_LEVEL_SLOW, cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE outputGridSize=cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_OUTPUT_VECTOR_GRID_SIZE_1, cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_HINT_VECTOR_GRID_SIZE hintGridSize=cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_HINT_VECTOR_GRID_SIZE_1, bool enableTemporalHints=false, bool enableExternalHints=false, bool enableCostBuffer=false, int gpuId=0, Stream &inputStream=Stream::Null(), Stream &outputStream=Stream::Null())
 Instantiate NVIDIA Optical Flow. More...
 
static Ptr< NvidiaOpticalFlow_2_0create (cv::Size imageSize, std::vector< Rect > roiData, cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_PERF_LEVEL perfPreset=cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_PERF_LEVEL_SLOW, cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE outputGridSize=cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_OUTPUT_VECTOR_GRID_SIZE_1, cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_HINT_VECTOR_GRID_SIZE hintGridSize=cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_HINT_VECTOR_GRID_SIZE_1, bool enableTemporalHints=false, bool enableExternalHints=false, bool enableCostBuffer=false, int gpuId=0, Stream &inputStream=Stream::Null(), Stream &outputStream=Stream::Null())
 Instantiate NVIDIA Optical Flow with ROI Feature. More...
 
- Static Public Member Functions inherited from cv::Algorithm
template<typename _Tp >
static Ptr< _Tp > load (const String &filename, const String &objname=String())
 Loads algorithm from the file. More...
 
template<typename _Tp >
static Ptr< _Tp > loadFromString (const String &strModel, const String &objname=String())
 Loads algorithm from a String. More...
 
template<typename _Tp >
static Ptr< _Tp > read (const FileNode &fn)
 Reads algorithm from the file node. More...
 

Additional Inherited Members

- Protected Member Functions inherited from cv::Algorithm
void writeFormat (FileStorage &fs) const
 

Detailed Description

Class for computing the optical flow vectors between two images using NVIDIA Optical Flow hardware and Optical Flow SDK 2.0.

Note
  • A sample application demonstrating the use of NVIDIA Optical Flow can be found at opencv_contrib_source_code/modules/cudaoptflow/samples/nvidia_optical_flow.cpp
  • An example application comparing accuracy and performance of NVIDIA Optical Flow with other optical flow algorithms in OpenCV can be found at opencv_contrib_source_code/modules/cudaoptflow/samples/optical_flow.cpp

Member Enumeration Documentation

◆ NVIDIA_OF_HINT_VECTOR_GRID_SIZE

Supported grid size for hint buffer.

Enumerator
NV_OF_HINT_VECTOR_GRID_SIZE_UNDEFINED 
NV_OF_HINT_VECTOR_GRID_SIZE_1 

Hint buffer grid size is 1x1.

NV_OF_HINT_VECTOR_GRID_SIZE_2 

Hint buffer grid size is 2x2.

NV_OF_HINT_VECTOR_GRID_SIZE_4 

Hint buffer grid size is 4x4.

NV_OF_HINT_VECTOR_GRID_SIZE_8 

Hint buffer grid size is 8x8.

NV_OF_HINT_VECTOR_GRID_SIZE_MAX 

◆ NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE

Supported grid size for output buffer.

Enumerator
NV_OF_OUTPUT_VECTOR_GRID_SIZE_UNDEFINED 
NV_OF_OUTPUT_VECTOR_GRID_SIZE_1 

Output buffer grid size is 1x1

NV_OF_OUTPUT_VECTOR_GRID_SIZE_2 

Output buffer grid size is 2x2

NV_OF_OUTPUT_VECTOR_GRID_SIZE_4 

Output buffer grid size is 4x4

NV_OF_OUTPUT_VECTOR_GRID_SIZE_MAX 

◆ NVIDIA_OF_PERF_LEVEL

Supported optical flow performance levels.

Enumerator
NV_OF_PERF_LEVEL_UNDEFINED 
NV_OF_PERF_LEVEL_SLOW 

Slow perf level results in lowest performance and best quality

NV_OF_PERF_LEVEL_MEDIUM 

Medium perf level results in low performance and medium quality

NV_OF_PERF_LEVEL_FAST 

Fast perf level results in high performance and low quality

NV_OF_PERF_LEVEL_MAX 

Member Function Documentation

◆ convertToFloat()

virtual void cv::cuda::NvidiaOpticalFlow_2_0::convertToFloat ( InputArray  flow,
InputOutputArray  floatFlow 
)
pure virtual

convertToFloat() helper function converts the hardware-generated flow vectors to floating point representation (1 flow vector for gridSize). gridSize can be queried via function getGridSize().

Parameters
flowBuffer of type CV_16FC2 containing flow vectors generated by calc().
floatFlowBuffer of type CV_32FC2, containing flow vectors in floating point representation, each flow vector for 1 pixel per gridSize, in the pitch-linear layout.

◆ create() [1/2]

static Ptr<NvidiaOpticalFlow_2_0> cv::cuda::NvidiaOpticalFlow_2_0::create ( cv::Size  imageSize,
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_PERF_LEVEL  perfPreset = cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_PERF_LEVEL_SLOW,
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE  outputGridSize = cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_OUTPUT_VECTOR_GRID_SIZE_1,
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_HINT_VECTOR_GRID_SIZE  hintGridSize = cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_HINT_VECTOR_GRID_SIZE_1,
bool  enableTemporalHints = false,
bool  enableExternalHints = false,
bool  enableCostBuffer = false,
int  gpuId = 0,
Stream inputStream = Stream::Null(),
Stream outputStream = Stream::Null() 
)
static

Instantiate NVIDIA Optical Flow.

Parameters
imageSizeSize of input image in pixels.
perfPresetOptional parameter. Refer NV OF SDK documentation for details about presets. Defaults to NV_OF_PERF_LEVEL_SLOW.
outputGridSizeOptional parameter. Refer NV OF SDK documentation for details about output grid sizes. Defaults to NV_OF_OUTPUT_VECTOR_GRID_SIZE_1.
hintGridSizeOptional parameter. Refer NV OF SDK documentation for details about hint grid sizes. Defaults to NV_OF_HINT_VECTOR_GRID_SIZE_1.
enableTemporalHintsOptional parameter. Flag to enable temporal hints. When set to true, the hardware uses the flow vectors generated in previous call to calc() as internal hints for the current call to calc(). Useful when computing flow vectors between successive video frames. Defaults to false.
enableExternalHintsOptional Parameter. Flag to enable passing external hints buffer to calc(). Defaults to false.
enableCostBufferOptional Parameter. Flag to enable cost buffer output from calc(). Defaults to false.
gpuIdOptional parameter to select the GPU ID on which the optical flow should be computed. Useful in multi-GPU systems. Defaults to 0.
inputStreamOptical flow algorithm may optionally involve cuda preprocessing on the input buffers. The input cuda stream can be used to pipeline and synchronize the cuda preprocessing tasks with OF HW engine. If input stream is not set, the execute function will use default stream which is NULL stream;
outputStreamOptical flow algorithm may optionally involve cuda post processing on the output flow vectors. The output cuda stream can be used to pipeline and synchronize the cuda post processing tasks with OF HW engine. If output stream is not set, the execute function will use default stream which is NULL stream;

◆ create() [2/2]

static Ptr<NvidiaOpticalFlow_2_0> cv::cuda::NvidiaOpticalFlow_2_0::create ( cv::Size  imageSize,
std::vector< Rect roiData,
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_PERF_LEVEL  perfPreset = cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_PERF_LEVEL_SLOW,
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_OUTPUT_VECTOR_GRID_SIZE  outputGridSize = cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_OUTPUT_VECTOR_GRID_SIZE_1,
cv::cuda::NvidiaOpticalFlow_2_0::NVIDIA_OF_HINT_VECTOR_GRID_SIZE  hintGridSize = cv::cuda::NvidiaOpticalFlow_2_0::NV_OF_HINT_VECTOR_GRID_SIZE_1,
bool  enableTemporalHints = false,
bool  enableExternalHints = false,
bool  enableCostBuffer = false,
int  gpuId = 0,
Stream inputStream = Stream::Null(),
Stream outputStream = Stream::Null() 
)
static

Instantiate NVIDIA Optical Flow with ROI Feature.

Parameters
imageSizeSize of input image in pixels.
roiDataPointer to ROI data.
perfPresetOptional parameter. Refer NV OF SDK documentation for details about presets. Defaults to NV_OF_PERF_LEVEL_SLOW.
outputGridSizeOptional parameter. Refer NV OF SDK documentation for details about output grid sizes. Defaults to NV_OF_OUTPUT_VECTOR_GRID_SIZE_1.
hintGridSizeOptional parameter. Refer NV OF SDK documentation for details about hint grid sizes. Defaults to NV_OF_HINT_VECTOR_GRID_SIZE_1.
enableTemporalHintsOptional parameter. Flag to enable temporal hints. When set to true, the hardware uses the flow vectors generated in previous call to calc() as internal hints for the current call to calc(). Useful when computing flow vectors between successive video frames. Defaults to false.
enableExternalHintsOptional Parameter. Flag to enable passing external hints buffer to calc(). Defaults to false.
enableCostBufferOptional Parameter. Flag to enable cost buffer output from calc(). Defaults to false.
gpuIdOptional parameter to select the GPU ID on which the optical flow should be computed. Useful in multi-GPU systems. Defaults to 0.
inputStreamOptical flow algorithm may optionally involve cuda preprocessing on the input buffers. The input cuda stream can be used to pipeline and synchronize the cuda preprocessing tasks with OF HW engine. If input stream is not set, the execute function will use default stream which is NULL stream;
outputStreamOptical flow algorithm may optionally involve cuda post processing on the output flow vectors. The output cuda stream can be used to pipeline and synchronize the cuda post processing tasks with OF HW engine. If output stream is not set, the execute function will use default stream which is NULL stream;

The documentation for this class was generated from the following file: