1 | /*M/////////////////////////////////////////////////////////////////////////////////////// |
2 | // |
3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. |
4 | // |
5 | // By downloading, copying, installing or using the software you agree to this license. |
6 | // If you do not agree to this license, do not download, install, |
7 | // copy or use the software. |
8 | // |
9 | // |
10 | // License Agreement |
11 | // For Open Source Computer Vision Library |
12 | // |
13 | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. |
14 | // Copyright (C) 2009, Willow Garage Inc., all rights reserved. |
15 | // Copyright (C) 2013, OpenCV Foundation, all rights reserved. |
16 | // Third party copyrights are property of their respective owners. |
17 | // |
18 | // Redistribution and use in source and binary forms, with or without modification, |
19 | // are permitted provided that the following conditions are met: |
20 | // |
21 | // * Redistribution's of source code must retain the above copyright notice, |
22 | // this list of conditions and the following disclaimer. |
23 | // |
24 | // * Redistribution's in binary form must reproduce the above copyright notice, |
25 | // this list of conditions and the following disclaimer in the documentation |
26 | // and/or other materials provided with the distribution. |
27 | // |
28 | // * The name of the copyright holders may not be used to endorse or promote products |
29 | // derived from this software without specific prior written permission. |
30 | // |
31 | // This software is provided by the copyright holders and contributors "as is" and |
32 | // any express or implied warranties, including, but not limited to, the implied |
33 | // warranties of merchantability and fitness for a particular purpose are disclaimed. |
34 | // In no event shall the Intel Corporation or contributors be liable for any direct, |
35 | // indirect, incidental, special, exemplary, or consequential damages |
36 | // (including, but not limited to, procurement of substitute goods or services; |
37 | // loss of use, data, or profits; or business interruption) however caused |
38 | // and on any theory of liability, whether in contract, strict liability, |
39 | // or tort (including negligence or otherwise) arising in any way out of |
40 | // the use of this software, even if advised of the possibility of such damage. |
41 | // |
42 | //M*/ |
43 | |
44 | #ifndef OPENCV_TRACKING_HPP |
45 | #define OPENCV_TRACKING_HPP |
46 | |
47 | #include "opencv2/core.hpp" |
48 | #include "opencv2/imgproc.hpp" |
49 | |
50 | namespace cv |
51 | { |
52 | |
53 | //! @addtogroup video_track |
54 | //! @{ |
55 | |
56 | enum { OPTFLOW_USE_INITIAL_FLOW = 4, |
57 | OPTFLOW_LK_GET_MIN_EIGENVALS = 8, |
58 | OPTFLOW_FARNEBACK_GAUSSIAN = 256 |
59 | }; |
60 | |
61 | /** @brief Finds an object center, size, and orientation. |
62 | |
63 | @param probImage Back projection of the object histogram. See calcBackProject. |
64 | @param window Initial search window. |
65 | @param criteria Stop criteria for the underlying meanShift. |
66 | returns |
67 | (in old interfaces) Number of iterations CAMSHIFT took to converge |
68 | The function implements the CAMSHIFT object tracking algorithm @cite Bradski98 . First, it finds an |
69 | object center using meanShift and then adjusts the window size and finds the optimal rotation. The |
70 | function returns the rotated rectangle structure that includes the object position, size, and |
71 | orientation. The next position of the search window can be obtained with RotatedRect::boundingRect() |
72 | |
73 | See the OpenCV sample camshiftdemo.c that tracks colored objects. |
74 | |
75 | @note |
76 | - (Python) A sample explaining the camshift tracking algorithm can be found at |
77 | opencv_source_code/samples/python/camshift.py |
78 | */ |
79 | CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_IN_OUT Rect& window, |
80 | TermCriteria criteria ); |
81 | /** @example samples/cpp/camshiftdemo.cpp |
82 | An example using the mean-shift tracking algorithm |
83 | */ |
84 | |
85 | /** @brief Finds an object on a back projection image. |
86 | |
87 | @param probImage Back projection of the object histogram. See calcBackProject for details. |
88 | @param window Initial search window. |
89 | @param criteria Stop criteria for the iterative search algorithm. |
90 | returns |
91 | : Number of iterations CAMSHIFT took to converge. |
92 | The function implements the iterative object search algorithm. It takes the input back projection of |
93 | an object and the initial position. The mass center in window of the back projection image is |
94 | computed and the search window center shifts to the mass center. The procedure is repeated until the |
95 | specified number of iterations criteria.maxCount is done or until the window center shifts by less |
96 | than criteria.epsilon. The algorithm is used inside CamShift and, unlike CamShift , the search |
97 | window size or orientation do not change during the search. You can simply pass the output of |
98 | calcBackProject to this function. But better results can be obtained if you pre-filter the back |
99 | projection and remove the noise. For example, you can do this by retrieving connected components |
100 | with findContours , throwing away contours with small area ( contourArea ), and rendering the |
101 | remaining contours with drawContours. |
102 | |
103 | */ |
104 | CV_EXPORTS_W int meanShift( InputArray probImage, CV_IN_OUT Rect& window, TermCriteria criteria ); |
105 | |
106 | /** @brief Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK. |
107 | |
108 | @param img 8-bit input image. |
109 | @param pyramid output pyramid. |
110 | @param winSize window size of optical flow algorithm. Must be not less than winSize argument of |
111 | calcOpticalFlowPyrLK. It is needed to calculate required padding for pyramid levels. |
112 | @param maxLevel 0-based maximal pyramid level number. |
113 | @param withDerivatives set to precompute gradients for the every pyramid level. If pyramid is |
114 | constructed without the gradients then calcOpticalFlowPyrLK will calculate them internally. |
115 | @param pyrBorder the border mode for pyramid layers. |
116 | @param derivBorder the border mode for gradients. |
117 | @param tryReuseInputImage put ROI of input image into the pyramid if possible. You can pass false |
118 | to force data copying. |
119 | @return number of levels in constructed pyramid. Can be less than maxLevel. |
120 | */ |
121 | CV_EXPORTS_W int buildOpticalFlowPyramid( InputArray img, OutputArrayOfArrays pyramid, |
122 | Size winSize, int maxLevel, bool withDerivatives = true, |
123 | int pyrBorder = BORDER_REFLECT_101, |
124 | int derivBorder = BORDER_CONSTANT, |
125 | bool tryReuseInputImage = true ); |
126 | |
127 | /** @example samples/cpp/lkdemo.cpp |
128 | An example using the Lucas-Kanade optical flow algorithm |
129 | */ |
130 | |
131 | /** @brief Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with |
132 | pyramids. |
133 | |
134 | @param prevImg first 8-bit input image or pyramid constructed by buildOpticalFlowPyramid. |
135 | @param nextImg second input image or pyramid of the same size and the same type as prevImg. |
136 | @param prevPts vector of 2D points for which the flow needs to be found; point coordinates must be |
137 | single-precision floating-point numbers. |
138 | @param nextPts output vector of 2D points (with single-precision floating-point coordinates) |
139 | containing the calculated new positions of input features in the second image; when |
140 | OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input. |
141 | @param status output status vector (of unsigned chars); each element of the vector is set to 1 if |
142 | the flow for the corresponding features has been found, otherwise, it is set to 0. |
143 | @param err output vector of errors; each element of the vector is set to an error for the |
144 | corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't |
145 | found then the error is not defined (use the status parameter to find such cases). |
146 | @param winSize size of the search window at each pyramid level. |
147 | @param maxLevel 0-based maximal pyramid level number; if set to 0, pyramids are not used (single |
148 | level), if set to 1, two levels are used, and so on; if pyramids are passed to input then |
149 | algorithm will use as many levels as pyramids have but no more than maxLevel. |
150 | @param criteria parameter, specifying the termination criteria of the iterative search algorithm |
151 | (after the specified maximum number of iterations criteria.maxCount or when the search window |
152 | moves by less than criteria.epsilon. |
153 | @param flags operation flags: |
154 | - **OPTFLOW_USE_INITIAL_FLOW** uses initial estimations, stored in nextPts; if the flag is |
155 | not set, then prevPts is copied to nextPts and is considered the initial estimate. |
156 | - **OPTFLOW_LK_GET_MIN_EIGENVALS** use minimum eigen values as an error measure (see |
157 | minEigThreshold description); if the flag is not set, then L1 distance between patches |
158 | around the original and a moved point, divided by number of pixels in a window, is used as a |
159 | error measure. |
160 | @param minEigThreshold the algorithm calculates the minimum eigen value of a 2x2 normal matrix of |
161 | optical flow equations (this matrix is called a spatial gradient matrix in @cite Bouguet00), divided |
162 | by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding |
163 | feature is filtered out and its flow is not processed, so it allows to remove bad points and get a |
164 | performance boost. |
165 | |
166 | The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See |
167 | @cite Bouguet00 . The function is parallelized with the TBB library. |
168 | |
169 | @note Some examples: |
170 | |
171 | - An example using the Lucas-Kanade optical flow algorithm can be found at |
172 | opencv_source_code/samples/cpp/lkdemo.cpp |
173 | - (Python) An example using the Lucas-Kanade optical flow algorithm can be found at |
174 | opencv_source_code/samples/python/lk_track.py |
175 | - (Python) An example using the Lucas-Kanade tracker for homography matching can be found at |
176 | opencv_source_code/samples/python/lk_homography.py |
177 | */ |
178 | CV_EXPORTS_W void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg, |
179 | InputArray prevPts, InputOutputArray nextPts, |
180 | OutputArray status, OutputArray err, |
181 | Size winSize = Size(21,21), int maxLevel = 3, |
182 | TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), |
183 | int flags = 0, double minEigThreshold = 1e-4 ); |
184 | |
185 | /** @brief Computes a dense optical flow using the Gunnar Farneback's algorithm. |
186 | |
187 | @param prev first 8-bit single-channel input image. |
188 | @param next second input image of the same size and the same type as prev. |
189 | @param flow computed flow image that has the same size as prev and type CV_32FC2. |
190 | @param pyr_scale parameter, specifying the image scale (\<1) to build pyramids for each image; |
191 | pyr_scale=0.5 means a classical pyramid, where each next layer is twice smaller than the previous |
192 | one. |
193 | @param levels number of pyramid layers including the initial image; levels=1 means that no extra |
194 | layers are created and only the original images are used. |
195 | @param winsize averaging window size; larger values increase the algorithm robustness to image |
196 | noise and give more chances for fast motion detection, but yield more blurred motion field. |
197 | @param iterations number of iterations the algorithm does at each pyramid level. |
198 | @param poly_n size of the pixel neighborhood used to find polynomial expansion in each pixel; |
199 | larger values mean that the image will be approximated with smoother surfaces, yielding more |
200 | robust algorithm and more blurred motion field, typically poly_n =5 or 7. |
201 | @param poly_sigma standard deviation of the Gaussian that is used to smooth derivatives used as a |
202 | basis for the polynomial expansion; for poly_n=5, you can set poly_sigma=1.1, for poly_n=7, a |
203 | good value would be poly_sigma=1.5. |
204 | @param flags operation flags that can be a combination of the following: |
205 | - **OPTFLOW_USE_INITIAL_FLOW** uses the input flow as an initial flow approximation. |
206 | - **OPTFLOW_FARNEBACK_GAUSSIAN** uses the Gaussian \f$\texttt{winsize}\times\texttt{winsize}\f$ |
207 | filter instead of a box filter of the same size for optical flow estimation; usually, this |
208 | option gives z more accurate flow than with a box filter, at the cost of lower speed; |
209 | normally, winsize for a Gaussian window should be set to a larger value to achieve the same |
210 | level of robustness. |
211 | |
212 | The function finds an optical flow for each prev pixel using the @cite Farneback2003 algorithm so that |
213 | |
214 | \f[\texttt{prev} (y,x) \sim \texttt{next} ( y + \texttt{flow} (y,x)[1], x + \texttt{flow} (y,x)[0])\f] |
215 | |
216 | @note Some examples: |
217 | |
218 | - An example using the optical flow algorithm described by Gunnar Farneback can be found at |
219 | opencv_source_code/samples/cpp/fback.cpp |
220 | - (Python) An example using the optical flow algorithm described by Gunnar Farneback can be |
221 | found at opencv_source_code/samples/python/opt_flow.py |
222 | */ |
223 | CV_EXPORTS_W void calcOpticalFlowFarneback( InputArray prev, InputArray next, InputOutputArray flow, |
224 | double pyr_scale, int levels, int winsize, |
225 | int iterations, int poly_n, double poly_sigma, |
226 | int flags ); |
227 | |
228 | /** @brief Computes an optimal affine transformation between two 2D point sets. |
229 | |
230 | @param src First input 2D point set stored in std::vector or Mat, or an image stored in Mat. |
231 | @param dst Second input 2D point set of the same size and the same type as A, or another image. |
232 | @param fullAffine If true, the function finds an optimal affine transformation with no additional |
233 | restrictions (6 degrees of freedom). Otherwise, the class of transformations to choose from is |
234 | limited to combinations of translation, rotation, and uniform scaling (4 degrees of freedom). |
235 | |
236 | The function finds an optimal affine transform *[A|b]* (a 2 x 3 floating-point matrix) that |
237 | approximates best the affine transformation between: |
238 | |
239 | * Two point sets |
240 | * Two raster images. In this case, the function first finds some features in the src image and |
241 | finds the corresponding features in dst image. After that, the problem is reduced to the first |
242 | case. |
243 | In case of point sets, the problem is formulated as follows: you need to find a 2x2 matrix *A* and |
244 | 2x1 vector *b* so that: |
245 | |
246 | \f[[A^*|b^*] = arg \min _{[A|b]} \sum _i \| \texttt{dst}[i] - A { \texttt{src}[i]}^T - b \| ^2\f] |
247 | where src[i] and dst[i] are the i-th points in src and dst, respectively |
248 | \f$[A|b]\f$ can be either arbitrary (when fullAffine=true ) or have a form of |
249 | \f[\begin{bmatrix} a_{11} & a_{12} & b_1 \\ -a_{12} & a_{11} & b_2 \end{bmatrix}\f] |
250 | when fullAffine=false. |
251 | |
252 | @deprecated Use cv::estimateAffine2D, cv::estimateAffinePartial2D instead. If you are using this function |
253 | with images, extract points using cv::calcOpticalFlowPyrLK and then use the estimation functions. |
254 | |
255 | @sa |
256 | estimateAffine2D, estimateAffinePartial2D, getAffineTransform, getPerspectiveTransform, findHomography |
257 | */ |
258 | CV_DEPRECATED CV_EXPORTS Mat estimateRigidTransform( InputArray src, InputArray dst, bool fullAffine ); |
259 | |
260 | enum |
261 | { |
262 | MOTION_TRANSLATION = 0, |
263 | MOTION_EUCLIDEAN = 1, |
264 | MOTION_AFFINE = 2, |
265 | MOTION_HOMOGRAPHY = 3 |
266 | }; |
267 | |
268 | /** @brief Computes the Enhanced Correlation Coefficient value between two images @cite EP08 . |
269 | |
270 | @param templateImage single-channel template image; CV_8U or CV_32F array. |
271 | @param inputImage single-channel input image to be warped to provide an image similar to |
272 | templateImage, same type as templateImage. |
273 | @param inputMask An optional mask to indicate valid values of inputImage. |
274 | |
275 | @sa |
276 | findTransformECC |
277 | */ |
278 | |
279 | CV_EXPORTS_W double computeECC(InputArray templateImage, InputArray inputImage, InputArray inputMask = noArray()); |
280 | |
281 | /** @example samples/cpp/image_alignment.cpp |
282 | An example using the image alignment ECC algorithm |
283 | */ |
284 | |
285 | /** @brief Finds the geometric transform (warp) between two images in terms of the ECC criterion @cite EP08 . |
286 | |
287 | @param templateImage single-channel template image; CV_8U or CV_32F array. |
288 | @param inputImage single-channel input image which should be warped with the final warpMatrix in |
289 | order to provide an image similar to templateImage, same type as templateImage. |
290 | @param warpMatrix floating-point \f$2\times 3\f$ or \f$3\times 3\f$ mapping matrix (warp). |
291 | @param motionType parameter, specifying the type of motion: |
292 | - **MOTION_TRANSLATION** sets a translational motion model; warpMatrix is \f$2\times 3\f$ with |
293 | the first \f$2\times 2\f$ part being the unity matrix and the rest two parameters being |
294 | estimated. |
295 | - **MOTION_EUCLIDEAN** sets a Euclidean (rigid) transformation as motion model; three |
296 | parameters are estimated; warpMatrix is \f$2\times 3\f$. |
297 | - **MOTION_AFFINE** sets an affine motion model (DEFAULT); six parameters are estimated; |
298 | warpMatrix is \f$2\times 3\f$. |
299 | - **MOTION_HOMOGRAPHY** sets a homography as a motion model; eight parameters are |
300 | estimated;\`warpMatrix\` is \f$3\times 3\f$. |
301 | @param criteria parameter, specifying the termination criteria of the ECC algorithm; |
302 | criteria.epsilon defines the threshold of the increment in the correlation coefficient between two |
303 | iterations (a negative criteria.epsilon makes criteria.maxcount the only termination criterion). |
304 | Default values are shown in the declaration above. |
305 | @param inputMask An optional mask to indicate valid values of inputImage. |
306 | @param gaussFiltSize An optional value indicating size of gaussian blur filter; (DEFAULT: 5) |
307 | |
308 | The function estimates the optimum transformation (warpMatrix) with respect to ECC criterion |
309 | (@cite EP08), that is |
310 | |
311 | \f[\texttt{warpMatrix} = \arg\max_{W} \texttt{ECC}(\texttt{templateImage}(x,y),\texttt{inputImage}(x',y'))\f] |
312 | |
313 | where |
314 | |
315 | \f[\begin{bmatrix} x' \\ y' \end{bmatrix} = W \cdot \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}\f] |
316 | |
317 | (the equation holds with homogeneous coordinates for homography). It returns the final enhanced |
318 | correlation coefficient, that is the correlation coefficient between the template image and the |
319 | final warped input image. When a \f$3\times 3\f$ matrix is given with motionType =0, 1 or 2, the third |
320 | row is ignored. |
321 | |
322 | Unlike findHomography and estimateRigidTransform, the function findTransformECC implements an |
323 | area-based alignment that builds on intensity similarities. In essence, the function updates the |
324 | initial transformation that roughly aligns the images. If this information is missing, the identity |
325 | warp (unity matrix) is used as an initialization. Note that if images undergo strong |
326 | displacements/rotations, an initial transformation that roughly aligns the images is necessary |
327 | (e.g., a simple euclidean/similarity transform that allows for the images showing the same image |
328 | content approximately). Use inverse warping in the second image to take an image close to the first |
329 | one, i.e. use the flag WARP_INVERSE_MAP with warpAffine or warpPerspective. See also the OpenCV |
330 | sample image_alignment.cpp that demonstrates the use of the function. Note that the function throws |
331 | an exception if algorithm does not converges. |
332 | |
333 | @sa |
334 | computeECC, estimateAffine2D, estimateAffinePartial2D, findHomography |
335 | */ |
336 | CV_EXPORTS_W double findTransformECC( InputArray templateImage, InputArray inputImage, |
337 | InputOutputArray warpMatrix, int motionType, |
338 | TermCriteria criteria, |
339 | InputArray inputMask, int gaussFiltSize); |
340 | |
341 | /** @overload */ |
342 | CV_EXPORTS_W |
343 | double findTransformECC(InputArray templateImage, InputArray inputImage, |
344 | InputOutputArray warpMatrix, int motionType = MOTION_AFFINE, |
345 | TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001), |
346 | InputArray inputMask = noArray()); |
347 | |
348 | /** @example samples/cpp/kalman.cpp |
349 | An example using the standard Kalman filter |
350 | */ |
351 | |
352 | /** @brief Kalman filter class. |
353 | |
354 | The class implements a standard Kalman filter <http://en.wikipedia.org/wiki/Kalman_filter>, |
355 | @cite Welch95 . However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get |
356 | an extended Kalman filter functionality. |
357 | @note In C API when CvKalman\* kalmanFilter structure is not needed anymore, it should be released |
358 | with cvReleaseKalman(&kalmanFilter) |
359 | */ |
360 | class CV_EXPORTS_W KalmanFilter |
361 | { |
362 | public: |
363 | CV_WRAP KalmanFilter(); |
364 | /** @overload |
365 | @param dynamParams Dimensionality of the state. |
366 | @param measureParams Dimensionality of the measurement. |
367 | @param controlParams Dimensionality of the control vector. |
368 | @param type Type of the created matrices that should be CV_32F or CV_64F. |
369 | */ |
370 | CV_WRAP KalmanFilter( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); |
371 | |
372 | /** @brief Re-initializes Kalman filter. The previous content is destroyed. |
373 | |
374 | @param dynamParams Dimensionality of the state. |
375 | @param measureParams Dimensionality of the measurement. |
376 | @param controlParams Dimensionality of the control vector. |
377 | @param type Type of the created matrices that should be CV_32F or CV_64F. |
378 | */ |
379 | void init( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); |
380 | |
381 | /** @brief Computes a predicted state. |
382 | |
383 | @param control The optional input control |
384 | */ |
385 | CV_WRAP const Mat& predict( const Mat& control = Mat() ); |
386 | |
387 | /** @brief Updates the predicted state from the measurement. |
388 | |
389 | @param measurement The measured system parameters |
390 | */ |
391 | CV_WRAP const Mat& correct( const Mat& measurement ); |
392 | |
393 | CV_PROP_RW Mat statePre; //!< predicted state (x'(k)): x(k)=A*x(k-1)+B*u(k) |
394 | CV_PROP_RW Mat statePost; //!< corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) |
395 | CV_PROP_RW Mat transitionMatrix; //!< state transition matrix (A) |
396 | CV_PROP_RW Mat controlMatrix; //!< control matrix (B) (not used if there is no control) |
397 | CV_PROP_RW Mat measurementMatrix; //!< measurement matrix (H) |
398 | CV_PROP_RW Mat processNoiseCov; //!< process noise covariance matrix (Q) |
399 | CV_PROP_RW Mat measurementNoiseCov;//!< measurement noise covariance matrix (R) |
400 | CV_PROP_RW Mat errorCovPre; //!< priori error estimate covariance matrix (P'(k)): P'(k)=A*P(k-1)*At + Q)*/ |
401 | CV_PROP_RW Mat gain; //!< Kalman gain matrix (K(k)): K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R) |
402 | CV_PROP_RW Mat errorCovPost; //!< posteriori error estimate covariance matrix (P(k)): P(k)=(I-K(k)*H)*P'(k) |
403 | |
404 | // temporary matrices |
405 | Mat temp1; |
406 | Mat temp2; |
407 | Mat temp3; |
408 | Mat temp4; |
409 | Mat temp5; |
410 | }; |
411 | |
412 | |
413 | /** @brief Read a .flo file |
414 | |
415 | @param path Path to the file to be loaded |
416 | |
417 | The function readOpticalFlow loads a flow field from a file and returns it as a single matrix. |
418 | Resulting Mat has a type CV_32FC2 - floating-point, 2-channel. First channel corresponds to the |
419 | flow in the horizontal direction (u), second - vertical (v). |
420 | */ |
421 | CV_EXPORTS_W Mat readOpticalFlow( const String& path ); |
422 | /** @brief Write a .flo to disk |
423 | |
424 | @param path Path to the file to be written |
425 | @param flow Flow field to be stored |
426 | |
427 | The function stores a flow field in a file, returns true on success, false otherwise. |
428 | The flow field must be a 2-channel, floating-point matrix (CV_32FC2). First channel corresponds |
429 | to the flow in the horizontal direction (u), second - vertical (v). |
430 | */ |
431 | CV_EXPORTS_W bool writeOpticalFlow( const String& path, InputArray flow ); |
432 | |
433 | /** |
434 | Base class for dense optical flow algorithms |
435 | */ |
436 | class CV_EXPORTS_W DenseOpticalFlow : public Algorithm |
437 | { |
438 | public: |
439 | /** @brief Calculates an optical flow. |
440 | |
441 | @param I0 first 8-bit single-channel input image. |
442 | @param I1 second input image of the same size and the same type as prev. |
443 | @param flow computed flow image that has the same size as prev and type CV_32FC2. |
444 | */ |
445 | CV_WRAP virtual void calc( InputArray I0, InputArray I1, InputOutputArray flow ) = 0; |
446 | /** @brief Releases all inner buffers. |
447 | */ |
448 | CV_WRAP virtual void collectGarbage() = 0; |
449 | }; |
450 | |
451 | /** @brief Base interface for sparse optical flow algorithms. |
452 | */ |
453 | class CV_EXPORTS_W SparseOpticalFlow : public Algorithm |
454 | { |
455 | public: |
456 | /** @brief Calculates a sparse optical flow. |
457 | |
458 | @param prevImg First input image. |
459 | @param nextImg Second input image of the same size and the same type as prevImg. |
460 | @param prevPts Vector of 2D points for which the flow needs to be found. |
461 | @param nextPts Output vector of 2D points containing the calculated new positions of input features in the second image. |
462 | @param status Output status vector. Each element of the vector is set to 1 if the |
463 | flow for the corresponding features has been found. Otherwise, it is set to 0. |
464 | @param err Optional output vector that contains error response for each point (inverse confidence). |
465 | */ |
466 | CV_WRAP virtual void calc(InputArray prevImg, InputArray nextImg, |
467 | InputArray prevPts, InputOutputArray nextPts, |
468 | OutputArray status, |
469 | OutputArray err = cv::noArray()) = 0; |
470 | }; |
471 | |
472 | |
473 | /** @brief Class computing a dense optical flow using the Gunnar Farneback's algorithm. |
474 | */ |
475 | class CV_EXPORTS_W FarnebackOpticalFlow : public DenseOpticalFlow |
476 | { |
477 | public: |
478 | CV_WRAP virtual int getNumLevels() const = 0; |
479 | CV_WRAP virtual void setNumLevels(int numLevels) = 0; |
480 | |
481 | CV_WRAP virtual double getPyrScale() const = 0; |
482 | CV_WRAP virtual void setPyrScale(double pyrScale) = 0; |
483 | |
484 | CV_WRAP virtual bool getFastPyramids() const = 0; |
485 | CV_WRAP virtual void setFastPyramids(bool fastPyramids) = 0; |
486 | |
487 | CV_WRAP virtual int getWinSize() const = 0; |
488 | CV_WRAP virtual void setWinSize(int winSize) = 0; |
489 | |
490 | CV_WRAP virtual int getNumIters() const = 0; |
491 | CV_WRAP virtual void setNumIters(int numIters) = 0; |
492 | |
493 | CV_WRAP virtual int getPolyN() const = 0; |
494 | CV_WRAP virtual void setPolyN(int polyN) = 0; |
495 | |
496 | CV_WRAP virtual double getPolySigma() const = 0; |
497 | CV_WRAP virtual void setPolySigma(double polySigma) = 0; |
498 | |
499 | CV_WRAP virtual int getFlags() const = 0; |
500 | CV_WRAP virtual void setFlags(int flags) = 0; |
501 | |
502 | CV_WRAP static Ptr<FarnebackOpticalFlow> create( |
503 | int numLevels = 5, |
504 | double pyrScale = 0.5, |
505 | bool fastPyramids = false, |
506 | int winSize = 13, |
507 | int numIters = 10, |
508 | int polyN = 5, |
509 | double polySigma = 1.1, |
510 | int flags = 0); |
511 | }; |
512 | |
513 | /** @brief Variational optical flow refinement |
514 | |
515 | This class implements variational refinement of the input flow field, i.e. |
516 | it uses input flow to initialize the minimization of the following functional: |
517 | \f$E(U) = \int_{\Omega} \delta \Psi(E_I) + \gamma \Psi(E_G) + \alpha \Psi(E_S) \f$, |
518 | where \f$E_I,E_G,E_S\f$ are color constancy, gradient constancy and smoothness terms |
519 | respectively. \f$\Psi(s^2)=\sqrt{s^2+\epsilon^2}\f$ is a robust penalizer to limit the |
520 | influence of outliers. A complete formulation and a description of the minimization |
521 | procedure can be found in @cite Brox2004 |
522 | */ |
523 | class CV_EXPORTS_W VariationalRefinement : public DenseOpticalFlow |
524 | { |
525 | public: |
526 | /** @brief @ref calc function overload to handle separate horizontal (u) and vertical (v) flow components |
527 | (to avoid extra splits/merges) */ |
528 | CV_WRAP virtual void calcUV(InputArray I0, InputArray I1, InputOutputArray flow_u, InputOutputArray flow_v) = 0; |
529 | |
530 | /** @brief Number of outer (fixed-point) iterations in the minimization procedure. |
531 | @see setFixedPointIterations */ |
532 | CV_WRAP virtual int getFixedPointIterations() const = 0; |
533 | /** @copybrief getFixedPointIterations @see getFixedPointIterations */ |
534 | CV_WRAP virtual void setFixedPointIterations(int val) = 0; |
535 | |
536 | /** @brief Number of inner successive over-relaxation (SOR) iterations |
537 | in the minimization procedure to solve the respective linear system. |
538 | @see setSorIterations */ |
539 | CV_WRAP virtual int getSorIterations() const = 0; |
540 | /** @copybrief getSorIterations @see getSorIterations */ |
541 | CV_WRAP virtual void setSorIterations(int val) = 0; |
542 | |
543 | /** @brief Relaxation factor in SOR |
544 | @see setOmega */ |
545 | CV_WRAP virtual float getOmega() const = 0; |
546 | /** @copybrief getOmega @see getOmega */ |
547 | CV_WRAP virtual void setOmega(float val) = 0; |
548 | |
549 | /** @brief Weight of the smoothness term |
550 | @see setAlpha */ |
551 | CV_WRAP virtual float getAlpha() const = 0; |
552 | /** @copybrief getAlpha @see getAlpha */ |
553 | CV_WRAP virtual void setAlpha(float val) = 0; |
554 | |
555 | /** @brief Weight of the color constancy term |
556 | @see setDelta */ |
557 | CV_WRAP virtual float getDelta() const = 0; |
558 | /** @copybrief getDelta @see getDelta */ |
559 | CV_WRAP virtual void setDelta(float val) = 0; |
560 | |
561 | /** @brief Weight of the gradient constancy term |
562 | @see setGamma */ |
563 | CV_WRAP virtual float getGamma() const = 0; |
564 | /** @copybrief getGamma @see getGamma */ |
565 | CV_WRAP virtual void setGamma(float val) = 0; |
566 | |
567 | /** @brief Norm value shift for robust penalizer |
568 | @see setEpsilon */ |
569 | CV_WRAP virtual float getEpsilon() const = 0; |
570 | /** @copybrief getEpsilon @see getEpsilon */ |
571 | CV_WRAP virtual void setEpsilon(float val) = 0; |
572 | |
573 | /** @brief Creates an instance of VariationalRefinement |
574 | */ |
575 | CV_WRAP static Ptr<VariationalRefinement> create(); |
576 | }; |
577 | |
578 | /** @brief DIS optical flow algorithm. |
579 | |
580 | This class implements the Dense Inverse Search (DIS) optical flow algorithm. More |
581 | details about the algorithm can be found at @cite Kroeger2016 . Includes three presets with preselected |
582 | parameters to provide reasonable trade-off between speed and quality. However, even the slowest preset is |
583 | still relatively fast, use DeepFlow if you need better quality and don't care about speed. |
584 | |
585 | This implementation includes several additional features compared to the algorithm described in the paper, |
586 | including spatial propagation of flow vectors (@ref getUseSpatialPropagation), as well as an option to |
587 | utilize an initial flow approximation passed to @ref calc (which is, essentially, temporal propagation, |
588 | if the previous frame's flow field is passed). |
589 | */ |
590 | class CV_EXPORTS_W DISOpticalFlow : public DenseOpticalFlow |
591 | { |
592 | public: |
593 | enum |
594 | { |
595 | PRESET_ULTRAFAST = 0, |
596 | PRESET_FAST = 1, |
597 | PRESET_MEDIUM = 2 |
598 | }; |
599 | |
600 | /** @brief Finest level of the Gaussian pyramid on which the flow is computed (zero level |
601 | corresponds to the original image resolution). The final flow is obtained by bilinear upscaling. |
602 | @see setFinestScale */ |
603 | CV_WRAP virtual int getFinestScale() const = 0; |
604 | /** @copybrief getFinestScale @see getFinestScale */ |
605 | CV_WRAP virtual void setFinestScale(int val) = 0; |
606 | |
607 | /** @brief Size of an image patch for matching (in pixels). Normally, default 8x8 patches work well |
608 | enough in most cases. |
609 | @see setPatchSize */ |
610 | CV_WRAP virtual int getPatchSize() const = 0; |
611 | /** @copybrief getPatchSize @see getPatchSize */ |
612 | CV_WRAP virtual void setPatchSize(int val) = 0; |
613 | |
614 | /** @brief Stride between neighbor patches. Must be less than patch size. Lower values correspond |
615 | to higher flow quality. |
616 | @see setPatchStride */ |
617 | CV_WRAP virtual int getPatchStride() const = 0; |
618 | /** @copybrief getPatchStride @see getPatchStride */ |
619 | CV_WRAP virtual void setPatchStride(int val) = 0; |
620 | |
621 | /** @brief Maximum number of gradient descent iterations in the patch inverse search stage. Higher values |
622 | may improve quality in some cases. |
623 | @see setGradientDescentIterations */ |
624 | CV_WRAP virtual int getGradientDescentIterations() const = 0; |
625 | /** @copybrief getGradientDescentIterations @see getGradientDescentIterations */ |
626 | CV_WRAP virtual void setGradientDescentIterations(int val) = 0; |
627 | |
628 | /** @brief Number of fixed point iterations of variational refinement per scale. Set to zero to |
629 | disable variational refinement completely. Higher values will typically result in more smooth and |
630 | high-quality flow. |
631 | @see setGradientDescentIterations */ |
632 | CV_WRAP virtual int getVariationalRefinementIterations() const = 0; |
633 | /** @copybrief getGradientDescentIterations @see getGradientDescentIterations */ |
634 | CV_WRAP virtual void setVariationalRefinementIterations(int val) = 0; |
635 | |
636 | /** @brief Weight of the smoothness term |
637 | @see setVariationalRefinementAlpha */ |
638 | CV_WRAP virtual float getVariationalRefinementAlpha() const = 0; |
639 | /** @copybrief getVariationalRefinementAlpha @see getVariationalRefinementAlpha */ |
640 | CV_WRAP virtual void setVariationalRefinementAlpha(float val) = 0; |
641 | |
642 | /** @brief Weight of the color constancy term |
643 | @see setVariationalRefinementDelta */ |
644 | CV_WRAP virtual float getVariationalRefinementDelta() const = 0; |
645 | /** @copybrief getVariationalRefinementDelta @see getVariationalRefinementDelta */ |
646 | CV_WRAP virtual void setVariationalRefinementDelta(float val) = 0; |
647 | |
648 | /** @brief Weight of the gradient constancy term |
649 | @see setVariationalRefinementGamma */ |
650 | CV_WRAP virtual float getVariationalRefinementGamma() const = 0; |
651 | /** @copybrief getVariationalRefinementGamma @see getVariationalRefinementGamma */ |
652 | CV_WRAP virtual void setVariationalRefinementGamma(float val) = 0; |
653 | |
654 | /** @brief Norm value shift for robust penalizer |
655 | @see setVariationalRefinementEpsilon */ |
656 | CV_WRAP virtual float getVariationalRefinementEpsilon() const = 0; |
657 | /** @copybrief getVariationalRefinementEpsilon @see getVariationalRefinementEpsilon */ |
658 | CV_WRAP virtual void setVariationalRefinementEpsilon(float val) = 0; |
659 | |
660 | |
661 | /** @brief Whether to use mean-normalization of patches when computing patch distance. It is turned on |
662 | by default as it typically provides a noticeable quality boost because of increased robustness to |
663 | illumination variations. Turn it off if you are certain that your sequence doesn't contain any changes |
664 | in illumination. |
665 | @see setUseMeanNormalization */ |
666 | CV_WRAP virtual bool getUseMeanNormalization() const = 0; |
667 | /** @copybrief getUseMeanNormalization @see getUseMeanNormalization */ |
668 | CV_WRAP virtual void setUseMeanNormalization(bool val) = 0; |
669 | |
670 | /** @brief Whether to use spatial propagation of good optical flow vectors. This option is turned on by |
671 | default, as it tends to work better on average and can sometimes help recover from major errors |
672 | introduced by the coarse-to-fine scheme employed by the DIS optical flow algorithm. Turning this |
673 | option off can make the output flow field a bit smoother, however. |
674 | @see setUseSpatialPropagation */ |
675 | CV_WRAP virtual bool getUseSpatialPropagation() const = 0; |
676 | /** @copybrief getUseSpatialPropagation @see getUseSpatialPropagation */ |
677 | CV_WRAP virtual void setUseSpatialPropagation(bool val) = 0; |
678 | |
679 | /** @brief Creates an instance of DISOpticalFlow |
680 | |
681 | @param preset one of PRESET_ULTRAFAST, PRESET_FAST and PRESET_MEDIUM |
682 | */ |
683 | CV_WRAP static Ptr<DISOpticalFlow> create(int preset = DISOpticalFlow::PRESET_FAST); |
684 | }; |
685 | |
686 | /** @brief Class used for calculating a sparse optical flow. |
687 | |
688 | The class can calculate an optical flow for a sparse feature set using the |
689 | iterative Lucas-Kanade method with pyramids. |
690 | |
691 | @sa calcOpticalFlowPyrLK |
692 | |
693 | */ |
694 | class CV_EXPORTS_W SparsePyrLKOpticalFlow : public SparseOpticalFlow |
695 | { |
696 | public: |
697 | CV_WRAP virtual Size getWinSize() const = 0; |
698 | CV_WRAP virtual void setWinSize(Size winSize) = 0; |
699 | |
700 | CV_WRAP virtual int getMaxLevel() const = 0; |
701 | CV_WRAP virtual void setMaxLevel(int maxLevel) = 0; |
702 | |
703 | CV_WRAP virtual TermCriteria getTermCriteria() const = 0; |
704 | CV_WRAP virtual void setTermCriteria(TermCriteria& crit) = 0; |
705 | |
706 | CV_WRAP virtual int getFlags() const = 0; |
707 | CV_WRAP virtual void setFlags(int flags) = 0; |
708 | |
709 | CV_WRAP virtual double getMinEigThreshold() const = 0; |
710 | CV_WRAP virtual void setMinEigThreshold(double minEigThreshold) = 0; |
711 | |
712 | CV_WRAP static Ptr<SparsePyrLKOpticalFlow> create( |
713 | Size winSize = Size(21, 21), |
714 | int maxLevel = 3, TermCriteria crit = |
715 | TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), |
716 | int flags = 0, |
717 | double minEigThreshold = 1e-4); |
718 | }; |
719 | |
720 | |
721 | |
722 | |
723 | /** @brief Base abstract class for the long-term tracker |
724 | */ |
725 | class CV_EXPORTS_W Tracker |
726 | { |
727 | protected: |
728 | Tracker(); |
729 | public: |
730 | virtual ~Tracker(); |
731 | |
732 | /** @brief Initialize the tracker with a known bounding box that surrounded the target |
733 | @param image The initial frame |
734 | @param boundingBox The initial bounding box |
735 | */ |
736 | CV_WRAP virtual |
737 | void init(InputArray image, const Rect& boundingBox) = 0; |
738 | |
739 | /** @brief Update the tracker, find the new most likely bounding box for the target |
740 | @param image The current frame |
741 | @param boundingBox The bounding box that represent the new target location, if true was returned, not |
742 | modified otherwise |
743 | |
744 | @return True means that target was located and false means that tracker cannot locate target in |
745 | current frame. Note, that latter *does not* imply that tracker has failed, maybe target is indeed |
746 | missing from the frame (say, out of sight) |
747 | */ |
748 | CV_WRAP virtual |
749 | bool update(InputArray image, CV_OUT Rect& boundingBox) = 0; |
750 | }; |
751 | |
752 | |
753 | |
754 | /** @brief The MIL algorithm trains a classifier in an online manner to separate the object from the |
755 | background. |
756 | |
757 | Multiple Instance Learning avoids the drift problem for a robust tracking. The implementation is |
758 | based on @cite MIL . |
759 | |
760 | Original code can be found here <http://vision.ucsd.edu/~bbabenko/project_miltrack.shtml> |
761 | */ |
762 | class CV_EXPORTS_W TrackerMIL : public Tracker |
763 | { |
764 | protected: |
765 | TrackerMIL(); // use ::create() |
766 | public: |
767 | virtual ~TrackerMIL() CV_OVERRIDE; |
768 | |
769 | struct CV_EXPORTS_W_SIMPLE Params |
770 | { |
771 | CV_WRAP Params(); |
772 | //parameters for sampler |
773 | CV_PROP_RW float samplerInitInRadius; //!< radius for gathering positive instances during init |
774 | CV_PROP_RW int samplerInitMaxNegNum; //!< # negative samples to use during init |
775 | CV_PROP_RW float samplerSearchWinSize; //!< size of search window |
776 | CV_PROP_RW float samplerTrackInRadius; //!< radius for gathering positive instances during tracking |
777 | CV_PROP_RW int samplerTrackMaxPosNum; //!< # positive samples to use during tracking |
778 | CV_PROP_RW int samplerTrackMaxNegNum; //!< # negative samples to use during tracking |
779 | CV_PROP_RW int featureSetNumFeatures; //!< # features |
780 | }; |
781 | |
782 | /** @brief Create MIL tracker instance |
783 | * @param parameters MIL parameters TrackerMIL::Params |
784 | */ |
785 | static CV_WRAP |
786 | Ptr<TrackerMIL> create(const TrackerMIL::Params ¶meters = TrackerMIL::Params()); |
787 | |
788 | //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE; |
789 | //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE; |
790 | }; |
791 | |
792 | |
793 | |
794 | /** @brief the GOTURN (Generic Object Tracking Using Regression Networks) tracker |
795 | * |
796 | * GOTURN (@cite GOTURN) is kind of trackers based on Convolutional Neural Networks (CNN). While taking all advantages of CNN trackers, |
797 | * GOTURN is much faster due to offline training without online fine-tuning nature. |
798 | * GOTURN tracker addresses the problem of single target tracking: given a bounding box label of an object in the first frame of the video, |
799 | * we track that object through the rest of the video. NOTE: Current method of GOTURN does not handle occlusions; however, it is fairly |
800 | * robust to viewpoint changes, lighting changes, and deformations. |
801 | * Inputs of GOTURN are two RGB patches representing Target and Search patches resized to 227x227. |
802 | * Outputs of GOTURN are predicted bounding box coordinates, relative to Search patch coordinate system, in format X1,Y1,X2,Y2. |
803 | * Original paper is here: <http://davheld.github.io/GOTURN/GOTURN.pdf> |
804 | * As long as original authors implementation: <https://github.com/davheld/GOTURN#train-the-tracker> |
805 | * Implementation of training algorithm is placed in separately here due to 3d-party dependencies: |
806 | * <https://github.com/Auron-X/GOTURN_Training_Toolkit> |
807 | * GOTURN architecture goturn.prototxt and trained model goturn.caffemodel are accessible on opencv_extra GitHub repository. |
808 | */ |
809 | class CV_EXPORTS_W TrackerGOTURN : public Tracker |
810 | { |
811 | protected: |
812 | TrackerGOTURN(); // use ::create() |
813 | public: |
814 | virtual ~TrackerGOTURN() CV_OVERRIDE; |
815 | |
816 | struct CV_EXPORTS_W_SIMPLE Params |
817 | { |
818 | CV_WRAP Params(); |
819 | CV_PROP_RW std::string modelTxt; |
820 | CV_PROP_RW std::string modelBin; |
821 | }; |
822 | |
823 | /** @brief Constructor |
824 | @param parameters GOTURN parameters TrackerGOTURN::Params |
825 | */ |
826 | static CV_WRAP |
827 | Ptr<TrackerGOTURN> create(const TrackerGOTURN::Params& parameters = TrackerGOTURN::Params()); |
828 | |
829 | //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE; |
830 | //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE; |
831 | }; |
832 | |
833 | class CV_EXPORTS_W TrackerDaSiamRPN : public Tracker |
834 | { |
835 | protected: |
836 | TrackerDaSiamRPN(); // use ::create() |
837 | public: |
838 | virtual ~TrackerDaSiamRPN() CV_OVERRIDE; |
839 | |
840 | struct CV_EXPORTS_W_SIMPLE Params |
841 | { |
842 | CV_WRAP Params(); |
843 | CV_PROP_RW std::string model; |
844 | CV_PROP_RW std::string kernel_cls1; |
845 | CV_PROP_RW std::string kernel_r1; |
846 | CV_PROP_RW int backend; |
847 | CV_PROP_RW int target; |
848 | }; |
849 | |
850 | /** @brief Constructor |
851 | @param parameters DaSiamRPN parameters TrackerDaSiamRPN::Params |
852 | */ |
853 | static CV_WRAP |
854 | Ptr<TrackerDaSiamRPN> create(const TrackerDaSiamRPN::Params& parameters = TrackerDaSiamRPN::Params()); |
855 | |
856 | /** @brief Return tracking score |
857 | */ |
858 | CV_WRAP virtual float getTrackingScore() = 0; |
859 | |
860 | //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE; |
861 | //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE; |
862 | }; |
863 | |
864 | /** @brief the Nano tracker is a super lightweight dnn-based general object tracking. |
865 | * |
866 | * Nano tracker is much faster and extremely lightweight due to special model structure, the whole model size is about 1.9 MB. |
867 | * Nano tracker needs two models: one for feature extraction (backbone) and the another for localization (neckhead). |
868 | * Model download link: https://github.com/HonglinChu/SiamTrackers/tree/master/NanoTrack/models/nanotrackv2 |
869 | * Original repo is here: https://github.com/HonglinChu/NanoTrack |
870 | * Author: HongLinChu, 1628464345@qq.com |
871 | */ |
872 | class CV_EXPORTS_W TrackerNano : public Tracker |
873 | { |
874 | protected: |
875 | TrackerNano(); // use ::create() |
876 | public: |
877 | virtual ~TrackerNano() CV_OVERRIDE; |
878 | |
879 | struct CV_EXPORTS_W_SIMPLE Params |
880 | { |
881 | CV_WRAP Params(); |
882 | CV_PROP_RW std::string backbone; |
883 | CV_PROP_RW std::string neckhead; |
884 | CV_PROP_RW int backend; |
885 | CV_PROP_RW int target; |
886 | }; |
887 | |
888 | /** @brief Constructor |
889 | @param parameters NanoTrack parameters TrackerNano::Params |
890 | */ |
891 | static CV_WRAP |
892 | Ptr<TrackerNano> create(const TrackerNano::Params& parameters = TrackerNano::Params()); |
893 | |
894 | /** @brief Return tracking score |
895 | */ |
896 | CV_WRAP virtual float getTrackingScore() = 0; |
897 | |
898 | //void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE; |
899 | //bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE; |
900 | }; |
901 | |
902 | /** @brief the VIT tracker is a super lightweight dnn-based general object tracking. |
903 | * |
904 | * VIT tracker is much faster and extremely lightweight due to special model structure, the model file is about 767KB. |
905 | * Model download link: https://github.com/opencv/opencv_zoo/tree/main/models/object_tracking_vittrack |
906 | * Author: PengyuLiu, 1872918507@qq.com |
907 | */ |
908 | class CV_EXPORTS_W TrackerVit : public Tracker |
909 | { |
910 | protected: |
911 | TrackerVit(); // use ::create() |
912 | public: |
913 | virtual ~TrackerVit() CV_OVERRIDE; |
914 | |
915 | struct CV_EXPORTS_W_SIMPLE Params |
916 | { |
917 | CV_WRAP Params(); |
918 | CV_PROP_RW std::string net; |
919 | CV_PROP_RW int backend; |
920 | CV_PROP_RW int target; |
921 | CV_PROP_RW Scalar meanvalue; |
922 | CV_PROP_RW Scalar stdvalue; |
923 | CV_PROP_RW float tracking_score_threshold; |
924 | }; |
925 | |
926 | /** @brief Constructor |
927 | @param parameters vit tracker parameters TrackerVit::Params |
928 | */ |
929 | static CV_WRAP |
930 | Ptr<TrackerVit> create(const TrackerVit::Params& parameters = TrackerVit::Params()); |
931 | |
932 | /** @brief Return tracking score |
933 | */ |
934 | CV_WRAP virtual float getTrackingScore() = 0; |
935 | |
936 | // void init(InputArray image, const Rect& boundingBox) CV_OVERRIDE; |
937 | // bool update(InputArray image, CV_OUT Rect& boundingBox) CV_OVERRIDE; |
938 | }; |
939 | |
940 | //! @} video_track |
941 | |
942 | } // cv |
943 | |
944 | #endif |
945 | |