OpenCV  4.1.1-pre
Open Source Computer Vision
Looking for a C++ dev who knows OpenCV?
I'm looking for work. Hire me!
cv::DISOpticalFlow Class Referenceabstract

DIS optical flow algorithm. More...

#include <opencv2/video/tracking.hpp>

Inheritance diagram for cv::DISOpticalFlow:
Collaboration diagram for cv::DISOpticalFlow:

Public Types

enum  {
  PRESET_ULTRAFAST = 0,
  PRESET_FAST = 1,
  PRESET_MEDIUM = 2
}
 

Public Member Functions

virtual void calc (InputArray I0, InputArray I1, InputOutputArray flow)=0
 Calculates an optical flow. More...
 
virtual void clear ()
 Clears the algorithm state. More...
 
virtual void collectGarbage ()=0
 Releases all inner buffers. More...
 
virtual bool empty () const
 Returns true if the Algorithm is empty (e.g. More...
 
virtual String getDefaultName () const
 Returns the algorithm string identifier. More...
 
virtual int getFinestScale () const =0
 Finest level of the Gaussian pyramid on which the flow is computed (zero level corresponds to the original image resolution). More...
 
virtual int getGradientDescentIterations () const =0
 Maximum number of gradient descent iterations in the patch inverse search stage. More...
 
virtual int getPatchSize () const =0
 Size of an image patch for matching (in pixels). More...
 
virtual int getPatchStride () const =0
 Stride between neighbor patches. More...
 
virtual bool getUseMeanNormalization () const =0
 Whether to use mean-normalization of patches when computing patch distance. More...
 
virtual bool getUseSpatialPropagation () const =0
 Whether to use spatial propagation of good optical flow vectors. More...
 
virtual float getVariationalRefinementAlpha () const =0
 Weight of the smoothness term. More...
 
virtual float getVariationalRefinementDelta () const =0
 Weight of the color constancy term. More...
 
virtual float getVariationalRefinementGamma () const =0
 Weight of the gradient constancy term. More...
 
virtual int getVariationalRefinementIterations () const =0
 Number of fixed point iterations of variational refinement per scale. More...
 
virtual void read (const FileNode &fn)
 Reads algorithm parameters from a file storage. More...
 
virtual void save (const String &filename) const
 Saves the algorithm to a file. More...
 
virtual void setFinestScale (int val)=0
 Finest level of the Gaussian pyramid on which the flow is computed (zero level corresponds to the original image resolution). More...
 
virtual void setGradientDescentIterations (int val)=0
 Maximum number of gradient descent iterations in the patch inverse search stage. More...
 
virtual void setPatchSize (int val)=0
 Size of an image patch for matching (in pixels). More...
 
virtual void setPatchStride (int val)=0
 Stride between neighbor patches. More...
 
virtual void setUseMeanNormalization (bool val)=0
 Whether to use mean-normalization of patches when computing patch distance. More...
 
virtual void setUseSpatialPropagation (bool val)=0
 Whether to use spatial propagation of good optical flow vectors. More...
 
virtual void setVariationalRefinementAlpha (float val)=0
 Weight of the smoothness term. More...
 
virtual void setVariationalRefinementDelta (float val)=0
 Weight of the color constancy term. More...
 
virtual void setVariationalRefinementGamma (float val)=0
 Weight of the gradient constancy term. More...
 
virtual void setVariationalRefinementIterations (int val)=0
 Maximum number of gradient descent iterations in the patch inverse search stage. More...
 
virtual void write (FileStorage &fs) const
 Stores algorithm parameters in a file storage. More...
 
void write (const Ptr< FileStorage > &fs, const String &name=String()) const
 simplified API for language bindings This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 

Static Public Member Functions

static Ptr< DISOpticalFlowcreate (int preset=DISOpticalFlow::PRESET_FAST)
 Creates an instance of DISOpticalFlow. More...
 
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...
 

Protected Member Functions

void writeFormat (FileStorage &fs) const
 

Detailed Description

DIS optical flow algorithm.

This class implements the Dense Inverse Search (DIS) optical flow algorithm. More details about the algorithm can be found at [50] . Includes three presets with preselected parameters to provide reasonable trade-off between speed and quality. However, even the slowest preset is still relatively fast, use DeepFlow if you need better quality and don't care about speed.

This implementation includes several additional features compared to the algorithm described in the paper, including spatial propagation of flow vectors (getUseSpatialPropagation), as well as an option to utilize an initial flow approximation passed to calc (which is, essentially, temporal propagation, if the previous frame's flow field is passed).

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
PRESET_ULTRAFAST 
PRESET_FAST 
PRESET_MEDIUM 

Member Function Documentation

◆ calc()

virtual void cv::DenseOpticalFlow::calc ( InputArray  I0,
InputArray  I1,
InputOutputArray  flow 
)
pure virtualinherited

Calculates an optical flow.

Parameters
I0first 8-bit single-channel input image.
I1second input image of the same size and the same type as prev.
flowcomputed flow image that has the same size as prev and type CV_32FC2.

◆ clear()

virtual void cv::Algorithm::clear ( )
inlinevirtualinherited

Clears the algorithm state.

Reimplemented in cv::FlannBasedMatcher, and cv::DescriptorMatcher.

◆ collectGarbage()

virtual void cv::DenseOpticalFlow::collectGarbage ( )
pure virtualinherited

Releases all inner buffers.

◆ create()

static Ptr<DISOpticalFlow> cv::DISOpticalFlow::create ( int  preset = DISOpticalFlow::PRESET_FAST)
static

Creates an instance of DISOpticalFlow.

Parameters
presetone of PRESET_ULTRAFAST, PRESET_FAST and PRESET_MEDIUM

◆ empty()

virtual bool cv::Algorithm::empty ( ) const
inlinevirtualinherited

Returns true if the Algorithm is empty (e.g.

in the very beginning or after unsuccessful read

Reimplemented in cv::DescriptorMatcher, cv::ml::StatModel, cv::Feature2D, and cv::BaseCascadeClassifier.

◆ getDefaultName()

virtual String cv::Algorithm::getDefaultName ( ) const
virtualinherited

Returns the algorithm string identifier.

This string is used as top level xml/yml node tag when the object is saved to a file or string.

Reimplemented in cv::AKAZE, cv::KAZE, cv::SimpleBlobDetector, cv::GFTTDetector, cv::AgastFeatureDetector, cv::FastFeatureDetector, cv::MSER, cv::ORB, cv::BRISK, and cv::Feature2D.

◆ getFinestScale()

virtual int cv::DISOpticalFlow::getFinestScale ( ) const
pure virtual

Finest level of the Gaussian pyramid on which the flow is computed (zero level corresponds to the original image resolution).

The final flow is obtained by bilinear upscaling.

See also
setFinestScale

◆ getGradientDescentIterations()

virtual int cv::DISOpticalFlow::getGradientDescentIterations ( ) const
pure virtual

Maximum number of gradient descent iterations in the patch inverse search stage.

Higher values may improve quality in some cases.

See also
setGradientDescentIterations

◆ getPatchSize()

virtual int cv::DISOpticalFlow::getPatchSize ( ) const
pure virtual

Size of an image patch for matching (in pixels).

Normally, default 8x8 patches work well enough in most cases.

See also
setPatchSize

◆ getPatchStride()

virtual int cv::DISOpticalFlow::getPatchStride ( ) const
pure virtual

Stride between neighbor patches.

Must be less than patch size. Lower values correspond to higher flow quality.

See also
setPatchStride

◆ getUseMeanNormalization()

virtual bool cv::DISOpticalFlow::getUseMeanNormalization ( ) const
pure virtual

Whether to use mean-normalization of patches when computing patch distance.

It is turned on by default as it typically provides a noticeable quality boost because of increased robustness to illumination variations. Turn it off if you are certain that your sequence doesn't contain any changes in illumination.

See also
setUseMeanNormalization

◆ getUseSpatialPropagation()

virtual bool cv::DISOpticalFlow::getUseSpatialPropagation ( ) const
pure virtual

Whether to use spatial propagation of good optical flow vectors.

This option is turned on by default, as it tends to work better on average and can sometimes help recover from major errors introduced by the coarse-to-fine scheme employed by the DIS optical flow algorithm. Turning this option off can make the output flow field a bit smoother, however.

See also
setUseSpatialPropagation

◆ getVariationalRefinementAlpha()

virtual float cv::DISOpticalFlow::getVariationalRefinementAlpha ( ) const
pure virtual

Weight of the smoothness term.

See also
setVariationalRefinementAlpha

◆ getVariationalRefinementDelta()

virtual float cv::DISOpticalFlow::getVariationalRefinementDelta ( ) const
pure virtual

Weight of the color constancy term.

See also
setVariationalRefinementDelta

◆ getVariationalRefinementGamma()

virtual float cv::DISOpticalFlow::getVariationalRefinementGamma ( ) const
pure virtual

Weight of the gradient constancy term.

See also
setVariationalRefinementGamma

◆ getVariationalRefinementIterations()

virtual int cv::DISOpticalFlow::getVariationalRefinementIterations ( ) const
pure virtual

Number of fixed point iterations of variational refinement per scale.

Set to zero to disable variational refinement completely. Higher values will typically result in more smooth and high-quality flow.

See also
setGradientDescentIterations

◆ load()

template<typename _Tp >
static Ptr<_Tp> cv::Algorithm::load ( const String filename,
const String objname = String() 
)
inlinestaticinherited

Loads algorithm from the file.

Parameters
filenameName of the file to read.
objnameThe optional name of the node to read (if empty, the first top-level node will be used)

This is static template method of Algorithm. It's usage is following (in the case of SVM):

Ptr<SVM> svm = Algorithm::load<SVM>("my_svm_model.xml");

In order to make this method work, the derived class must overwrite Algorithm::read(const FileNode& fn).

References CV_Assert, cv::FileNode::empty(), cv::FileStorage::getFirstTopLevelNode(), cv::FileStorage::isOpened(), and cv::FileStorage::READ.

Here is the call graph for this function:

◆ loadFromString()

template<typename _Tp >
static Ptr<_Tp> cv::Algorithm::loadFromString ( const String strModel,
const String objname = String() 
)
inlinestaticinherited

Loads algorithm from a String.

Parameters
strModelThe string variable containing the model you want to load.
objnameThe optional name of the node to read (if empty, the first top-level node will be used)

This is static template method of Algorithm. It's usage is following (in the case of SVM):

Ptr<SVM> svm = Algorithm::loadFromString<SVM>(myStringModel);

References CV_WRAP, cv::FileNode::empty(), cv::FileStorage::getFirstTopLevelNode(), cv::FileStorage::MEMORY, and cv::FileStorage::READ.

Here is the call graph for this function:

◆ read() [1/2]

virtual void cv::Algorithm::read ( const FileNode fn)
inlinevirtualinherited

Reads algorithm parameters from a file storage.

Reimplemented in cv::FlannBasedMatcher, cv::DescriptorMatcher, and cv::Feature2D.

◆ read() [2/2]

template<typename _Tp >
static Ptr<_Tp> cv::Algorithm::read ( const FileNode fn)
inlinestaticinherited

Reads algorithm from the file node.

This is static template method of Algorithm. It's usage is following (in the case of SVM):

cv::FileStorage fsRead("example.xml", FileStorage::READ);
Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());

In order to make this method work, the derived class must overwrite Algorithm::read(const FileNode& fn) and also have static create() method without parameters (or with all the optional parameters)

◆ save()

virtual void cv::Algorithm::save ( const String filename) const
virtualinherited

Saves the algorithm to a file.

In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).

◆ setFinestScale()

virtual void cv::DISOpticalFlow::setFinestScale ( int  val)
pure virtual

Finest level of the Gaussian pyramid on which the flow is computed (zero level corresponds to the original image resolution).

See also
getFinestScale

◆ setGradientDescentIterations()

virtual void cv::DISOpticalFlow::setGradientDescentIterations ( int  val)
pure virtual

Maximum number of gradient descent iterations in the patch inverse search stage.

See also
getGradientDescentIterations

◆ setPatchSize()

virtual void cv::DISOpticalFlow::setPatchSize ( int  val)
pure virtual

Size of an image patch for matching (in pixels).

See also
getPatchSize

◆ setPatchStride()

virtual void cv::DISOpticalFlow::setPatchStride ( int  val)
pure virtual

Stride between neighbor patches.

See also
getPatchStride

◆ setUseMeanNormalization()

virtual void cv::DISOpticalFlow::setUseMeanNormalization ( bool  val)
pure virtual

Whether to use mean-normalization of patches when computing patch distance.

See also
getUseMeanNormalization

◆ setUseSpatialPropagation()

virtual void cv::DISOpticalFlow::setUseSpatialPropagation ( bool  val)
pure virtual

Whether to use spatial propagation of good optical flow vectors.

See also
getUseSpatialPropagation

◆ setVariationalRefinementAlpha()

virtual void cv::DISOpticalFlow::setVariationalRefinementAlpha ( float  val)
pure virtual

Weight of the smoothness term.

See also
getVariationalRefinementAlpha

◆ setVariationalRefinementDelta()

virtual void cv::DISOpticalFlow::setVariationalRefinementDelta ( float  val)
pure virtual

Weight of the color constancy term.

See also
getVariationalRefinementDelta

◆ setVariationalRefinementGamma()

virtual void cv::DISOpticalFlow::setVariationalRefinementGamma ( float  val)
pure virtual

Weight of the gradient constancy term.

See also
getVariationalRefinementGamma

◆ setVariationalRefinementIterations()

virtual void cv::DISOpticalFlow::setVariationalRefinementIterations ( int  val)
pure virtual

Maximum number of gradient descent iterations in the patch inverse search stage.

See also
getGradientDescentIterations

◆ write() [1/2]

virtual void cv::Algorithm::write ( FileStorage fs) const
inlinevirtualinherited

Stores algorithm parameters in a file storage.

Reimplemented in cv::FlannBasedMatcher, cv::DescriptorMatcher, and cv::Feature2D.

References CV_WRAP.

Referenced by cv::Feature2D::write(), and cv::DescriptorMatcher::write().

Here is the caller graph for this function:

◆ write() [2/2]

void cv::Algorithm::write ( const Ptr< FileStorage > &  fs,
const String name = String() 
) const
inherited

simplified API for language bindings This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ writeFormat()

void cv::Algorithm::writeFormat ( FileStorage fs) const
protectedinherited

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