The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

PDL::OpenCV::Tracking - PDL bindings for OpenCV DISOpticalFlow, DenseOpticalFlow, FarnebackOpticalFlow, KalmanFilter, SparseOpticalFlow, SparsePyrLKOpticalFlow, Tracker, TrackerCSRT, TrackerDaSiamRPN, TrackerGOTURN, TrackerKCF, TrackerMIL, VariationalRefinement

SYNOPSIS

 use PDL::OpenCV::Tracking;

FUNCTIONS

CamShift

  Signature: ([phys] probImage(l1,c1,r1); indx [io,phys] window(n2=4); TermCriteriaWrapper * criteria; [o] RotatedRectWrapper * res)

Finds an object center, size, and orientation.

 $res = CamShift($probImage,$window,$criteria);

@cite Bradski98 . First, it finds an object center using meanShift and then adjusts the window size and finds the optimal rotation. The function returns the rotated rectangle structure that includes the object position, size, and CV_WRAP orientation. The next position of the search window can be obtained with RotatedRect::boundingRect() See the OpenCV sample camshiftdemo.c that tracks colored objects. @note - (Python) A sample explaining the camshift tracking algorithm can be found at opencv_source_code/samples/python/camshift.py

Parameters:

probImage

Back projection of the object histogram. See calcBackProject.

window

Initial search window.

criteria

Stop criteria for the underlying meanShift. returns (in old interfaces) Number of iterations CAMSHIFT took to converge The function implements the CAMSHIFT object tracking algorithm

CamShift ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

meanShift

  Signature: ([phys] probImage(l1,c1,r1); indx [io,phys] window(n2=4); int [o,phys] res(); TermCriteriaWrapper * criteria)

Finds an object on a back projection image.

 $res = meanShift($probImage,$window,$criteria);

Parameters:

probImage

Back projection of the object histogram. See calcBackProject for details.

window

Initial search window.

criteria

Stop criteria for the iterative search algorithm. returns : Number of iterations CAMSHIFT took to converge. The function implements the iterative object search algorithm. It takes the input back projection of an object and the initial position. The mass center in window of the back projection image is computed and the search window center shifts to the mass center. The procedure is repeated until the specified number of iterations criteria.maxCount is done or until the window center shifts by less than criteria.epsilon. The algorithm is used inside CamShift and, unlike CamShift , the search window size or orientation do not change during the search. You can simply pass the output of calcBackProject to this function. But better results can be obtained if you pre-filter the back projection and remove the noise. For example, you can do this by retrieving connected components with findContours , throwing away contours with small area ( contourArea ), and rendering the remaining contours with drawContours.

meanShift ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

buildOpticalFlowPyramid

  Signature: ([phys] img(l1,c1,r1); indx [phys] winSize(n3=2); int [phys] maxLevel(); byte [phys] withDerivatives(); int [phys] pyrBorder(); int [phys] derivBorder(); byte [phys] tryReuseInputImage(); int [o,phys] res(); [o] vector_MatWrapper * pyramid)

Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK.

 ($pyramid,$res) = buildOpticalFlowPyramid($img,$winSize,$maxLevel); # with defaults
 ($pyramid,$res) = buildOpticalFlowPyramid($img,$winSize,$maxLevel,$withDerivatives,$pyrBorder,$derivBorder,$tryReuseInputImage);

Parameters:

img

8-bit input image.

pyramid

output pyramid.

winSize

window size of optical flow algorithm. Must be not less than winSize argument of calcOpticalFlowPyrLK. It is needed to calculate required padding for pyramid levels.

maxLevel

0-based maximal pyramid level number.

withDerivatives

set to precompute gradients for the every pyramid level. If pyramid is constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally.

pyrBorder

the border mode for pyramid layers.

derivBorder

the border mode for gradients.

tryReuseInputImage

put ROI of input image into the pyramid if possible. You can pass false to force data copying.

Returns: number of levels in constructed pyramid. Can be less than maxLevel.

buildOpticalFlowPyramid ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

