Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RZ_A2M_Mbed_samples
tracking.hpp
00001 /*M/////////////////////////////////////////////////////////////////////////////////////// 00002 // 00003 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 00004 // 00005 // By downloading, copying, installing or using the software you agree to this license. 00006 // If you do not agree to this license, do not download, install, 00007 // copy or use the software. 00008 // 00009 // 00010 // License Agreement 00011 // For Open Source Computer Vision Library 00012 // 00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved. 00015 // Copyright (C) 2013, OpenCV Foundation, all rights reserved. 00016 // Third party copyrights are property of their respective owners. 00017 // 00018 // Redistribution and use in source and binary forms, with or without modification, 00019 // are permitted provided that the following conditions are met: 00020 // 00021 // * Redistribution's of source code must retain the above copyright notice, 00022 // this list of conditions and the following disclaimer. 00023 // 00024 // * Redistribution's in binary form must reproduce the above copyright notice, 00025 // this list of conditions and the following disclaimer in the documentation 00026 // and/or other materials provided with the distribution. 00027 // 00028 // * The name of the copyright holders may not be used to endorse or promote products 00029 // derived from this software without specific prior written permission. 00030 // 00031 // This software is provided by the copyright holders and contributors "as is" and 00032 // any express or implied warranties, including, but not limited to, the implied 00033 // warranties of merchantability and fitness for a particular purpose are disclaimed. 00034 // In no event shall the Intel Corporation or contributors be liable for any direct, 00035 // indirect, incidental, special, exemplary, or consequential damages 00036 // (including, but not limited to, procurement of substitute goods or services; 00037 // loss of use, data, or profits; or business interruption) however caused 00038 // and on any theory of liability, whether in contract, strict liability, 00039 // or tort (including negligence or otherwise) arising in any way out of 00040 // the use of this software, even if advised of the possibility of such damage. 00041 // 00042 //M*/ 00043 00044 #ifndef OPENCV_TRACKING_HPP 00045 #define OPENCV_TRACKING_HPP 00046 00047 #include "opencv2/core.hpp" 00048 #include "opencv2/imgproc.hpp" 00049 00050 namespace cv 00051 { 00052 00053 //! @addtogroup video_track 00054 //! @{ 00055 00056 enum { OPTFLOW_USE_INITIAL_FLOW = 4, 00057 OPTFLOW_LK_GET_MIN_EIGENVALS = 8, 00058 OPTFLOW_FARNEBACK_GAUSSIAN = 256 00059 }; 00060 00061 /** @brief Finds an object center, size, and orientation. 00062 00063 @param probImage Back projection of the object histogram. See calcBackProject. 00064 @param window Initial search window. 00065 @param criteria Stop criteria for the underlying meanShift. 00066 returns 00067 (in old interfaces) Number of iterations CAMSHIFT took to converge 00068 The function implements the CAMSHIFT object tracking algorithm @cite Bradski98 . First, it finds an 00069 object center using meanShift and then adjusts the window size and finds the optimal rotation. The 00070 function returns the rotated rectangle structure that includes the object position, size, and 00071 orientation. The next position of the search window can be obtained with RotatedRect::boundingRect() 00072 00073 See the OpenCV sample camshiftdemo.c that tracks colored objects. 00074 00075 @note 00076 - (Python) A sample explaining the camshift tracking algorithm can be found at 00077 opencv_source_code/samples/python/camshift.py 00078 */ 00079 CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_IN_OUT Rect& window, 00080 TermCriteria criteria ); 00081 00082 /** @brief Finds an object on a back projection image. 00083 00084 @param probImage Back projection of the object histogram. See calcBackProject for details. 00085 @param window Initial search window. 00086 @param criteria Stop criteria for the iterative search algorithm. 00087 returns 00088 : Number of iterations CAMSHIFT took to converge. 00089 The function implements the iterative object search algorithm. It takes the input back projection of 00090 an object and the initial position. The mass center in window of the back projection image is 00091 computed and the search window center shifts to the mass center. The procedure is repeated until the 00092 specified number of iterations criteria.maxCount is done or until the window center shifts by less 00093 than criteria.epsilon. The algorithm is used inside CamShift and, unlike CamShift , the search 00094 window size or orientation do not change during the search. You can simply pass the output of 00095 calcBackProject to this function. But better results can be obtained if you pre-filter the back 00096 projection and remove the noise. For example, you can do this by retrieving connected components 00097 with findContours , throwing away contours with small area ( contourArea ), and rendering the 00098 remaining contours with drawContours. 00099 00100 @note 00101 - A mean-shift tracking sample can be found at opencv_source_code/samples/cpp/camshiftdemo.cpp 00102 */ 00103 CV_EXPORTS_W int meanShift( InputArray probImage, CV_IN_OUT Rect& window, TermCriteria criteria ); 00104 00105 /** @brief Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK. 00106 00107 @param img 8-bit input image. 00108 @param pyramid output pyramid. 00109 @param winSize window size of optical flow algorithm. Must be not less than winSize argument of 00110 calcOpticalFlowPyrLK. It is needed to calculate required padding for pyramid levels. 00111 @param maxLevel 0-based maximal pyramid level number. 00112 @param withDerivatives set to precompute gradients for the every pyramid level. If pyramid is 00113 constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally. 00114 @param pyrBorder the border mode for pyramid layers. 00115 @param derivBorder the border mode for gradients. 00116 @param tryReuseInputImage put ROI of input image into the pyramid if possible. You can pass false 00117 to force data copying. 00118 @return number of levels in constructed pyramid. Can be less than maxLevel. 00119 */ 00120 CV_EXPORTS_W int buildOpticalFlowPyramid( InputArray img, OutputArrayOfArrays pyramid, 00121 Size winSize, int maxLevel, bool withDerivatives = true, 00122 int pyrBorder = BORDER_REFLECT_101, 00123 int derivBorder = BORDER_CONSTANT, 00124 bool tryReuseInputImage = true ); 00125 00126 /** @brief Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with 00127 pyramids. 00128 00129 @param prevImg first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid. 00130 @param nextImg second input image or pyramid of the same size and the same type as prevImg. 00131 @param prevPts vector of 2D points for which the flow needs to be found; point coordinates must be 00132 single-precision floating-point numbers. 00133 @param nextPts output vector of 2D points (with single-precision floating-point coordinates) 00134 containing the calculated new positions of input features in the second image; when 00135 OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input. 00136 @param status output status vector (of unsigned chars); each element of the vector is set to 1 if 00137 the flow for the corresponding features has been found, otherwise, it is set to 0. 00138 @param err output vector of errors; each element of the vector is set to an error for the 00139 corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't 00140 found then the error is not defined (use the status parameter to find such cases). 00141 @param winSize size of the search window at each pyramid level. 00142 @param maxLevel 0-based maximal pyramid level number; if set to 0, pyramids are not used (single 00143 level), if set to 1, two levels are used, and so on; if pyramids are passed to input then 00144 algorithm will use as many levels as pyramids have but no more than maxLevel. 00145 @param criteria parameter, specifying the termination criteria of the iterative search algorithm 00146 (after the specified maximum number of iterations criteria.maxCount or when the search window 00147 moves by less than criteria.epsilon. 00148 @param flags operation flags: 00149 - **OPTFLOW_USE_INITIAL_FLOW** uses initial estimations, stored in nextPts; if the flag is 00150 not set, then prevPts is copied to nextPts and is considered the initial estimate. 00151 - **OPTFLOW_LK_GET_MIN_EIGENVALS** use minimum eigen values as an error measure (see 00152 minEigThreshold description); if the flag is not set, then L1 distance between patches 00153 around the original and a moved point, divided by number of pixels in a window, is used as a 00154 error measure. 00155 @param minEigThreshold the algorithm calculates the minimum eigen value of a 2x2 normal matrix of 00156 optical flow equations (this matrix is called a spatial gradient matrix in @cite Bouguet00), divided 00157 by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding 00158 feature is filtered out and its flow is not processed, so it allows to remove bad points and get a 00159 performance boost. 00160 00161 The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See 00162 @cite Bouguet00 . The function is parallelized with the TBB library. 00163 00164 @note 00165 00166 - An example using the Lucas-Kanade optical flow algorithm can be found at 00167 opencv_source_code/samples/cpp/lkdemo.cpp 00168 - (Python) An example using the Lucas-Kanade optical flow algorithm can be found at 00169 opencv_source_code/samples/python/lk_track.py 00170 - (Python) An example using the Lucas-Kanade tracker for homography matching can be found at 00171 opencv_source_code/samples/python/lk_homography.py 00172 */ 00173 CV_EXPORTS_W void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg, 00174 InputArray prevPts, InputOutputArray nextPts, 00175 OutputArray status, OutputArray err, 00176 Size winSize = Size(21,21), int maxLevel = 3, 00177 TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), 00178 int flags = 0, double minEigThreshold = 1e-4 ); 00179 00180 /** @brief Computes a dense optical flow using the Gunnar Farneback's algorithm. 00181 00182 @param prev first 8-bit single-channel input image. 00183 @param next second input image of the same size and the same type as prev. 00184 @param flow computed flow image that has the same size as prev and type CV_32FC2. 00185 @param pyr_scale parameter, specifying the image scale (<1) to build pyramids for each image; 00186 pyr_scale=0.5 means a classical pyramid, where each next layer is twice smaller than the previous 00187 one. 00188 @param levels number of pyramid layers including the initial image; levels=1 means that no extra 00189 layers are created and only the original images are used. 00190 @param winsize averaging window size; larger values increase the algorithm robustness to image 00191 noise and give more chances for fast motion detection, but yield more blurred motion field. 00192 @param iterations number of iterations the algorithm does at each pyramid level. 00193 @param poly_n size of the pixel neighborhood used to find polynomial expansion in each pixel; 00194 larger values mean that the image will be approximated with smoother surfaces, yielding more 00195 robust algorithm and more blurred motion field, typically poly_n =5 or 7. 00196 @param poly_sigma standard deviation of the Gaussian that is used to smooth derivatives used as a 00197 basis for the polynomial expansion; for poly_n=5, you can set poly_sigma=1.1, for poly_n=7, a 00198 good value would be poly_sigma=1.5. 00199 @param flags operation flags that can be a combination of the following: 00200 - **OPTFLOW_USE_INITIAL_FLOW** uses the input flow as an initial flow approximation. 00201 - **OPTFLOW_FARNEBACK_GAUSSIAN** uses the Gaussian \f$\texttt{winsize}\times\texttt{winsize}\f$ 00202 filter instead of a box filter of the same size for optical flow estimation; usually, this 00203 option gives z more accurate flow than with a box filter, at the cost of lower speed; 00204 normally, winsize for a Gaussian window should be set to a larger value to achieve the same 00205 level of robustness. 00206 00207 The function finds an optical flow for each prev pixel using the @cite Farneback2003 algorithm so that 00208 00209 \f[\texttt{prev} (y,x) \sim \texttt{next} ( y + \texttt{flow} (y,x)[1], x + \texttt{flow} (y,x)[0])\f] 00210 00211 @note 00212 00213 - An example using the optical flow algorithm described by Gunnar Farneback can be found at 00214 opencv_source_code/samples/cpp/fback.cpp 00215 - (Python) An example using the optical flow algorithm described by Gunnar Farneback can be 00216 found at opencv_source_code/samples/python/opt_flow.py 00217 */ 00218 CV_EXPORTS_W void calcOpticalFlowFarneback( InputArray prev, InputArray next, InputOutputArray flow, 00219 double pyr_scale, int levels, int winsize, 00220 int iterations, int poly_n, double poly_sigma, 00221 int flags ); 00222 00223 /** @brief Computes an optimal affine transformation between two 2D point sets. 00224 00225 @param src First input 2D point set stored in std::vector or Mat, or an image stored in Mat. 00226 @param dst Second input 2D point set of the same size and the same type as A, or another image. 00227 @param fullAffine If true, the function finds an optimal affine transformation with no additional 00228 restrictions (6 degrees of freedom). Otherwise, the class of transformations to choose from is 00229 limited to combinations of translation, rotation, and uniform scaling (4 degrees of freedom). 00230 00231 The function finds an optimal affine transform *[A|b]* (a 2 x 3 floating-point matrix) that 00232 approximates best the affine transformation between: 00233 00234 * Two point sets 00235 * Two raster images. In this case, the function first finds some features in the src image and 00236 finds the corresponding features in dst image. After that, the problem is reduced to the first 00237 case. 00238 In case of point sets, the problem is formulated as follows: you need to find a 2x2 matrix *A* and 00239 2x1 vector *b* so that: 00240 00241 \f[[A^*|b^*] = arg \min _{[A|b]} \sum _i \| \texttt{dst}[i] - A { \texttt{src}[i]}^T - b \| ^2\f] 00242 where src[i] and dst[i] are the i-th points in src and dst, respectively 00243 \f$[A|b]\f$ can be either arbitrary (when fullAffine=true ) or have a form of 00244 \f[\begin{bmatrix} a_{11} & a_{12} & b_1 \\ -a_{12} & a_{11} & b_2 \end{bmatrix}\f] 00245 when fullAffine=false. 00246 00247 @sa 00248 estimateAffine2D, estimateAffinePartial2D, getAffineTransform, getPerspectiveTransform, findHomography 00249 */ 00250 CV_EXPORTS_W Mat estimateRigidTransform( InputArray src, InputArray dst, bool fullAffine ); 00251 00252 00253 enum 00254 { 00255 MOTION_TRANSLATION = 0, 00256 MOTION_EUCLIDEAN = 1, 00257 MOTION_AFFINE = 2, 00258 MOTION_HOMOGRAPHY = 3 00259 }; 00260 00261 /** @brief Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 . 00262 00263 @param templateImage single-channel template image; CV_8U or CV_32F array. 00264 @param inputImage single-channel input image which should be warped with the final warpMatrix in 00265 order to provide an image similar to templateImage, same type as temlateImage. 00266 @param warpMatrix floating-point \f$2\times 3\f$ or \f$3\times 3\f$ mapping matrix (warp). 00267 @param motionType parameter, specifying the type of motion: 00268 - **MOTION_TRANSLATION** sets a translational motion model; warpMatrix is \f$2\times 3\f$ with 00269 the first \f$2\times 2\f$ part being the unity matrix and the rest two parameters being 00270 estimated. 00271 - **MOTION_EUCLIDEAN** sets a Euclidean (rigid) transformation as motion model; three 00272 parameters are estimated; warpMatrix is \f$2\times 3\f$. 00273 - **MOTION_AFFINE** sets an affine motion model (DEFAULT); six parameters are estimated; 00274 warpMatrix is \f$2\times 3\f$. 00275 - **MOTION_HOMOGRAPHY** sets a homography as a motion model; eight parameters are 00276 estimated;\`warpMatrix\` is \f$3\times 3\f$. 00277 @param criteria parameter, specifying the termination criteria of the ECC algorithm; 00278 criteria.epsilon defines the threshold of the increment in the correlation coefficient between two 00279 iterations (a negative criteria.epsilon makes criteria.maxcount the only termination criterion). 00280 Default values are shown in the declaration above. 00281 @param inputMask An optional mask to indicate valid values of inputImage. 00282 00283 The function estimates the optimum transformation (warpMatrix) with respect to ECC criterion 00284 (@cite EP08), that is 00285 00286 \f[\texttt{warpMatrix} = \texttt{warpMatrix} = \arg\max_{W} \texttt{ECC}(\texttt{templateImage}(x,y),\texttt{inputImage}(x',y'))\f] 00287 00288 where 00289 00290 \f[\begin{bmatrix} x' \\ y' \end{bmatrix} = W \cdot \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}\f] 00291 00292 (the equation holds with homogeneous coordinates for homography). It returns the final enhanced 00293 correlation coefficient, that is the correlation coefficient between the template image and the 00294 final warped input image. When a \f$3\times 3\f$ matrix is given with motionType =0, 1 or 2, the third 00295 row is ignored. 00296 00297 Unlike findHomography and estimateRigidTransform, the function findTransformECC implements an 00298 area-based alignment that builds on intensity similarities. In essence, the function updates the 00299 initial transformation that roughly aligns the images. If this information is missing, the identity 00300 warp (unity matrix) should be given as input. Note that if images undergo strong 00301 displacements/rotations, an initial transformation that roughly aligns the images is necessary 00302 (e.g., a simple euclidean/similarity transform that allows for the images showing the same image 00303 content approximately). Use inverse warping in the second image to take an image close to the first 00304 one, i.e. use the flag WARP_INVERSE_MAP with warpAffine or warpPerspective. See also the OpenCV 00305 sample image_alignment.cpp that demonstrates the use of the function. Note that the function throws 00306 an exception if algorithm does not converges. 00307 00308 @sa 00309 estimateAffine2D, estimateAffinePartial2D, findHomography 00310 */ 00311 CV_EXPORTS_W double findTransformECC( InputArray templateImage, InputArray inputImage, 00312 InputOutputArray warpMatrix, int motionType = MOTION_AFFINE, 00313 TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001), 00314 InputArray inputMask = noArray()); 00315 00316 /** @brief Kalman filter class. 00317 00318 The class implements a standard Kalman filter <http://en.wikipedia.org/wiki/Kalman_filter>, 00319 @cite Welch95 . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get 00320 an extended Kalman filter functionality. See the OpenCV sample kalman.cpp. 00321 00322 @note 00323 00324 - An example using the standard Kalman filter can be found at 00325 opencv_source_code/samples/cpp/kalman.cpp 00326 */ 00327 class CV_EXPORTS_W KalmanFilter 00328 { 00329 public: 00330 /** @brief The constructors. 00331 00332 @note In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released 00333 with cvReleaseKalman(&kalmanFilter) 00334 */ 00335 CV_WRAP KalmanFilter(); 00336 /** @overload 00337 @param dynamParams Dimensionality of the state. 00338 @param measureParams Dimensionality of the measurement. 00339 @param controlParams Dimensionality of the control vector. 00340 @param type Type of the created matrices that should be CV_32F or CV_64F. 00341 */ 00342 CV_WRAP KalmanFilter( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); 00343 00344 /** @brief Re-initializes Kalman filter. The previous content is destroyed. 00345 00346 @param dynamParams Dimensionality of the state. 00347 @param measureParams Dimensionality of the measurement. 00348 @param controlParams Dimensionality of the control vector. 00349 @param type Type of the created matrices that should be CV_32F or CV_64F. 00350 */ 00351 void init( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); 00352 00353 /** @brief Computes a predicted state. 00354 00355 @param control The optional input control 00356 */ 00357 CV_WRAP const Mat& predict( const Mat& control = Mat() ); 00358 00359 /** @brief Updates the predicted state from the measurement. 00360 00361 @param measurement The measured system parameters 00362 */ 00363 CV_WRAP const Mat& correct( const Mat& measurement ); 00364 00365 CV_PROP_RW Mat statePre; //!< predicted state (x'(k)): x(k)=A*x(k-1)+B*u(k) 00366 CV_PROP_RW Mat statePost; //!< corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) 00367 CV_PROP_RW Mat transitionMatrix; //!< state transition matrix (A) 00368 CV_PROP_RW Mat controlMatrix; //!< control matrix (B) (not used if there is no control) 00369 CV_PROP_RW Mat measurementMatrix; //!< measurement matrix (H) 00370 CV_PROP_RW Mat processNoiseCov; //!< process noise covariance matrix (Q) 00371 CV_PROP_RW Mat measurementNoiseCov;//!< measurement noise covariance matrix (R) 00372 CV_PROP_RW Mat errorCovPre; //!< priori error estimate covariance matrix (P'(k)): P'(k)=A*P(k-1)*At + Q)*/ 00373 CV_PROP_RW Mat gain; //!< Kalman gain matrix (K(k)): K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R) 00374 CV_PROP_RW Mat errorCovPost; //!< posteriori error estimate covariance matrix (P(k)): P(k)=(I-K(k)*H)*P'(k) 00375 00376 // temporary matrices 00377 Mat temp1; 00378 Mat temp2; 00379 Mat temp3; 00380 Mat temp4; 00381 Mat temp5; 00382 }; 00383 00384 00385 class CV_EXPORTS_W DenseOpticalFlow : public Algorithm 00386 { 00387 public: 00388 /** @brief Calculates an optical flow. 00389 00390 @param I0 first 8-bit single-channel input image. 00391 @param I1 second input image of the same size and the same type as prev. 00392 @param flow computed flow image that has the same size as prev and type CV_32FC2. 00393 */ 00394 CV_WRAP virtual void calc( InputArray I0, InputArray I1, InputOutputArray flow ) = 0; 00395 /** @brief Releases all inner buffers. 00396 */ 00397 CV_WRAP virtual void collectGarbage() = 0; 00398 }; 00399 00400 /** @brief Base interface for sparse optical flow algorithms. 00401 */ 00402 class CV_EXPORTS_W SparseOpticalFlow : public Algorithm 00403 { 00404 public: 00405 /** @brief Calculates a sparse optical flow. 00406 00407 @param prevImg First input image. 00408 @param nextImg Second input image of the same size and the same type as prevImg. 00409 @param prevPts Vector of 2D points for which the flow needs to be found. 00410 @param nextPts Output vector of 2D points containing the calculated new positions of input features in the second image. 00411 @param status Output status vector. Each element of the vector is set to 1 if the 00412 flow for the corresponding features has been found. Otherwise, it is set to 0. 00413 @param err Optional output vector that contains error response for each point (inverse confidence). 00414 */ 00415 CV_WRAP virtual void calc(InputArray prevImg, InputArray nextImg, 00416 InputArray prevPts, InputOutputArray nextPts, 00417 OutputArray status, 00418 OutputArray err = cv::noArray()) = 0; 00419 }; 00420 00421 /** @brief "Dual TV L1" Optical Flow Algorithm. 00422 00423 The class implements the "Dual TV L1" optical flow algorithm described in @cite Zach2007 and 00424 @cite Javier2012 . 00425 Here are important members of the class that control the algorithm, which you can set after 00426 constructing the class instance: 00427 00428 - member double tau 00429 Time step of the numerical scheme. 00430 00431 - member double lambda 00432 Weight parameter for the data term, attachment parameter. This is the most relevant 00433 parameter, which determines the smoothness of the output. The smaller this parameter is, 00434 the smoother the solutions we obtain. It depends on the range of motions of the images, so 00435 its value should be adapted to each image sequence. 00436 00437 - member double theta 00438 Weight parameter for (u - v)\^2, tightness parameter. It serves as a link between the 00439 attachment and the regularization terms. In theory, it should have a small value in order 00440 to maintain both parts in correspondence. The method is stable for a large range of values 00441 of this parameter. 00442 00443 - member int nscales 00444 Number of scales used to create the pyramid of images. 00445 00446 - member int warps 00447 Number of warpings per scale. Represents the number of times that I1(x+u0) and grad( 00448 I1(x+u0) ) are computed per scale. This is a parameter that assures the stability of the 00449 method. It also affects the running time, so it is a compromise between speed and 00450 accuracy. 00451 00452 - member double epsilon 00453 Stopping criterion threshold used in the numerical scheme, which is a trade-off between 00454 precision and running time. A small value will yield more accurate solutions at the 00455 expense of a slower convergence. 00456 00457 - member int iterations 00458 Stopping criterion iterations number used in the numerical scheme. 00459 00460 C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow". 00461 Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation". 00462 */ 00463 class CV_EXPORTS_W DualTVL1OpticalFlow : public DenseOpticalFlow 00464 { 00465 public: 00466 //! @brief Time step of the numerical scheme 00467 /** @see setTau */ 00468 CV_WRAP virtual double getTau() const = 0; 00469 /** @copybrief getTau @see getTau */ 00470 CV_WRAP virtual void setTau(double val) = 0; 00471 //! @brief Weight parameter for the data term, attachment parameter 00472 /** @see setLambda */ 00473 CV_WRAP virtual double getLambda() const = 0; 00474 /** @copybrief getLambda @see getLambda */ 00475 CV_WRAP virtual void setLambda(double val) = 0; 00476 //! @brief Weight parameter for (u - v)^2, tightness parameter 00477 /** @see setTheta */ 00478 CV_WRAP virtual double getTheta() const = 0; 00479 /** @copybrief getTheta @see getTheta */ 00480 CV_WRAP virtual void setTheta(double val) = 0; 00481 //! @brief coefficient for additional illumination variation term 00482 /** @see setGamma */ 00483 CV_WRAP virtual double getGamma() const = 0; 00484 /** @copybrief getGamma @see getGamma */ 00485 CV_WRAP virtual void setGamma(double val) = 0; 00486 //! @brief Number of scales used to create the pyramid of images 00487 /** @see setScalesNumber */ 00488 CV_WRAP virtual int getScalesNumber() const = 0; 00489 /** @copybrief getScalesNumber @see getScalesNumber */ 00490 CV_WRAP virtual void setScalesNumber(int val) = 0; 00491 //! @brief Number of warpings per scale 00492 /** @see setWarpingsNumber */ 00493 CV_WRAP virtual int getWarpingsNumber() const = 0; 00494 /** @copybrief getWarpingsNumber @see getWarpingsNumber */ 00495 CV_WRAP virtual void setWarpingsNumber(int val) = 0; 00496 //! @brief Stopping criterion threshold used in the numerical scheme, which is a trade-off between precision and running time 00497 /** @see setEpsilon */ 00498 CV_WRAP virtual double getEpsilon() const = 0; 00499 /** @copybrief getEpsilon @see getEpsilon */ 00500 CV_WRAP virtual void setEpsilon(double val) = 0; 00501 //! @brief Inner iterations (between outlier filtering) used in the numerical scheme 00502 /** @see setInnerIterations */ 00503 CV_WRAP virtual int getInnerIterations() const = 0; 00504 /** @copybrief getInnerIterations @see getInnerIterations */ 00505 CV_WRAP virtual void setInnerIterations(int val) = 0; 00506 //! @brief Outer iterations (number of inner loops) used in the numerical scheme 00507 /** @see setOuterIterations */ 00508 CV_WRAP virtual int getOuterIterations() const = 0; 00509 /** @copybrief getOuterIterations @see getOuterIterations */ 00510 CV_WRAP virtual void setOuterIterations(int val) = 0; 00511 //! @brief Use initial flow 00512 /** @see setUseInitialFlow */ 00513 CV_WRAP virtual bool getUseInitialFlow() const = 0; 00514 /** @copybrief getUseInitialFlow @see getUseInitialFlow */ 00515 CV_WRAP virtual void setUseInitialFlow(bool val) = 0; 00516 //! @brief Step between scales (<1) 00517 /** @see setScaleStep */ 00518 CV_WRAP virtual double getScaleStep() const = 0; 00519 /** @copybrief getScaleStep @see getScaleStep */ 00520 CV_WRAP virtual void setScaleStep(double val) = 0; 00521 //! @brief Median filter kernel size (1 = no filter) (3 or 5) 00522 /** @see setMedianFiltering */ 00523 CV_WRAP virtual int getMedianFiltering() const = 0; 00524 /** @copybrief getMedianFiltering @see getMedianFiltering */ 00525 CV_WRAP virtual void setMedianFiltering(int val) = 0; 00526 00527 /** @brief Creates instance of cv::DualTVL1OpticalFlow*/ 00528 CV_WRAP static Ptr<DualTVL1OpticalFlow> create( 00529 double tau = 0.25, 00530 double lambda = 0.15, 00531 double theta = 0.3, 00532 int nscales = 5, 00533 int warps = 5, 00534 double epsilon = 0.01, 00535 int innnerIterations = 30, 00536 int outerIterations = 10, 00537 double scaleStep = 0.8, 00538 double gamma = 0.0, 00539 int medianFiltering = 5, 00540 bool useInitialFlow = false); 00541 }; 00542 00543 /** @brief Creates instance of cv::DenseOpticalFlow 00544 */ 00545 CV_EXPORTS_W Ptr<DualTVL1OpticalFlow> createOptFlow_DualTVL1(); 00546 00547 /** @brief Class computing a dense optical flow using the Gunnar Farneback’s algorithm. 00548 */ 00549 class CV_EXPORTS_W FarnebackOpticalFlow : public DenseOpticalFlow 00550 { 00551 public: 00552 CV_WRAP virtual int getNumLevels() const = 0; 00553 CV_WRAP virtual void setNumLevels(int numLevels) = 0; 00554 00555 CV_WRAP virtual double getPyrScale() const = 0; 00556 CV_WRAP virtual void setPyrScale(double pyrScale) = 0; 00557 00558 CV_WRAP virtual bool getFastPyramids() const = 0; 00559 CV_WRAP virtual void setFastPyramids(bool fastPyramids) = 0; 00560 00561 CV_WRAP virtual int getWinSize() const = 0; 00562 CV_WRAP virtual void setWinSize(int winSize) = 0; 00563 00564 CV_WRAP virtual int getNumIters() const = 0; 00565 CV_WRAP virtual void setNumIters(int numIters) = 0; 00566 00567 CV_WRAP virtual int getPolyN() const = 0; 00568 CV_WRAP virtual void setPolyN(int polyN) = 0; 00569 00570 CV_WRAP virtual double getPolySigma() const = 0; 00571 CV_WRAP virtual void setPolySigma(double polySigma) = 0; 00572 00573 CV_WRAP virtual int getFlags() const = 0; 00574 CV_WRAP virtual void setFlags(int flags) = 0; 00575 00576 CV_WRAP static Ptr<FarnebackOpticalFlow> create( 00577 int numLevels = 5, 00578 double pyrScale = 0.5, 00579 bool fastPyramids = false, 00580 int winSize = 13, 00581 int numIters = 10, 00582 int polyN = 5, 00583 double polySigma = 1.1, 00584 int flags = 0); 00585 }; 00586 00587 00588 /** @brief Class used for calculating a sparse optical flow. 00589 00590 The class can calculate an optical flow for a sparse feature set using the 00591 iterative Lucas-Kanade method with pyramids. 00592 00593 @sa calcOpticalFlowPyrLK 00594 00595 */ 00596 class CV_EXPORTS_W SparsePyrLKOpticalFlow : public SparseOpticalFlow 00597 { 00598 public: 00599 CV_WRAP virtual Size getWinSize() const = 0; 00600 CV_WRAP virtual void setWinSize(Size winSize) = 0; 00601 00602 CV_WRAP virtual int getMaxLevel() const = 0; 00603 CV_WRAP virtual void setMaxLevel(int maxLevel) = 0; 00604 00605 CV_WRAP virtual TermCriteria getTermCriteria() const = 0; 00606 CV_WRAP virtual void setTermCriteria(TermCriteria& crit) = 0; 00607 00608 CV_WRAP virtual int getFlags() const = 0; 00609 CV_WRAP virtual void setFlags(int flags) = 0; 00610 00611 CV_WRAP virtual double getMinEigThreshold() const = 0; 00612 CV_WRAP virtual void setMinEigThreshold(double minEigThreshold) = 0; 00613 00614 CV_WRAP static Ptr<SparsePyrLKOpticalFlow> create( 00615 Size winSize = Size(21, 21), 00616 int maxLevel = 3, TermCriteria crit = 00617 TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), 00618 int flags = 0, 00619 double minEigThreshold = 1e-4); 00620 }; 00621 00622 //! @} video_track 00623 00624 } // cv 00625 00626 #endif
Generated on Tue Jul 12 2022 18:20:19 by
