Extensive wrapping of CUDA functionalities for Python

This commit is contained in:
Hamdi Sahloul
2018-08-25 05:57:24 +09:00
parent d4ac4fcde1
commit 532eace7d6
16 changed files with 804 additions and 611 deletions
@@ -67,7 +67,7 @@ namespace cv { namespace cuda {
/** @brief Base interface for dense optical flow algorithms.
*/
class CV_EXPORTS DenseOpticalFlow : public Algorithm
class CV_EXPORTS_W DenseOpticalFlow : public Algorithm
{
public:
/** @brief Calculates a dense optical flow.
@@ -77,12 +77,12 @@ public:
@param flow computed flow image that has the same size as I0 and type CV_32FC2.
@param stream Stream for the asynchronous version.
*/
virtual void calc(InputArray I0, InputArray I1, InputOutputArray flow, Stream& stream = Stream::Null()) = 0;
CV_WRAP virtual void calc(InputArray I0, InputArray I1, InputOutputArray flow, Stream& stream = Stream::Null()) = 0;
};
/** @brief Base interface for sparse optical flow algorithms.
*/
class CV_EXPORTS SparseOpticalFlow : public Algorithm
class CV_EXPORTS_W SparseOpticalFlow : public Algorithm
{
public:
/** @brief Calculates a sparse optical flow.
@@ -96,7 +96,7 @@ public:
@param err Optional output vector that contains error response for each point (inverse confidence).
@param stream Stream for the asynchronous version.
*/
virtual void calc(InputArray prevImg, InputArray nextImg,
CV_WRAP virtual void calc(InputArray prevImg, InputArray nextImg,
InputArray prevPts, InputOutputArray nextPts,
OutputArray status,
OutputArray err = cv::noArray(),
@@ -109,31 +109,31 @@ public:
/** @brief Class computing the optical flow for two images using Brox et al Optical Flow algorithm (@cite Brox2004).
*/
class CV_EXPORTS BroxOpticalFlow : public DenseOpticalFlow
class CV_EXPORTS_W BroxOpticalFlow : public DenseOpticalFlow
{
public:
virtual double getFlowSmoothness() const = 0;
virtual void setFlowSmoothness(double alpha) = 0;
CV_WRAP virtual double getFlowSmoothness() const = 0;
CV_WRAP virtual void setFlowSmoothness(double alpha) = 0;
virtual double getGradientConstancyImportance() const = 0;
virtual void setGradientConstancyImportance(double gamma) = 0;
CV_WRAP virtual double getGradientConstancyImportance() const = 0;
CV_WRAP virtual void setGradientConstancyImportance(double gamma) = 0;
virtual double getPyramidScaleFactor() const = 0;
virtual void setPyramidScaleFactor(double scale_factor) = 0;
CV_WRAP virtual double getPyramidScaleFactor() const = 0;
CV_WRAP virtual void setPyramidScaleFactor(double scale_factor) = 0;
//! number of lagged non-linearity iterations (inner loop)
virtual int getInnerIterations() const = 0;
virtual void setInnerIterations(int inner_iterations) = 0;
CV_WRAP virtual int getInnerIterations() const = 0;
CV_WRAP virtual void setInnerIterations(int inner_iterations) = 0;
//! number of warping iterations (number of pyramid levels)
virtual int getOuterIterations() const = 0;
virtual void setOuterIterations(int outer_iterations) = 0;
CV_WRAP virtual int getOuterIterations() const = 0;
CV_WRAP virtual void setOuterIterations(int outer_iterations) = 0;
//! number of linear system solver iterations
virtual int getSolverIterations() const = 0;
virtual void setSolverIterations(int solver_iterations) = 0;
CV_WRAP virtual int getSolverIterations() const = 0;
CV_WRAP virtual void setSolverIterations(int solver_iterations) = 0;
static Ptr<BroxOpticalFlow> create(
CV_WRAP static Ptr<BroxOpticalFlow> create(
double alpha = 0.197,
double gamma = 50.0,
double scale_factor = 0.8,
@@ -157,22 +157,22 @@ iterative Lucas-Kanade method with pyramids.
- An example of the Lucas Kanade optical flow algorithm can be found at
opencv_source_code/samples/gpu/pyrlk_optical_flow.cpp
*/
class CV_EXPORTS SparsePyrLKOpticalFlow : public SparseOpticalFlow
class CV_EXPORTS_W SparsePyrLKOpticalFlow : public SparseOpticalFlow
{
public:
virtual Size getWinSize() const = 0;
virtual void setWinSize(Size winSize) = 0;
CV_WRAP virtual Size getWinSize() const = 0;
CV_WRAP virtual void setWinSize(Size winSize) = 0;
virtual int getMaxLevel() const = 0;
virtual void setMaxLevel(int maxLevel) = 0;
CV_WRAP virtual int getMaxLevel() const = 0;
CV_WRAP virtual void setMaxLevel(int maxLevel) = 0;
virtual int getNumIters() const = 0;
virtual void setNumIters(int iters) = 0;
CV_WRAP virtual int getNumIters() const = 0;
CV_WRAP virtual void setNumIters(int iters) = 0;
virtual bool getUseInitialFlow() const = 0;
virtual void setUseInitialFlow(bool useInitialFlow) = 0;
CV_WRAP virtual bool getUseInitialFlow() const = 0;
CV_WRAP virtual void setUseInitialFlow(bool useInitialFlow) = 0;
static Ptr<SparsePyrLKOpticalFlow> create(
CV_WRAP static Ptr<cuda::SparsePyrLKOpticalFlow> create(
Size winSize = Size(21, 21),
int maxLevel = 3,
int iters = 30,
@@ -184,22 +184,22 @@ public:
The class can calculate an optical flow for a dense optical flow using the
iterative Lucas-Kanade method with pyramids.
*/
class CV_EXPORTS DensePyrLKOpticalFlow : public DenseOpticalFlow
class CV_EXPORTS_W DensePyrLKOpticalFlow : public DenseOpticalFlow
{
public:
virtual Size getWinSize() const = 0;
virtual void setWinSize(Size winSize) = 0;
CV_WRAP virtual Size getWinSize() const = 0;
CV_WRAP virtual void setWinSize(Size winSize) = 0;
virtual int getMaxLevel() const = 0;
virtual void setMaxLevel(int maxLevel) = 0;
CV_WRAP virtual int getMaxLevel() const = 0;
CV_WRAP virtual void setMaxLevel(int maxLevel) = 0;
virtual int getNumIters() const = 0;
virtual void setNumIters(int iters) = 0;
CV_WRAP virtual int getNumIters() const = 0;
CV_WRAP virtual void setNumIters(int iters) = 0;
virtual bool getUseInitialFlow() const = 0;
virtual void setUseInitialFlow(bool useInitialFlow) = 0;
CV_WRAP virtual bool getUseInitialFlow() const = 0;
CV_WRAP virtual void setUseInitialFlow(bool useInitialFlow) = 0;
static Ptr<DensePyrLKOpticalFlow> create(
CV_WRAP static Ptr<DensePyrLKOpticalFlow> create(
Size winSize = Size(13, 13),
int maxLevel = 3,
int iters = 30,
@@ -212,34 +212,34 @@ public:
/** @brief Class computing a dense optical flow using the Gunnar Farneback's algorithm.
*/
class CV_EXPORTS FarnebackOpticalFlow : public DenseOpticalFlow
class CV_EXPORTS_W FarnebackOpticalFlow : public DenseOpticalFlow
{
public:
virtual int getNumLevels() const = 0;
virtual void setNumLevels(int numLevels) = 0;
CV_WRAP virtual int getNumLevels() const = 0;
CV_WRAP virtual void setNumLevels(int numLevels) = 0;
virtual double getPyrScale() const = 0;
virtual void setPyrScale(double pyrScale) = 0;
CV_WRAP virtual double getPyrScale() const = 0;
CV_WRAP virtual void setPyrScale(double pyrScale) = 0;
virtual bool getFastPyramids() const = 0;
virtual void setFastPyramids(bool fastPyramids) = 0;
CV_WRAP virtual bool getFastPyramids() const = 0;
CV_WRAP virtual void setFastPyramids(bool fastPyramids) = 0;
virtual int getWinSize() const = 0;
virtual void setWinSize(int winSize) = 0;
CV_WRAP virtual int getWinSize() const = 0;
CV_WRAP virtual void setWinSize(int winSize) = 0;
virtual int getNumIters() const = 0;
virtual void setNumIters(int numIters) = 0;
CV_WRAP virtual int getNumIters() const = 0;
CV_WRAP virtual void setNumIters(int numIters) = 0;
virtual int getPolyN() const = 0;
virtual void setPolyN(int polyN) = 0;
CV_WRAP virtual int getPolyN() const = 0;
CV_WRAP virtual void setPolyN(int polyN) = 0;
virtual double getPolySigma() const = 0;
virtual void setPolySigma(double polySigma) = 0;
CV_WRAP virtual double getPolySigma() const = 0;
CV_WRAP virtual void setPolySigma(double polySigma) = 0;
virtual int getFlags() const = 0;
virtual void setFlags(int flags) = 0;
CV_WRAP virtual int getFlags() const = 0;
CV_WRAP virtual void setFlags(int flags) = 0;
static Ptr<FarnebackOpticalFlow> create(
CV_WRAP static Ptr<cuda::FarnebackOpticalFlow> create(
int numLevels = 5,
double pyrScale = 0.5,
bool fastPyramids = false,
@@ -259,14 +259,14 @@ public:
* @sa C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow".
* @sa Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation".
*/
class CV_EXPORTS OpticalFlowDual_TVL1 : public DenseOpticalFlow
class CV_EXPORTS_W OpticalFlowDual_TVL1 : public DenseOpticalFlow
{
public:
/**
* Time step of the numerical scheme.
*/
virtual double getTau() const = 0;
virtual void setTau(double tau) = 0;
CV_WRAP virtual double getTau() const = 0;
CV_WRAP virtual void setTau(double tau) = 0;
/**
* Weight parameter for the data term, attachment parameter.
@@ -274,8 +274,8 @@ public:
* The smaller this parameter is, the smoother the solutions we obtain.
* It depends on the range of motions of the images, so its value should be adapted to each image sequence.
*/
virtual double getLambda() const = 0;
virtual void setLambda(double lambda) = 0;
CV_WRAP virtual double getLambda() const = 0;
CV_WRAP virtual void setLambda(double lambda) = 0;
/**
* Weight parameter for (u - v)^2, tightness parameter.
@@ -283,8 +283,8 @@ public:
* In theory, it should have a small value in order to maintain both parts in correspondence.
* The method is stable for a large range of values of this parameter.
*/
virtual double getGamma() const = 0;
virtual void setGamma(double gamma) = 0;
CV_WRAP virtual double getGamma() const = 0;
CV_WRAP virtual void setGamma(double gamma) = 0;
/**
* parameter used for motion estimation. It adds a variable allowing for illumination variations
@@ -292,14 +292,14 @@ public:
* See: Chambolle et al, A First-Order Primal-Dual Algorithm for Convex Problems with Applications to Imaging
* Journal of Mathematical imaging and vision, may 2011 Vol 40 issue 1, pp 120-145
*/
virtual double getTheta() const = 0;
virtual void setTheta(double theta) = 0;
CV_WRAP virtual double getTheta() const = 0;
CV_WRAP virtual void setTheta(double theta) = 0;
/**
* Number of scales used to create the pyramid of images.
*/
virtual int getNumScales() const = 0;
virtual void setNumScales(int nscales) = 0;
CV_WRAP virtual int getNumScales() const = 0;
CV_WRAP virtual void setNumScales(int nscales) = 0;
/**
* Number of warpings per scale.
@@ -307,29 +307,29 @@ public:
* This is a parameter that assures the stability of the method.
* It also affects the running time, so it is a compromise between speed and accuracy.
*/
virtual int getNumWarps() const = 0;
virtual void setNumWarps(int warps) = 0;
CV_WRAP virtual int getNumWarps() const = 0;
CV_WRAP virtual void setNumWarps(int warps) = 0;
/**
* Stopping criterion threshold used in the numerical scheme, which is a trade-off between precision and running time.
* A small value will yield more accurate solutions at the expense of a slower convergence.
*/
virtual double getEpsilon() const = 0;
virtual void setEpsilon(double epsilon) = 0;
CV_WRAP virtual double getEpsilon() const = 0;
CV_WRAP virtual void setEpsilon(double epsilon) = 0;
/**
* Stopping criterion iterations number used in the numerical scheme.
*/
virtual int getNumIterations() const = 0;
virtual void setNumIterations(int iterations) = 0;
CV_WRAP virtual int getNumIterations() const = 0;
CV_WRAP virtual void setNumIterations(int iterations) = 0;
virtual double getScaleStep() const = 0;
virtual void setScaleStep(double scaleStep) = 0;
CV_WRAP virtual double getScaleStep() const = 0;
CV_WRAP virtual void setScaleStep(double scaleStep) = 0;
virtual bool getUseInitialFlow() const = 0;
virtual void setUseInitialFlow(bool useInitialFlow) = 0;
CV_WRAP virtual bool getUseInitialFlow() const = 0;
CV_WRAP virtual void setUseInitialFlow(bool useInitialFlow) = 0;
static Ptr<OpticalFlowDual_TVL1> create(
CV_WRAP static Ptr<OpticalFlowDual_TVL1> create(
double tau = 0.25,
double lambda = 0.15,
double theta = 0.3,