calcOpticalFlowPyrLK

  Signature: ([phys] prevImg(l1,c1,r1); [phys] nextImg(l2,c2,r2); [phys] prevPts(l3,c3,r3); [io,phys] nextPts(l4,c4,r4); [o,phys] status(l5,c5,r5); [o,phys] err(l6,c6,r6); indx [phys] winSize(n7=2); int [phys] maxLevel(); int [phys] flags(); double [phys] minEigThreshold(); TermCriteriaWrapper * criteria)

Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids. NO BROADCASTING.

 ($status,$err) = calcOpticalFlowPyrLK($prevImg,$nextImg,$prevPts,$nextPts); # with defaults
 ($status,$err) = calcOpticalFlowPyrLK($prevImg,$nextImg,$prevPts,$nextPts,$winSize,$maxLevel,$criteria,$flags,$minEigThreshold);

@cite Bouguet00), divided by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding feature is filtered out and its flow is not processed, so it allows to remove bad points and get a performance boost. The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See @cite Bouguet00 . The function is parallelized with the TBB library. @note - An example using the Lucas-Kanade optical flow algorithm can be found at opencv_source_code/samples/cpp/lkdemo.cpp - (Python) An example using the Lucas-Kanade optical flow algorithm can be found at opencv_source_code/samples/python/lk_track.py - (Python) An example using the Lucas-Kanade tracker for homography matching can be found at opencv_source_code/samples/python/lk_homography.py

Parameters:

prevImg

first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid.

nextImg

second input image or pyramid of the same size and the same type as prevImg.

prevPts

vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers.

nextPts

output vector of 2D points (with single-precision floating-point coordinates) containing the calculated new positions of input features in the second image; when OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.

status

output status vector (of unsigned chars); each element of the vector is set to 1 if the flow for the corresponding features has been found, otherwise, it is set to 0.

err

output vector of errors; each element of the vector is set to an error for the corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't found then the error is not defined (use the status parameter to find such cases).

winSize

size of the search window at each pyramid level.

maxLevel

0-based maximal pyramid level number; if set to 0, pyramids are not used (single level), if set to 1, two levels are used, and so on; if pyramids are passed to input then algorithm will use as many levels as pyramids have but no more than maxLevel.

criteria

