00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef __OPENCV_TRACKING_HPP__
00048 #define __OPENCV_TRACKING_HPP__
00049
00050 #include "opencv2/core/core.hpp"
00051 #include "opencv2/imgproc/imgproc.hpp"
00052
00053 #ifdef __cplusplus
00054 extern "C" {
00055 #endif
00056
00057
00058
00059
00060
00061
00062
00063 #define CV_LKFLOW_PYR_A_READY 1
00064 #define CV_LKFLOW_PYR_B_READY 2
00065 #define CV_LKFLOW_INITIAL_GUESSES 4
00066 #define CV_LKFLOW_GET_MIN_EIGENVALS 8
00067
00068
00069
00070
00071
00072
00073 CVAPI(void) cvCalcOpticalFlowPyrLK( const CvArr* prev, const CvArr* curr,
00074 CvArr* prev_pyr, CvArr* curr_pyr,
00075 const CvPoint2D32f* prev_features,
00076 CvPoint2D32f* curr_features,
00077 int count,
00078 CvSize win_size,
00079 int level,
00080 char* status,
00081 float* track_error,
00082 CvTermCriteria criteria,
00083 int flags );
00084
00085
00086
00087
00088 CVAPI(void) cvCalcAffineFlowPyrLK( const CvArr* prev, const CvArr* curr,
00089 CvArr* prev_pyr, CvArr* curr_pyr,
00090 const CvPoint2D32f* prev_features,
00091 CvPoint2D32f* curr_features,
00092 float* matrices, int count,
00093 CvSize win_size, int level,
00094 char* status, float* track_error,
00095 CvTermCriteria criteria, int flags );
00096
00097
00098 CVAPI(int) cvEstimateRigidTransform( const CvArr* A, const CvArr* B,
00099 CvMat* M, int full_affine );
00100
00101
00102 CVAPI(void) cvCalcOpticalFlowFarneback( const CvArr* prev, const CvArr* next,
00103 CvArr* flow, double pyr_scale, int levels,
00104 int winsize, int iterations, int poly_n,
00105 double poly_sigma, int flags );
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 CVAPI(void) cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi,
00121 double timestamp, double duration );
00122
00123
00124
00125 CVAPI(void) cvCalcMotionGradient( const CvArr* mhi, CvArr* mask, CvArr* orientation,
00126 double delta1, double delta2,
00127 int aperture_size CV_DEFAULT(3));
00128
00129
00130
00131
00132 CVAPI(double) cvCalcGlobalOrientation( const CvArr* orientation, const CvArr* mask,
00133 const CvArr* mhi, double timestamp,
00134 double duration );
00135
00136
00137
00138 CVAPI(CvSeq*) cvSegmentMotion( const CvArr* mhi, CvArr* seg_mask,
00139 CvMemStorage* storage,
00140 double timestamp, double seg_thresh );
00141
00142
00143
00144
00145
00146
00147
00148 CVAPI(int) cvCamShift( const CvArr* prob_image, CvRect window,
00149 CvTermCriteria criteria, CvConnectedComp* comp,
00150 CvBox2D* box CV_DEFAULT(NULL) );
00151
00152
00153
00154 CVAPI(int) cvMeanShift( const CvArr* prob_image, CvRect window,
00155 CvTermCriteria criteria, CvConnectedComp* comp );
00156
00157
00158
00159
00160
00161
00162
00163 typedef struct CvKalman
00164 {
00165 int MP;
00166 int DP;
00167 int CP;
00168
00169
00170 #if 1
00171 float* PosterState;
00172 float* PriorState;
00173 float* DynamMatr;
00174 float* MeasurementMatr;
00175 float* MNCovariance;
00176 float* PNCovariance;
00177 float* KalmGainMatr;
00178 float* PriorErrorCovariance;
00179 float* PosterErrorCovariance;
00180 float* Temp1;
00181 float* Temp2;
00182 #endif
00183
00184 CvMat* state_pre;
00185
00186 CvMat* state_post;
00187
00188 CvMat* transition_matrix;
00189 CvMat* control_matrix;
00190
00191 CvMat* measurement_matrix;
00192 CvMat* process_noise_cov;
00193 CvMat* measurement_noise_cov;
00194 CvMat* error_cov_pre;
00195
00196 CvMat* gain;
00197
00198 CvMat* error_cov_post;
00199
00200 CvMat* temp1;
00201 CvMat* temp2;
00202 CvMat* temp3;
00203 CvMat* temp4;
00204 CvMat* temp5;
00205 } CvKalman;
00206
00207
00208 CVAPI(CvKalman*) cvCreateKalman( int dynam_params, int measure_params,
00209 int control_params CV_DEFAULT(0));
00210
00211
00212 CVAPI(void) cvReleaseKalman( CvKalman** kalman);
00213
00214
00215 CVAPI(const CvMat*) cvKalmanPredict( CvKalman* kalman,
00216 const CvMat* control CV_DEFAULT(NULL));
00217
00218
00219
00220 CVAPI(const CvMat*) cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement );
00221
00222 #define cvKalmanUpdateByTime cvKalmanPredict
00223 #define cvKalmanUpdateByMeasurement cvKalmanCorrect
00224
00225 #ifdef __cplusplus
00226 }
00227
00228 namespace cv
00229 {
00230
00232 CV_EXPORTS_W void updateMotionHistory( InputArray silhouette, InputOutputArray mhi,
00233 double timestamp, double duration );
00234
00236 CV_EXPORTS_W void calcMotionGradient( InputArray mhi, OutputArray mask,
00237 OutputArray orientation,
00238 double delta1, double delta2,
00239 int apertureSize=3 );
00240
00242 CV_EXPORTS_W double calcGlobalOrientation( InputArray orientation, InputArray mask,
00243 InputArray mhi, double timestamp,
00244 double duration );
00245
00246 CV_EXPORTS_W void segmentMotion(InputArray mhi, OutputArray segmask,
00247 CV_OUT vector<Rect>& boundingRects,
00248 double timestamp, double segThresh);
00249
00251 CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_OUT CV_IN_OUT Rect& window,
00252 TermCriteria criteria );
00253
00255 CV_EXPORTS_W int meanShift( InputArray probImage, CV_OUT CV_IN_OUT Rect& window,
00256 TermCriteria criteria );
00257
00265 class CV_EXPORTS_W KalmanFilter
00266 {
00267 public:
00269 CV_WRAP KalmanFilter();
00271 CV_WRAP KalmanFilter(int dynamParams, int measureParams, int controlParams=0, int type=CV_32F);
00273 void init(int dynamParams, int measureParams, int controlParams=0, int type=CV_32F);
00274
00276 CV_WRAP const Mat& predict(const Mat& control=Mat());
00278 CV_WRAP const Mat& correct(const Mat& measurement);
00279
00280 Mat statePre;
00281 Mat statePost;
00282 Mat transitionMatrix;
00283 Mat controlMatrix;
00284 Mat measurementMatrix;
00285 Mat processNoiseCov;
00286 Mat measurementNoiseCov;
00287 Mat errorCovPre;
00288 Mat gain;
00289 Mat errorCovPost;
00290
00291
00292 Mat temp1;
00293 Mat temp2;
00294 Mat temp3;
00295 Mat temp4;
00296 Mat temp5;
00297 };
00298
00299 enum
00300 {
00301 OPTFLOW_USE_INITIAL_FLOW = CV_LKFLOW_INITIAL_GUESSES,
00302 OPTFLOW_LK_GET_MIN_EIGENVALS = CV_LKFLOW_GET_MIN_EIGENVALS,
00303 OPTFLOW_FARNEBACK_GAUSSIAN = 256
00304 };
00305
00307 CV_EXPORTS_W int buildOpticalFlowPyramid(InputArray img, OutputArrayOfArrays pyramid,
00308 Size winSize, int maxLevel, bool withDerivatives = true,
00309 int pyrBorder = BORDER_REFLECT_101, int derivBorder = BORDER_CONSTANT,
00310 bool tryReuseInputImage = true);
00311
00313 CV_EXPORTS_W void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg,
00314 InputArray prevPts, CV_OUT InputOutputArray nextPts,
00315 OutputArray status, OutputArray err,
00316 Size winSize=Size(21,21), int maxLevel=3,
00317 TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01),
00318 int flags=0, double minEigThreshold=1e-4);
00319
00321 CV_EXPORTS_W void calcOpticalFlowFarneback( InputArray prev, InputArray next,
00322 CV_OUT InputOutputArray flow, double pyr_scale, int levels, int winsize,
00323 int iterations, int poly_n, double poly_sigma, int flags );
00324
00326
00327 CV_EXPORTS_W Mat estimateRigidTransform( InputArray src, InputArray dst,
00328 bool fullAffine);
00329
00331 CV_EXPORTS_W void calcOpticalFlowSF(Mat& from,
00332 Mat& to,
00333 Mat& flow,
00334 int layers,
00335 int averaging_block_size,
00336 int max_flow);
00337
00338 CV_EXPORTS_W void calcOpticalFlowSF(Mat& from,
00339 Mat& to,
00340 Mat& flow,
00341 int layers,
00342 int averaging_block_size,
00343 int max_flow,
00344 double sigma_dist,
00345 double sigma_color,
00346 int postprocess_window,
00347 double sigma_dist_fix,
00348 double sigma_color_fix,
00349 double occ_thr,
00350 int upscale_averaging_radius,
00351 double upscale_sigma_dist,
00352 double upscale_sigma_color,
00353 double speed_up_thr);
00354
00355 }
00356
00357 #endif
00358
00359 #endif