parameter, specifying the termination criteria of the iterative search algorithm (after the specified maximum number of iterations criteria.maxCount or when the search window moves by less than criteria.epsilon.

flags

operation flags: - **OPTFLOW_USE_INITIAL_FLOW** uses initial estimations, stored in nextPts; if the flag is not set, then prevPts is copied to nextPts and is considered the initial estimate. - **OPTFLOW_LK_GET_MIN_EIGENVALS** use minimum eigen values as an error measure (see minEigThreshold description); if the flag is not set, then L1 distance between patches around the original and a moved point, divided by number of pixels in a window, is used as a error measure.

minEigThreshold

the algorithm calculates the minimum eigen value of a 2x2 normal matrix of optical flow equations (this matrix is called a spatial gradient matrix in

calcOpticalFlowPyrLK ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

calcOpticalFlowFarneback

  Signature: ([phys] prev(l1,c1,r1); [phys] next(l2,c2,r2); [io,phys] flow(l3,c3,r3); double [phys] pyr_scale(); int [phys] levels(); int [phys] winsize(); int [phys] iterations(); int [phys] poly_n(); double [phys] poly_sigma(); int [phys] flags())

Computes a dense optical flow using the Gunnar Farneback's algorithm.

 calcOpticalFlowFarneback($prev,$next,$flow,$pyr_scale,$levels,$winsize,$iterations,$poly_n,$poly_sigma,$flags);

\<1) to build pyramids for each image; pyr_scale=0.5 means a classical pyramid, where each next layer is twice smaller than the previous one. \texttt{winsize}\times\texttt{winsize}filter instead of a box filter of the same size for optical flow estimation; usually, this option gives z more accurate flow than with a box filter, at the cost of lower speed; normally, winsize for a Gaussian window should be set to a larger value to achieve the same level of robustness. The function finds an optical flow for each prev pixel using the @cite Farneback2003 algorithm so that \f[\texttt{prev} (y,x) \sim \texttt{next} ( y + \texttt{flow} (y,x)[1], x + \texttt{flow} (y,x)[0])\f] @note - An example using the optical flow algorithm described by Gunnar Farneback can be found at opencv_source_code/samples/cpp/fback.cpp - (Python) An example using the optical flow algorithm described by Gunnar Farneback can be found at opencv_source_code/samples/python/opt_flow.py

Parameters:

prev

first 8-bit single-channel input image.

next

second input image of the same size and the same type as prev.

flow

computed flow image that has the same size as prev and type CV_32FC2.

pyr_scale

parameter, specifying the image scale (

levels

number of pyramid layers including the initial image; levels=1 means that no extra layers are created and only the original images are used.

winsize

averaging window size; larger values increase the algorithm robustness to image noise and give more chances for fast motion detection, but yield more blurred motion field.

iterations

number of iterations the algorithm does at each pyramid level.

poly_n

size of the pixel neighborhood used to find polynomial expansion in each pixel; larger values mean that the image will be approximated with smoother surfaces, yielding more robust algorithm and more blurred motion field, typically poly_n =5 or 7.

poly_sigma

standard deviation of the Gaussian that is used to smooth derivatives used as a basis for the polynomial expansion; for poly_n=5, you can set poly_sigma=1.1, for poly_n=7, a good value would be poly_sigma=1.5.

flags

operation flags that can be a combination of the following: - **OPTFLOW_USE_INITIAL_FLOW** uses the input flow as an initial flow approximation. - **OPTFLOW_FARNEBACK_GAUSSIAN** uses the Gaussian

calcOpticalFlowFarneback ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

computeECC

  Signature: ([phys] templateImage(l1,c1,r1); [phys] inputImage(l2,c2,r2); [phys] inputMask(l3,c3,r3); double [o,phys] res())

Computes the Enhanced Correlation Coefficient value between two images

 $res = computeECC($templateImage,$inputImage); # with defaults
 $res = computeECC($templateImage,$inputImage,$inputMask);

@cite EP08 .

Parameters:

templateImage

single-channel template image; CV_8U or CV_32F array.

inputImage

single-channel input image to be warped to provide an image similar to templateImage, same type as templateImage.

inputMask

An optional mask to indicate valid values of inputImage.

See also: findTransformECC

computeECC ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

findTransformECC

  Signature: ([phys] templateImage(l1,c1,r1); [phys] inputImage(l2,c2,r2); [io,phys] warpMatrix(l3,c3,r3); int [phys] motionType(); [phys] inputMask(l6,c6,r6); int [phys] gaussFiltSize(); double [o,phys] res(); TermCriteriaWrapper * criteria)

Finds the geometric transform (warp) between two images in terms of the ECC criterion

 $res = findTransformECC($templateImage,$inputImage,$warpMatrix,$motionType,$criteria,$inputMask,$gaussFiltSize);

@cite EP08 . 2\times 3or 3\times 3mapping matrix (warp). 2\times 3with the first 2\times 2part being the unity matrix and the rest two parameters being estimated. - **MOTION_EUCLIDEAN** sets a Euclidean (rigid) transformation as motion model; three parameters are estimated; warpMatrix is 2\times 3. - **MOTION_AFFINE** sets an affine motion model (DEFAULT); six parameters are estimated; warpMatrix is 2\times 3. - **MOTION_HOMOGRAPHY** sets a homography as a motion model; eight parameters are estimated;\`warpMatrix\` is 3\times 3. The function estimates the optimum transformation (warpMatrix) with respect to ECC criterion (@cite EP08), that is \f[\texttt{warpMatrix} = \arg\max_{W} \texttt{ECC}(\texttt{templateImage}(x,y),\texttt{inputImage}(x',y'))\f] where \f[\begin{bmatrix} x' \\ y' \end{bmatrix} = W \cdot \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}\f] (the equation holds with homogeneous coordinates for homography). It returns the final enhanced correlation coefficient, that is the correlation coefficient between the template image and the final warped input image. When a 3\times 3matrix is given with motionType =0, 1 or 2, the third row is ignored. Unlike findHomography and estimateRigidTransform, the function findTransformECC implements an area-based alignment that builds on intensity similarities. In essence, the function updates the initial transformation that roughly aligns the images. If this information is missing, the identity warp (unity matrix) is used as an initialization. Note that if images undergo strong displacements/rotations, an initial transformation that roughly aligns the images is necessary (e.g., a simple euclidean/similarity transform that allows for the images showing the same image content approximately). Use inverse warping in the second image to take an image close to the first one, i.e. use the flag WARP_INVERSE_MAP with warpAffine or warpPerspective. See also the OpenCV sample image_alignment.cpp that demonstrates the use of the function. Note that the function throws an exception if algorithm does not converges.

Parameters:

templateImage

single-channel template image; CV_8U or CV_32F array.

inputImage

single-channel input image which should be warped with the final warpMatrix in order to provide an image similar to templateImage, same type as templateImage.

warpMatrix

floating-point

motionType

parameter, specifying the type of motion: - **MOTION_TRANSLATION** sets a translational motion model; warpMatrix is

criteria

parameter, specifying the termination criteria of the ECC algorithm; criteria.epsilon defines the threshold of the increment in the correlation coefficient between two iterations (a negative criteria.epsilon makes criteria.maxcount the only termination criterion). Default values are shown in the declaration above.

inputMask

An optional mask to indicate valid values of inputImage.

gaussFiltSize

An optional value indicating size of gaussian blur filter; (DEFAULT: 5)

See also: computeECC, estimateAffine2D, estimateAffinePartial2D, findHomography

findTransformECC ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

findTransformECC2

  Signature: ([phys] templateImage(l1,c1,r1); [phys] inputImage(l2,c2,r2); [io,phys] warpMatrix(l3,c3,r3); int [phys] motionType(); [phys] inputMask(l6,c6,r6); double [o,phys] res(); TermCriteriaWrapper * criteria)
 $res = findTransformECC2($templateImage,$inputImage,$warpMatrix); # with defaults
 $res = findTransformECC2($templateImage,$inputImage,$warpMatrix,$motionType,$criteria,$inputMask);

@overload

findTransformECC2 ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

readOpticalFlow

  Signature: ([o,phys] res(l2,c2,r2); StringWrapper* path)

Read a .flo file NO BROADCASTING.

 $res = readOpticalFlow($path);

The function readOpticalFlow loads a flow field from a file and returns it as a single matrix. Resulting Mat has a type CV_32FC2 - floating-point, 2-channel. First channel corresponds to the flow in the horizontal direction (u), second - vertical (v).

Parameters:

path

Path to the file to be loaded

readOpticalFlow ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

writeOpticalFlow

  Signature: ([phys] flow(l2,c2,r2); byte [o,phys] res(); StringWrapper* path)

Write a .flo to disk

 $res = writeOpticalFlow($path,$flow);

The function stores a flow field in a file, returns true on success, false otherwise. The flow field must be a 2-channel, floating-point matrix (CV_32FC2). First channel corresponds to the flow in the horizontal direction (u), second - vertical (v).

Parameters:

path

Path to the file to be written

flow

Flow field to be stored

writeOpticalFlow ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

METHODS for PDL::OpenCV::DISOpticalFlow

DIS optical flow algorithm.

This class implements the Dense Inverse Search (DIS) optical flow algorithm. More details about the algorithm can be found at @cite Kroeger2016 . 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 (@ref getUseSpatialPropagation), as well as an option to utilize an initial flow approximation passed to @ref calc (which is, essentially, temporal propagation, if the previous frame's flow field is passed).

Subclass of PDL::OpenCV::DenseOpticalFlow

new

Creates an instance of DISOpticalFlow

 $obj = PDL::OpenCV::DISOpticalFlow->new; # with defaults
 $obj = PDL::OpenCV::DISOpticalFlow->new($preset);

Parameters:

preset

one of PRESET_ULTRAFAST, PRESET_FAST and PRESET_MEDIUM

getFinestScale

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.

 $res = $obj->getFinestScale;

See also: setFinestScale

setFinestScale

 $obj->setFinestScale($val);

@copybrief getFinestScale See also: getFinestScale

getPatchSize

Size of an image patch for matching (in pixels). Normally, default 8x8 patches work well enough in most cases.

 $res = $obj->getPatchSize;

See also: setPatchSize

setPatchSize

 $obj->setPatchSize($val);

@copybrief getPatchSize See also: getPatchSize

getPatchStride

Stride between neighbor patches. Must be less than patch size. Lower values correspond to higher flow quality.

 $res = $obj->getPatchStride;

See also: setPatchStride

setPatchStride

 $obj->setPatchStride($val);

@copybrief getPatchStride See also: getPatchStride

getGradientDescentIterations

Maximum number of gradient descent iterations in the patch inverse search stage. Higher values may improve quality in some cases.

 $res = $obj->getGradientDescentIterations;

See also: setGradientDescentIterations

setGradientDescentIterations

 $obj->setGradientDescentIterations($val);

@copybrief getGradientDescentIterations See also: getGradientDescentIterations

getVariationalRefinementIterations

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.

 $res = $obj->getVariationalRefinementIterations;

See also: setGradientDescentIterations

setVariationalRefinementIterations

 $obj->setVariationalRefinementIterations($val);

@copybrief getGradientDescentIterations See also: getGradientDescentIterations

getVariationalRefinementAlpha

Weight of the smoothness term

 $res = $obj->getVariationalRefinementAlpha;

See also: setVariationalRefinementAlpha

setVariationalRefinementAlpha

 $obj->setVariationalRefinementAlpha($val);

@copybrief getVariationalRefinementAlpha See also: getVariationalRefinementAlpha

getVariationalRefinementDelta

Weight of the color constancy term

 $res = $obj->getVariationalRefinementDelta;

See also: setVariationalRefinementDelta

setVariationalRefinementDelta

 $obj->setVariationalRefinementDelta($val);

@copybrief getVariationalRefinementDelta See also: getVariationalRefinementDelta

getVariationalRefinementGamma

Weight of the gradient constancy term

 $res = $obj->getVariationalRefinementGamma;

See also: setVariationalRefinementGamma

setVariationalRefinementGamma

 $obj->setVariationalRefinementGamma($val);

@copybrief getVariationalRefinementGamma See also: getVariationalRefinementGamma

getUseMeanNormalization

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.

 $res = $obj->getUseMeanNormalization;

See also: setUseMeanNormalization

setUseMeanNormalization

 $obj->setUseMeanNormalization($val);

@copybrief getUseMeanNormalization See also: getUseMeanNormalization

getUseSpatialPropagation

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.

 $res = $obj->getUseSpatialPropagation;

See also: setUseSpatialPropagation

setUseSpatialPropagation

 $obj->setUseSpatialPropagation($val);

@copybrief getUseSpatialPropagation See also: getUseSpatialPropagation

METHODS for PDL::OpenCV::DenseOpticalFlow

Base class for dense optical flow algorithms

Subclass of PDL::OpenCV::Algorithm

DenseOpticalFlow_calc

  Signature: ([phys] I0(l2,c2,r2); [phys] I1(l3,c3,r3); [io,phys] flow(l4,c4,r4); DenseOpticalFlowWrapper * self)

Calculates an optical flow.

 $obj->calc($I0,$I1,$flow);

Parameters:

I0

first 8-bit single-channel input image.

I1

second input image of the same size and the same type as prev.

flow

computed flow image that has the same size as prev and type CV_32FC2.

DenseOpticalFlow_calc ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

collectGarbage

Releases all inner buffers.

 $obj->collectGarbage;

METHODS for PDL::OpenCV::FarnebackOpticalFlow

Class computing a dense optical flow using the Gunnar Farneback's algorithm.

Subclass of PDL::OpenCV::DenseOpticalFlow

new

 $obj = PDL::OpenCV::FarnebackOpticalFlow->new; # with defaults
 $obj = PDL::OpenCV::FarnebackOpticalFlow->new($numLevels,$pyrScale,$fastPyramids,$winSize,$numIters,$polyN,$polySigma,$flags);

getNumLevels

 $res = $obj->getNumLevels;

setNumLevels

 $obj->setNumLevels($numLevels);

getPyrScale

 $res = $obj->getPyrScale;

setPyrScale

 $obj->setPyrScale($pyrScale);

getFastPyramids

 $res = $obj->getFastPyramids;

setFastPyramids

 $obj->setFastPyramids($fastPyramids);

getWinSize

 $res = $obj->getWinSize;

setWinSize

 $obj->setWinSize($winSize);

getNumIters

 $res = $obj->getNumIters;

setNumIters

 $obj->setNumIters($numIters);

getPolyN

 $res = $obj->getPolyN;

setPolyN

 $obj->setPolyN($polyN);

getPolySigma

 $res = $obj->getPolySigma;

setPolySigma

 $obj->setPolySigma($polySigma);

getFlags

 $res = $obj->getFlags;

setFlags

 $obj->setFlags($flags);

METHODS for PDL::OpenCV::KalmanFilter

Kalman filter class.

The class implements a standard Kalman filter <http://en.wikipedia.org/wiki/Kalman_filter>, @cite Welch95 . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get an extended Kalman filter functionality. @note In C API when CvKalman* kalmanFilter structure is not needed anymore, it should be released with cvReleaseKalman(&kalmanFilter)

new

 $obj = PDL::OpenCV::KalmanFilter->new;

new2

 $obj = PDL::OpenCV::KalmanFilter->new2($dynamParams,$measureParams); # with defaults
 $obj = PDL::OpenCV::KalmanFilter->new2($dynamParams,$measureParams,$controlParams,$type);

@overload

Parameters:

dynamParams

Dimensionality of the state.

measureParams

Dimensionality of the measurement.

controlParams

Dimensionality of the control vector.

type

Type of the created matrices that should be CV_32F or CV_64F.

KalmanFilter_predict

  Signature: ([phys] control(l2,c2,r2); [o,phys] res(l3,c3,r3); KalmanFilterWrapper * self)

Computes a predicted state. NO BROADCASTING.

 $res = $obj->predict; # with defaults
 $res = $obj->predict($control);

Parameters:

control

The optional input control

KalmanFilter_predict ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

KalmanFilter_correct

  Signature: ([phys] measurement(l2,c2,r2); [o,phys] res(l3,c3,r3); KalmanFilterWrapper * self)

Updates the predicted state from the measurement. NO BROADCASTING.

 $res = $obj->correct($measurement);

Parameters:

measurement

The measured system parameters

KalmanFilter_correct ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

METHODS for PDL::OpenCV::SparseOpticalFlow

Base interface for sparse optical flow algorithms.

Subclass of PDL::OpenCV::Algorithm

SparseOpticalFlow_calc

  Signature: ([phys] prevImg(l2,c2,r2); [phys] nextImg(l3,c3,r3); [phys] prevPts(l4,c4,r4); [io,phys] nextPts(l5,c5,r5); [o,phys] status(l6,c6,r6); [o,phys] err(l7,c7,r7); SparseOpticalFlowWrapper * self)

Calculates a sparse optical flow. NO BROADCASTING.

 ($status,$err) = $obj->calc($prevImg,$nextImg,$prevPts,$nextPts);

Parameters:

prevImg

First input image.

nextImg

Second input image of the same size and the same type as prevImg.

prevPts

Vector of 2D points for which the flow needs to be found.

nextPts

Output vector of 2D points containing the calculated new positions of input features in the second image.

status

Output status vector. Each element of the vector is set to 1 if the flow for the corresponding features has been found. Otherwise, it is set to 0.

err

Optional output vector that contains error response for each point (inverse confidence).

SparseOpticalFlow_calc ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

METHODS for PDL::OpenCV::SparsePyrLKOpticalFlow

Class used for calculating a sparse optical flow.

The class can calculate an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids. See also: calcOpticalFlowPyrLK

Subclass of PDL::OpenCV::SparseOpticalFlow

SparsePyrLKOpticalFlow_new

  Signature: (indx [phys] winSize(n2=2); int [phys] maxLevel(); int [phys] flags(); double [phys] minEigThreshold(); char * klass; TermCriteriaWrapper * crit; [o] SparsePyrLKOpticalFlowWrapper * res)
 $obj = PDL::OpenCV::SparsePyrLKOpticalFlow->new; # with defaults
 $obj = PDL::OpenCV::SparsePyrLKOpticalFlow->new($winSize,$maxLevel,$crit,$flags,$minEigThreshold);

SparsePyrLKOpticalFlow_new ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

SparsePyrLKOpticalFlow_getWinSize

  Signature: (indx [o,phys] res(n2=2); SparsePyrLKOpticalFlowWrapper * self)
 $res = $obj->getWinSize;

SparsePyrLKOpticalFlow_getWinSize ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

SparsePyrLKOpticalFlow_setWinSize

  Signature: (indx [phys] winSize(n2=2); SparsePyrLKOpticalFlowWrapper * self)
 $obj->setWinSize($winSize);

SparsePyrLKOpticalFlow_setWinSize ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

getMaxLevel

 $res = $obj->getMaxLevel;

setMaxLevel

 $obj->setMaxLevel($maxLevel);

getTermCriteria

 $res = $obj->getTermCriteria;

setTermCriteria

 $obj->setTermCriteria($crit);

getFlags

 $res = $obj->getFlags;

setFlags

 $obj->setFlags($flags);

getMinEigThreshold

 $res = $obj->getMinEigThreshold;

setMinEigThreshold

 $obj->setMinEigThreshold($minEigThreshold);

METHODS for PDL::OpenCV::Tracker

Base abstract class for the long-term tracker

Tracker_init

  Signature: ([phys] image(l2,c2,r2); indx [phys] boundingBox(n3=4); TrackerWrapper * self)

Initialize the tracker with a known bounding box that surrounded the target

 $obj->init($image,$boundingBox);

Parameters:

image

The initial frame

boundingBox

The initial bounding box

Tracker_init ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

Tracker_update

  Signature: ([phys] image(l2,c2,r2); indx [o,phys] boundingBox(n3=4); byte [o,phys] res(); TrackerWrapper * self)

Update the tracker, find the new most likely bounding box for the target

 ($boundingBox,$res) = $obj->update($image);

Parameters:

image

The current frame

boundingBox

The bounding box that represent the new target location, if true was returned, not modified otherwise

Returns: True means that target was located and false means that tracker cannot locate target in current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed missing from the frame (say, out of sight)

Tracker_update ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

METHODS for PDL::OpenCV::TrackerCSRT

the CSRT tracker

The implementation is based on @cite Lukezic_IJCV2018 Discriminative Correlation Filter with Channel and Spatial Reliability

Subclass of PDL::OpenCV::Tracker

new

Create CSRT tracker instance

 $obj = PDL::OpenCV::TrackerCSRT->new;

Parameters:

parameters

CSRT parameters TrackerCSRT::Params

TrackerCSRT_setInitialMask

  Signature: ([phys] mask(l2,c2,r2); TrackerCSRTWrapper * self)
 $obj->setInitialMask($mask);

TrackerCSRT_setInitialMask ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

METHODS for PDL::OpenCV::TrackerDaSiamRPN

Subclass of PDL::OpenCV::Tracker

new

Constructor

 $obj = PDL::OpenCV::TrackerDaSiamRPN->new;

Parameters:

parameters

DaSiamRPN parameters TrackerDaSiamRPN::Params

getTrackingScore

Return tracking score

 $res = $obj->getTrackingScore;

METHODS for PDL::OpenCV::TrackerGOTURN

the GOTURN (Generic Object Tracking Using Regression Networks) tracker * * GOTURN (

@cite GOTURN) is kind of trackers based on Convolutional Neural Networks (CNN). While taking all advantages of CNN trackers, * GOTURN is much faster due to offline training without online fine-tuning nature. * GOTURN tracker addresses the problem of single target tracking: given a bounding box label of an object in the first frame of the video, * we track that object through the rest of the video. NOTE: Current method of GOTURN does not handle occlusions; however, it is fairly * robust to viewpoint changes, lighting changes, and deformations. * Inputs of GOTURN are two RGB patches representing Target and Search patches resized to 227x227. * Outputs of GOTURN are predicted bounding box coordinates, relative to Search patch coordinate system, in format X1,Y1,X2,Y2. * Original paper is here: <http://davheld.github.io/GOTURN/GOTURN.pdf> * As long as original authors implementation: <https://github.com/davheld/GOTURN#train-the-tracker> * Implementation of training algorithm is placed in separately here due to 3d-party dependencies: * <https://github.com/Auron-X/GOTURN_Training_Toolkit> * GOTURN architecture goturn.prototxt and trained model goturn.caffemodel are accessible on opencv_extra GitHub repository.

Subclass of PDL::OpenCV::Tracker

new

Constructor

 $obj = PDL::OpenCV::TrackerGOTURN->new;

Parameters:

parameters

GOTURN parameters TrackerGOTURN::Params

METHODS for PDL::OpenCV::TrackerKCF

the KCF (Kernelized Correlation Filter) tracker

* KCF is a novel tracking framework that utilizes properties of circulant matrix to enhance the processing speed. * This tracking method is an implementation of @cite KCF_ECCV which is extended to KCF with color-names features (@cite KCF_CN). * The original paper of KCF is available at <http://www.robots.ox.ac.uk/~joao/publications/henriques_tpami2015.pdf> * as well as the matlab implementation. For more information about KCF with color-names features, please refer to * <http://www.cvl.isy.liu.se/research/objrec/visualtracking/colvistrack/index.html>.

Subclass of PDL::OpenCV::Tracker

new

Create KCF tracker instance

 $obj = PDL::OpenCV::TrackerKCF->new;

Parameters:

parameters

KCF parameters TrackerKCF::Params

METHODS for PDL::OpenCV::TrackerMIL

The MIL algorithm trains a classifier in an online manner to separate the object from the background.

Multiple Instance Learning avoids the drift problem for a robust tracking. The implementation is based on @cite MIL . Original code can be found here <http://vision.ucsd.edu/~bbabenko/project_miltrack.shtml>

Subclass of PDL::OpenCV::Tracker

new

Create MIL tracker instance *

 $obj = PDL::OpenCV::TrackerMIL->new;

Parameters:

parameters

MIL parameters TrackerMIL::Params

METHODS for PDL::OpenCV::VariationalRefinement

Variational optical flow refinement

This class implements variational refinement of the input flow field, i.e. it uses input flow to initialize the minimization of the following functional: E(U) = \int_{\Omega} \delta \Psi(E_I) + \gamma \Psi(E_G) + \alpha \Psi(E_S), where E_I,E_G,E_Sare color constancy, gradient constancy and smoothness terms respectively. \Psi(s^2)=\sqrt{s^2+\epsilon^2}is a robust penalizer to limit the influence of outliers. A complete formulation and a description of the minimization procedure can be found in @cite Brox2004

Subclass of PDL::OpenCV::DenseOpticalFlow

new

Creates an instance of VariationalRefinement

 $obj = PDL::OpenCV::VariationalRefinement->new;

VariationalRefinement_calcUV

  Signature: ([phys] I0(l2,c2,r2); [phys] I1(l3,c3,r3); [io,phys] flow_u(l4,c4,r4); [io,phys] flow_v(l5,c5,r5); VariationalRefinementWrapper * self)
 $obj->calcUV($I0,$I1,$flow_u,$flow_v);

@ref calc function overload to handle separate horizontal (u) and vertical (v) flow components (to avoid extra splits/merges)

VariationalRefinement_calcUV ignores the bad-value flag of the input ndarrays. It will set the bad-value flag of all output ndarrays if the flag is set for any of the input ndarrays.

getFixedPointIterations

Number of outer (fixed-point) iterations in the minimization procedure.

 $res = $obj->getFixedPointIterations;

See also: setFixedPointIterations

setFixedPointIterations

 $obj->setFixedPointIterations($val);

@copybrief getFixedPointIterations See also: getFixedPointIterations

getSorIterations

Number of inner successive over-relaxation (SOR) iterations in the minimization procedure to solve the respective linear system.

 $res = $obj->getSorIterations;

See also: setSorIterations

setSorIterations

 $obj->setSorIterations($val);

@copybrief getSorIterations See also: getSorIterations

getOmega

Relaxation factor in SOR

 $res = $obj->getOmega;

See also: setOmega

setOmega

 $obj->setOmega($val);

@copybrief getOmega See also: getOmega

getAlpha

Weight of the smoothness term

 $res = $obj->getAlpha;

See also: setAlpha

setAlpha

 $obj->setAlpha($val);

@copybrief getAlpha See also: getAlpha

getDelta

Weight of the color constancy term

 $res = $obj->getDelta;

See also: setDelta

setDelta

 $obj->setDelta($val);

@copybrief getDelta See also: getDelta

getGamma

Weight of the gradient constancy term

 $res = $obj->getGamma;

See also: setGamma

setGamma

 $obj->setGamma($val);

@copybrief getGamma See also: getGamma

CONSTANTS

PDL::OpenCV::Tracking::OPTFLOW_USE_INITIAL_FLOW()
PDL::OpenCV::Tracking::OPTFLOW_LK_GET_MIN_EIGENVALS()
PDL::OpenCV::Tracking::OPTFLOW_FARNEBACK_GAUSSIAN()
PDL::OpenCV::Tracking::MOTION_TRANSLATION()
PDL::OpenCV::Tracking::MOTION_EUCLIDEAN()
PDL::OpenCV::Tracking::MOTION_AFFINE()
PDL::OpenCV::Tracking::MOTION_HOMOGRAPHY()
PDL::OpenCV::Tracking::DISOpticalFlow::PRESET_ULTRAFAST()
PDL::OpenCV::Tracking::DISOpticalFlow::PRESET_FAST()
PDL::OpenCV::Tracking::DISOpticalFlow::PRESET_MEDIUM()
PDL::OpenCV::Tracking::TrackerKCF::GRAY()
PDL::OpenCV::Tracking::TrackerKCF::CN()
PDL::OpenCV::Tracking::TrackerKCF::CUSTOM()