diff --git a/apps/traincascade/HOGfeatures.cpp b/apps/traincascade/HOGfeatures.cpp index b4ae56d37..132e2e62e 100644 --- a/apps/traincascade/HOGfeatures.cpp +++ b/apps/traincascade/HOGfeatures.cpp @@ -1,4 +1,5 @@ #include "opencv2/core.hpp" +#include "opencv2/imgproc.hpp" #include "HOGfeatures.h" #include "cascadeclassifier.h" diff --git a/apps/traincascade/haarfeatures.cpp b/apps/traincascade/haarfeatures.cpp index 40af47d42..ceb730aaf 100644 --- a/apps/traincascade/haarfeatures.cpp +++ b/apps/traincascade/haarfeatures.cpp @@ -1,4 +1,5 @@ #include "opencv2/core.hpp" +#include "opencv2/imgproc.hpp" #include "haarfeatures.h" #include "cascadeclassifier.h" diff --git a/apps/traincascade/lbpfeatures.cpp b/apps/traincascade/lbpfeatures.cpp index eb15b5ae8..dd1659f9d 100644 --- a/apps/traincascade/lbpfeatures.cpp +++ b/apps/traincascade/lbpfeatures.cpp @@ -1,4 +1,5 @@ #include "opencv2/core.hpp" +#include "opencv2/imgproc.hpp" #include "lbpfeatures.h" #include "cascadeclassifier.h" diff --git a/include/opencv/cv.h b/include/opencv/cv.h index 87fc0f2cf..39de8507b 100644 --- a/include/opencv/cv.h +++ b/include/opencv/cv.h @@ -63,8 +63,8 @@ #include "opencv2/core/core_c.h" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/photo/photo_c.h" +#include "opencv2/video/tracking_c.h" -#include "opencv2/video.hpp" #include "opencv2/features2d.hpp" #include "opencv2/flann.hpp" #include "opencv2/calib3d.hpp" diff --git a/include/opencv/cv.hpp b/include/opencv/cv.hpp index 6b579ff91..4f60c49a7 100644 --- a/include/opencv/cv.hpp +++ b/include/opencv/cv.hpp @@ -51,6 +51,7 @@ #include "opencv2/core.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/photo.hpp" +#include "opencv2/video.hpp" #include "opencv2/highgui.hpp" #endif diff --git a/include/opencv/cvaux.h b/include/opencv/cvaux.h index 78777ac1b..12e49cc93 100644 --- a/include/opencv/cvaux.h +++ b/include/opencv/cvaux.h @@ -49,8 +49,8 @@ #include "opencv2/core/core_c.h" #include "opencv2/imgproc/imgproc_c.h" #include "opencv2/photo/photo_c.h" +#include "opencv2/video/tracking_c.h" -#include "opencv2/video.hpp" #include "opencv2/features2d.hpp" #include "opencv2/calib3d.hpp" #include "opencv2/objdetect.hpp" diff --git a/modules/contrib/src/colortracker.cpp b/modules/contrib/src/colortracker.cpp index 5a9d9b7c4..c1d91bb9b 100644 --- a/modules/contrib/src/colortracker.cpp +++ b/modules/contrib/src/colortracker.cpp @@ -60,7 +60,7 @@ void CvMeanShiftTracker::newTrackingWindow(Mat image, Rect selection) float srange[] = { 0, 1 }; const float* ranges[] = {hrange, srange}; - cvtColor(image, hsv, CV_BGR2HSV); + cvtColor(image, hsv, COLOR_BGR2HSV); inRange(hsv, Scalar(0, 30, MIN(10, 256)), Scalar(180, 256, MAX(10, 256)), mask); hue.create(hsv.size(), CV_8UC2); @@ -83,7 +83,7 @@ RotatedRect CvMeanShiftTracker::updateTrackingWindow(Mat image) float srange[] = { 0, 1 }; const float* ranges[] = {hrange, srange}; - cvtColor(image, hsv, CV_BGR2HSV); + cvtColor(image, hsv, COLOR_BGR2HSV); inRange(hsv, Scalar(0, 30, MIN(10, 256)), Scalar(180, 256, MAX(10, 256)), mask); hue.create(hsv.size(), CV_8UC2); mixChannels(&hsv, 1, &hue, 1, channels, 2); diff --git a/modules/contrib/src/featuretracker.cpp b/modules/contrib/src/featuretracker.cpp index 575f69abf..e94450db6 100644 --- a/modules/contrib/src/featuretracker.cpp +++ b/modules/contrib/src/featuretracker.cpp @@ -80,7 +80,7 @@ CvFeatureTracker::~CvFeatureTracker() void CvFeatureTracker::newTrackingWindow(Mat image, Rect selection) { image.copyTo(prev_image); - cvtColor(prev_image, prev_image_bw, CV_BGR2GRAY); + cvtColor(prev_image, prev_image_bw, COLOR_BGR2GRAY); prev_trackwindow = selection; prev_center.x = selection.x; prev_center.y = selection.y; @@ -148,12 +148,12 @@ Rect CvFeatureTracker::updateTrackingWindowWithFlow(Mat image) ittr++; Size subPixWinSize(10,10), winSize(31,31); Mat image_bw; - TermCriteria termcrit(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 20, 0.03); + TermCriteria termcrit(TermCriteria::COUNT | TermCriteria::EPS, 20, 0.03); std::vector status; std::vector err; - cvtColor(image, image_bw, CV_BGR2GRAY); - cvtColor(prev_image, prev_image_bw, CV_BGR2GRAY); + cvtColor(image, image_bw, COLOR_BGR2GRAY); + cvtColor(prev_image, prev_image_bw, COLOR_BGR2GRAY); if (ittr == 1) { diff --git a/modules/legacy/src/blobtrackpostprockalman.cpp b/modules/legacy/src/blobtrackpostprockalman.cpp index debe89d3f..fb6f8dee9 100644 --- a/modules/legacy/src/blobtrackpostprockalman.cpp +++ b/modules/legacy/src/blobtrackpostprockalman.cpp @@ -39,6 +39,7 @@ //M*/ #include "precomp.hpp" +#include "opencv2/video/tracking_c.h" /*======================= KALMAN FILTER =========================*/ /* State vector is (x,y,w,h,dx,dy,dw,dh). */ diff --git a/modules/legacy/src/camshift.cpp b/modules/legacy/src/camshift.cpp index 830e19824..b3cd9974a 100644 --- a/modules/legacy/src/camshift.cpp +++ b/modules/legacy/src/camshift.cpp @@ -39,6 +39,7 @@ // //M*/ #include "precomp.hpp" +#include "opencv2/video/tracking_c.h" CvCamShiftTracker::CvCamShiftTracker() { diff --git a/modules/legacy/test/test_optflow.cpp b/modules/legacy/test/test_optflow.cpp index f72d4c36a..99645410f 100644 --- a/modules/legacy/test/test_optflow.cpp +++ b/modules/legacy/test/test_optflow.cpp @@ -42,6 +42,7 @@ #include "test_precomp.hpp" #include "opencv2/video/tracking.hpp" +#include "opencv2/video/tracking_c.h" #include #include diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp index 75c8c2ec0..ac409ca2f 100644 --- a/modules/python/src2/cv2.cpp +++ b/modules/python/src2/cv2.cpp @@ -25,6 +25,7 @@ #include "opencv2/highgui/highgui_c.h" #include "opencv2/photo/photo_c.h" +#include "opencv2/video/tracking_c.h" #include "opencv2/opencv_modules.hpp" diff --git a/modules/video/include/opencv2/video.hpp b/modules/video/include/opencv2/video.hpp index 1dd96f543..b429ceff9 100644 --- a/modules/video/include/opencv2/video.hpp +++ b/modules/video/include/opencv2/video.hpp @@ -7,11 +7,12 @@ // copy or use the software. // // -// License Agreement +// License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, @@ -46,13 +47,9 @@ #include "opencv2/video/tracking.hpp" #include "opencv2/video/background_segm.hpp" -#ifdef __cplusplus namespace cv { - CV_EXPORTS bool initModule_video(void); - } -#endif #endif //__OPENCV_VIDEO_HPP__ diff --git a/modules/video/include/opencv2/video/background_segm.hpp b/modules/video/include/opencv2/video/background_segm.hpp index d43157bd2..a46dc820e 100644 --- a/modules/video/include/opencv2/video/background_segm.hpp +++ b/modules/video/include/opencv2/video/background_segm.hpp @@ -7,7 +7,7 @@ // copy or use the software. // // -// License Agreement +// License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. @@ -45,7 +45,7 @@ #define __OPENCV_BACKGROUND_SEGM_HPP__ #include "opencv2/core.hpp" -#include + namespace cv { @@ -66,6 +66,7 @@ public: }; + /*! Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm @@ -97,6 +98,7 @@ CV_EXPORTS_W Ptr double backgroundRatio=0.7, double noiseSigma=0); + /*! The class implements the following algorithm: "Improved adaptive Gausian mixture model for background subtraction" @@ -193,6 +195,6 @@ public: CV_EXPORTS_W Ptr createBackgroundSubtractorGMG(int initializationFrames=120, double decisionThreshold=0.8); -} +} // cv #endif diff --git a/modules/video/include/opencv2/video/tracking.hpp b/modules/video/include/opencv2/video/tracking.hpp index f943bb7e5..2045b19d9 100644 --- a/modules/video/include/opencv2/video/tracking.hpp +++ b/modules/video/include/opencv2/video/tracking.hpp @@ -7,11 +7,12 @@ // copy or use the software. // // -// License Agreement +// License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, @@ -43,218 +44,95 @@ #ifndef __OPENCV_TRACKING_HPP__ #define __OPENCV_TRACKING_HPP__ -#ifdef __cplusplus -# include "opencv2/core.hpp" -# include "opencv2/imgproc.hpp" -#endif - -#include "opencv2/imgproc/types_c.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/****************************************************************************************\ -* Motion Analysis * -\****************************************************************************************/ - -/************************************ optical flow ***************************************/ - -#define CV_LKFLOW_PYR_A_READY 1 -#define CV_LKFLOW_PYR_B_READY 2 -#define CV_LKFLOW_INITIAL_GUESSES 4 -#define CV_LKFLOW_GET_MIN_EIGENVALS 8 - -/* It is Lucas & Kanade method, modified to use pyramids. - Also it does several iterations to get optical flow for - every point at every pyramid level. - Calculates optical flow between two images for certain set of points (i.e. - it is a "sparse" optical flow, which is opposite to the previous 3 methods) */ -CVAPI(void) cvCalcOpticalFlowPyrLK( const CvArr* prev, const CvArr* curr, - CvArr* prev_pyr, CvArr* curr_pyr, - const CvPoint2D32f* prev_features, - CvPoint2D32f* curr_features, - int count, - CvSize win_size, - int level, - char* status, - float* track_error, - CvTermCriteria criteria, - int flags ); - - -/* Modification of a previous sparse optical flow algorithm to calculate - affine flow */ -CVAPI(void) cvCalcAffineFlowPyrLK( const CvArr* prev, const CvArr* curr, - CvArr* prev_pyr, CvArr* curr_pyr, - const CvPoint2D32f* prev_features, - CvPoint2D32f* curr_features, - float* matrices, int count, - CvSize win_size, int level, - char* status, float* track_error, - CvTermCriteria criteria, int flags ); - -/* Estimate rigid transformation between 2 images or 2 point sets */ -CVAPI(int) cvEstimateRigidTransform( const CvArr* A, const CvArr* B, - CvMat* M, int full_affine ); - -/* Estimate optical flow for each pixel using the two-frame G. Farneback algorithm */ -CVAPI(void) cvCalcOpticalFlowFarneback( const CvArr* prev, const CvArr* next, - CvArr* flow, double pyr_scale, int levels, - int winsize, int iterations, int poly_n, - double poly_sigma, int flags ); - -/********************************* motion templates *************************************/ - -/****************************************************************************************\ -* All the motion template functions work only with single channel images. * -* Silhouette image must have depth IPL_DEPTH_8U or IPL_DEPTH_8S * -* Motion history image must have depth IPL_DEPTH_32F, * -* Gradient mask - IPL_DEPTH_8U or IPL_DEPTH_8S, * -* Motion orientation image - IPL_DEPTH_32F * -* Segmentation mask - IPL_DEPTH_32F * -* All the angles are in degrees, all the times are in milliseconds * -\****************************************************************************************/ - -/* Updates motion history image given motion silhouette */ -CVAPI(void) cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi, - double timestamp, double duration ); - -/* Calculates gradient of the motion history image and fills - a mask indicating where the gradient is valid */ -CVAPI(void) cvCalcMotionGradient( const CvArr* mhi, CvArr* mask, CvArr* orientation, - double delta1, double delta2, - int aperture_size CV_DEFAULT(3)); - -/* Calculates average motion direction within a selected motion region - (region can be selected by setting ROIs and/or by composing a valid gradient mask - with the region mask) */ -CVAPI(double) cvCalcGlobalOrientation( const CvArr* orientation, const CvArr* mask, - const CvArr* mhi, double timestamp, - double duration ); - -/* Splits a motion history image into a few parts corresponding to separate independent motions - (e.g. left hand, right hand) */ -CVAPI(CvSeq*) cvSegmentMotion( const CvArr* mhi, CvArr* seg_mask, - CvMemStorage* storage, - double timestamp, double seg_thresh ); - -/****************************************************************************************\ -* Tracking * -\****************************************************************************************/ - -/* Implements CAMSHIFT algorithm - determines object position, size and orientation - from the object histogram back project (extension of meanshift) */ -CVAPI(int) cvCamShift( const CvArr* prob_image, CvRect window, - CvTermCriteria criteria, CvConnectedComp* comp, - CvBox2D* box CV_DEFAULT(NULL) ); - -/* Implements MeanShift algorithm - determines object position - from the object histogram back project */ -CVAPI(int) cvMeanShift( const CvArr* prob_image, CvRect window, - CvTermCriteria criteria, CvConnectedComp* comp ); - -/* -standard Kalman filter (in G. Welch' and G. Bishop's notation): - - x(k)=A*x(k-1)+B*u(k)+w(k) p(w)~N(0,Q) - z(k)=H*x(k)+v(k), p(v)~N(0,R) -*/ -typedef struct CvKalman -{ - int MP; /* number of measurement vector dimensions */ - int DP; /* number of state vector dimensions */ - int CP; /* number of control vector dimensions */ - - /* backward compatibility fields */ -#if 1 - float* PosterState; /* =state_pre->data.fl */ - float* PriorState; /* =state_post->data.fl */ - float* DynamMatr; /* =transition_matrix->data.fl */ - float* MeasurementMatr; /* =measurement_matrix->data.fl */ - float* MNCovariance; /* =measurement_noise_cov->data.fl */ - float* PNCovariance; /* =process_noise_cov->data.fl */ - float* KalmGainMatr; /* =gain->data.fl */ - float* PriorErrorCovariance;/* =error_cov_pre->data.fl */ - float* PosterErrorCovariance;/* =error_cov_post->data.fl */ - float* Temp1; /* temp1->data.fl */ - float* Temp2; /* temp2->data.fl */ -#endif - - CvMat* state_pre; /* predicted state (x'(k)): - x(k)=A*x(k-1)+B*u(k) */ - CvMat* state_post; /* corrected state (x(k)): - x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) */ - CvMat* transition_matrix; /* state transition matrix (A) */ - CvMat* control_matrix; /* control matrix (B) - (it is not used if there is no control)*/ - CvMat* measurement_matrix; /* measurement matrix (H) */ - CvMat* process_noise_cov; /* process noise covariance matrix (Q) */ - CvMat* measurement_noise_cov; /* measurement noise covariance matrix (R) */ - CvMat* error_cov_pre; /* priori error estimate covariance matrix (P'(k)): - P'(k)=A*P(k-1)*At + Q)*/ - CvMat* gain; /* Kalman gain matrix (K(k)): - K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)*/ - CvMat* error_cov_post; /* posteriori error estimate covariance matrix (P(k)): - P(k)=(I-K(k)*H)*P'(k) */ - CvMat* temp1; /* temporary matrices */ - CvMat* temp2; - CvMat* temp3; - CvMat* temp4; - CvMat* temp5; -} CvKalman; - -/* Creates Kalman filter and sets A, B, Q, R and state to some initial values */ -CVAPI(CvKalman*) cvCreateKalman( int dynam_params, int measure_params, - int control_params CV_DEFAULT(0)); - -/* Releases Kalman filter state */ -CVAPI(void) cvReleaseKalman( CvKalman** kalman); - -/* Updates Kalman filter by time (predicts future state of the system) */ -CVAPI(const CvMat*) cvKalmanPredict( CvKalman* kalman, - const CvMat* control CV_DEFAULT(NULL)); - -/* Updates Kalman filter by measurement - (corrects state of the system and internal matrices) */ -CVAPI(const CvMat*) cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement ); - -#define cvKalmanUpdateByTime cvKalmanPredict -#define cvKalmanUpdateByMeasurement cvKalmanCorrect - - -#ifdef __cplusplus -} +#include "opencv2/core.hpp" +#include "opencv2/imgproc.hpp" namespace cv { +enum { OPTFLOW_USE_INITIAL_FLOW = 4, + OPTFLOW_LK_GET_MIN_EIGENVALS = 8, + OPTFLOW_FARNEBACK_GAUSSIAN = 256 + }; + +enum { MOTION_TRANSLATION = 0, + MOTION_EUCLIDEAN = 1, + MOTION_AFFINE = 2, + MOTION_HOMOGRAPHY = 3 + }; + //! updates motion history image using the current silhouette CV_EXPORTS_W void updateMotionHistory( InputArray silhouette, InputOutputArray mhi, double timestamp, double duration ); //! computes the motion gradient orientation image from the motion history image -CV_EXPORTS_W void calcMotionGradient( InputArray mhi, OutputArray mask, - OutputArray orientation, - double delta1, double delta2, - int apertureSize=3 ); +CV_EXPORTS_W void calcMotionGradient( InputArray mhi, OutputArray mask, OutputArray orientation, + double delta1, double delta2, int apertureSize = 3 ); //! computes the global orientation of the selected motion history image part -CV_EXPORTS_W double calcGlobalOrientation( InputArray orientation, InputArray mask, - InputArray mhi, double timestamp, - double duration ); +CV_EXPORTS_W double calcGlobalOrientation( InputArray orientation, InputArray mask, InputArray mhi, + double timestamp, double duration ); -CV_EXPORTS_W void segmentMotion(InputArray mhi, OutputArray segmask, - CV_OUT std::vector& boundingRects, - double timestamp, double segThresh); +CV_EXPORTS_W void segmentMotion( InputArray mhi, OutputArray segmask, + CV_OUT std::vector& boundingRects, + double timestamp, double segThresh ); //! updates the object tracking window using CAMSHIFT algorithm -CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_OUT CV_IN_OUT Rect& window, +CV_EXPORTS_W RotatedRect CamShift( InputArray probImage, CV_IN_OUT Rect& window, TermCriteria criteria ); //! updates the object tracking window using meanshift algorithm -CV_EXPORTS_W int meanShift( InputArray probImage, CV_OUT CV_IN_OUT Rect& window, - TermCriteria criteria ); +CV_EXPORTS_W int meanShift( InputArray probImage, CV_IN_OUT Rect& window, TermCriteria criteria ); + +//! constructs a pyramid which can be used as input for calcOpticalFlowPyrLK +CV_EXPORTS_W int buildOpticalFlowPyramid( InputArray img, OutputArrayOfArrays pyramid, + Size winSize, int maxLevel, bool withDerivatives = true, + int pyrBorder = BORDER_REFLECT_101, + int derivBorder = BORDER_CONSTANT, + bool tryReuseInputImage = true ); + +//! computes sparse optical flow using multi-scale Lucas-Kanade algorithm +CV_EXPORTS_W void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg, + InputArray prevPts, InputOutputArray nextPts, + OutputArray status, OutputArray err, + Size winSize = Size(21,21), int maxLevel = 3, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), + int flags = 0, double minEigThreshold = 1e-4 ); + +//! computes dense optical flow using Farneback algorithm +CV_EXPORTS_W void calcOpticalFlowFarneback( InputArray prev, InputArray next, InputOutputArray flow, + double pyr_scale, int levels, int winsize, + int iterations, int poly_n, double poly_sigma, + int flags ); + +//! estimates the best-fit Euqcidean, similarity, affine or perspective transformation +// that maps one 2D point set to another or one image to another. +CV_EXPORTS_W Mat estimateRigidTransform( InputArray src, InputArray dst, bool fullAffine ); + +//! estimates the best-fit Translation, Euclidean, Affine or Perspective Transformation +// with respect to Enhanced Correlation Coefficient criterion that maps one image to +// another (area-based alignment) +// +// see reference: +// Evangelidis, G. E., Psarakis, E.Z., Parametric Image Alignment using +// Enhanced Correlation Coefficient Maximization, PAMI, 30(8), 2008 +CV_EXPORTS_W double findTransformECC( InputArray templateImage, InputArray inputImage, + InputOutputArray warpMatrix, int motionType = MOTION_AFFINE, + TermCriteria criteria = TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001)); + + +//! computes dense optical flow using Simple Flow algorithm +CV_EXPORTS_W void calcOpticalFlowSF( InputArray from, InputArray to, OutputArray flow, + int layers, int averaging_block_size, int max_flow); + +CV_EXPORTS_W void calcOpticalFlowSF( InputArray from, InputArray to, OutputArray flow, int layers, + int averaging_block_size, int max_flow, + double sigma_dist, double sigma_color, int postprocess_window, + double sigma_dist_fix, double sigma_color_fix, double occ_thr, + int upscale_averaging_radius, double upscale_sigma_dist, + double upscale_sigma_color, double speed_up_thr ); + + /*! Kalman filter. @@ -269,14 +147,14 @@ public: //! the default constructor CV_WRAP KalmanFilter(); //! the full constructor taking the dimensionality of the state, of the measurement and of the control vector - CV_WRAP KalmanFilter(int dynamParams, int measureParams, int controlParams=0, int type=CV_32F); + CV_WRAP KalmanFilter( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); //! re-initializes Kalman filter. The previous content is destroyed. - void init(int dynamParams, int measureParams, int controlParams=0, int type=CV_32F); + void init( int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F ); //! computes predicted state - CV_WRAP const Mat& predict(const Mat& control=Mat()); + CV_WRAP const Mat& predict( const Mat& control = Mat() ); //! updates the predicted state from the measurement - CV_WRAP const Mat& correct(const Mat& measurement); + CV_WRAP const Mat& correct( const Mat& measurement ); Mat statePre; //!< predicted state (x'(k)): x(k)=A*x(k-1)+B*u(k) Mat statePost; //!< corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) @@ -297,89 +175,12 @@ public: Mat temp5; }; -enum -{ - OPTFLOW_USE_INITIAL_FLOW = CV_LKFLOW_INITIAL_GUESSES, - OPTFLOW_LK_GET_MIN_EIGENVALS = CV_LKFLOW_GET_MIN_EIGENVALS, - OPTFLOW_FARNEBACK_GAUSSIAN = 256 -}; -//! constructs a pyramid which can be used as input for calcOpticalFlowPyrLK -CV_EXPORTS_W int buildOpticalFlowPyramid(InputArray img, OutputArrayOfArrays pyramid, - Size winSize, int maxLevel, bool withDerivatives = true, - int pyrBorder = BORDER_REFLECT_101, int derivBorder = BORDER_CONSTANT, - bool tryReuseInputImage = true); - -//! computes sparse optical flow using multi-scale Lucas-Kanade algorithm -CV_EXPORTS_W void calcOpticalFlowPyrLK( InputArray prevImg, InputArray nextImg, - InputArray prevPts, InputOutputArray nextPts, - OutputArray status, OutputArray err, - Size winSize=Size(21,21), int maxLevel=3, - TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 30, 0.01), - int flags=0, double minEigThreshold=1e-4); - -//! computes dense optical flow using Farneback algorithm -CV_EXPORTS_W void calcOpticalFlowFarneback( InputArray prev, InputArray next, - InputOutputArray flow, double pyr_scale, int levels, int winsize, - int iterations, int poly_n, double poly_sigma, int flags ); - -//! estimates the best-fit Euqcidean, similarity, affine or perspective transformation -// that maps one 2D point set to another or one image to another. -CV_EXPORTS_W Mat estimateRigidTransform( InputArray src, InputArray dst, - bool fullAffine); - -enum -{ - MOTION_TRANSLATION=0, - MOTION_EUCLIDEAN=1, - MOTION_AFFINE=2, - MOTION_HOMOGRAPHY=3 -}; - -//! estimates the best-fit Translation, Euclidean, Affine or Perspective Transformation -// with respect to Enhanced Correlation Coefficient criterion that maps one image to -// another (area-based alignment) -// -// see reference: -// Evangelidis, G. E., Psarakis, E.Z., Parametric Image Alignment using -// Enhanced Correlation Coefficient Maximization, PAMI, 30(8), 2008 - -CV_EXPORTS_W double findTransformECC(InputArray templateImage, - InputArray inputImage, - InputOutputArray warpMatrix, - int motionType=MOTION_AFFINE, - TermCriteria criteria=TermCriteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001)); - - -//! computes dense optical flow using Simple Flow algorithm -CV_EXPORTS_W void calcOpticalFlowSF(InputArray from, - InputArray to, - OutputArray flow, - int layers, - int averaging_block_size, - int max_flow); - -CV_EXPORTS_W void calcOpticalFlowSF(InputArray from, - InputArray to, - OutputArray flow, - int layers, - int averaging_block_size, - int max_flow, - double sigma_dist, - double sigma_color, - int postprocess_window, - double sigma_dist_fix, - double sigma_color_fix, - double occ_thr, - int upscale_averaging_radius, - double upscale_sigma_dist, - double upscale_sigma_color, - double speed_up_thr); class CV_EXPORTS DenseOpticalFlow : public Algorithm { public: - virtual void calc(InputArray I0, InputArray I1, InputOutputArray flow) = 0; + virtual void calc( InputArray I0, InputArray I1, InputOutputArray flow ) = 0; virtual void collectGarbage() = 0; }; @@ -390,8 +191,6 @@ public: // [2] Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation". CV_EXPORTS Ptr createOptFlow_DualTVL1(); -} - -#endif +} // cv #endif diff --git a/modules/video/include/opencv2/video/tracking_c.h b/modules/video/include/opencv2/video/tracking_c.h new file mode 100644 index 000000000..e05a0b3ad --- /dev/null +++ b/modules/video/include/opencv2/video/tracking_c.h @@ -0,0 +1,227 @@ +/*M/////////////////////////////////////////////////////////////////////////////////////// +// +// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. +// +// By downloading, copying, installing or using the software you agree to this license. +// If you do not agree to this license, do not download, install, +// copy or use the software. +// +// +// License Agreement +// For Open Source Computer Vision Library +// +// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +// Copyright (C) 2009, Willow Garage Inc., all rights reserved. +// Copyright (C) 2013, OpenCV Foundation, all rights reserved. +// Third party copyrights are property of their respective owners. +// +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistribution's of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistribution's in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * The name of the copyright holders may not be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// This software is provided by the copyright holders and contributors "as is" and +// any express or implied warranties, including, but not limited to, the implied +// warranties of merchantability and fitness for a particular purpose are disclaimed. +// In no event shall the Intel Corporation or contributors be liable for any direct, +// indirect, incidental, special, exemplary, or consequential damages +// (including, but not limited to, procurement of substitute goods or services; +// loss of use, data, or profits; or business interruption) however caused +// and on any theory of liability, whether in contract, strict liability, +// or tort (including negligence or otherwise) arising in any way out of +// the use of this software, even if advised of the possibility of such damage. +// +//M*/ + +#ifndef __OPENCV_TRACKING_C_H__ +#define __OPENCV_TRACKING_C_H__ + +#include "opencv2/imgproc/types_c.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/****************************************************************************************\ +* Motion Analysis * +\****************************************************************************************/ + +/************************************ optical flow ***************************************/ + +#define CV_LKFLOW_PYR_A_READY 1 +#define CV_LKFLOW_PYR_B_READY 2 +#define CV_LKFLOW_INITIAL_GUESSES 4 +#define CV_LKFLOW_GET_MIN_EIGENVALS 8 + +/* It is Lucas & Kanade method, modified to use pyramids. + Also it does several iterations to get optical flow for + every point at every pyramid level. + Calculates optical flow between two images for certain set of points (i.e. + it is a "sparse" optical flow, which is opposite to the previous 3 methods) */ +CVAPI(void) cvCalcOpticalFlowPyrLK( const CvArr* prev, const CvArr* curr, + CvArr* prev_pyr, CvArr* curr_pyr, + const CvPoint2D32f* prev_features, + CvPoint2D32f* curr_features, + int count, + CvSize win_size, + int level, + char* status, + float* track_error, + CvTermCriteria criteria, + int flags ); + + +/* Modification of a previous sparse optical flow algorithm to calculate + affine flow */ +CVAPI(void) cvCalcAffineFlowPyrLK( const CvArr* prev, const CvArr* curr, + CvArr* prev_pyr, CvArr* curr_pyr, + const CvPoint2D32f* prev_features, + CvPoint2D32f* curr_features, + float* matrices, int count, + CvSize win_size, int level, + char* status, float* track_error, + CvTermCriteria criteria, int flags ); + +/* Estimate rigid transformation between 2 images or 2 point sets */ +CVAPI(int) cvEstimateRigidTransform( const CvArr* A, const CvArr* B, + CvMat* M, int full_affine ); + +/* Estimate optical flow for each pixel using the two-frame G. Farneback algorithm */ +CVAPI(void) cvCalcOpticalFlowFarneback( const CvArr* prev, const CvArr* next, + CvArr* flow, double pyr_scale, int levels, + int winsize, int iterations, int poly_n, + double poly_sigma, int flags ); + +/********************************* motion templates *************************************/ + +/****************************************************************************************\ +* All the motion template functions work only with single channel images. * +* Silhouette image must have depth IPL_DEPTH_8U or IPL_DEPTH_8S * +* Motion history image must have depth IPL_DEPTH_32F, * +* Gradient mask - IPL_DEPTH_8U or IPL_DEPTH_8S, * +* Motion orientation image - IPL_DEPTH_32F * +* Segmentation mask - IPL_DEPTH_32F * +* All the angles are in degrees, all the times are in milliseconds * +\****************************************************************************************/ + +/* Updates motion history image given motion silhouette */ +CVAPI(void) cvUpdateMotionHistory( const CvArr* silhouette, CvArr* mhi, + double timestamp, double duration ); + +/* Calculates gradient of the motion history image and fills + a mask indicating where the gradient is valid */ +CVAPI(void) cvCalcMotionGradient( const CvArr* mhi, CvArr* mask, CvArr* orientation, + double delta1, double delta2, + int aperture_size CV_DEFAULT(3)); + +/* Calculates average motion direction within a selected motion region + (region can be selected by setting ROIs and/or by composing a valid gradient mask + with the region mask) */ +CVAPI(double) cvCalcGlobalOrientation( const CvArr* orientation, const CvArr* mask, + const CvArr* mhi, double timestamp, + double duration ); + +/* Splits a motion history image into a few parts corresponding to separate independent motions + (e.g. left hand, right hand) */ +CVAPI(CvSeq*) cvSegmentMotion( const CvArr* mhi, CvArr* seg_mask, + CvMemStorage* storage, + double timestamp, double seg_thresh ); + +/****************************************************************************************\ +* Tracking * +\****************************************************************************************/ + +/* Implements CAMSHIFT algorithm - determines object position, size and orientation + from the object histogram back project (extension of meanshift) */ +CVAPI(int) cvCamShift( const CvArr* prob_image, CvRect window, + CvTermCriteria criteria, CvConnectedComp* comp, + CvBox2D* box CV_DEFAULT(NULL) ); + +/* Implements MeanShift algorithm - determines object position + from the object histogram back project */ +CVAPI(int) cvMeanShift( const CvArr* prob_image, CvRect window, + CvTermCriteria criteria, CvConnectedComp* comp ); + +/* +standard Kalman filter (in G. Welch' and G. Bishop's notation): + + x(k)=A*x(k-1)+B*u(k)+w(k) p(w)~N(0,Q) + z(k)=H*x(k)+v(k), p(v)~N(0,R) +*/ +typedef struct CvKalman +{ + int MP; /* number of measurement vector dimensions */ + int DP; /* number of state vector dimensions */ + int CP; /* number of control vector dimensions */ + + /* backward compatibility fields */ +#if 1 + float* PosterState; /* =state_pre->data.fl */ + float* PriorState; /* =state_post->data.fl */ + float* DynamMatr; /* =transition_matrix->data.fl */ + float* MeasurementMatr; /* =measurement_matrix->data.fl */ + float* MNCovariance; /* =measurement_noise_cov->data.fl */ + float* PNCovariance; /* =process_noise_cov->data.fl */ + float* KalmGainMatr; /* =gain->data.fl */ + float* PriorErrorCovariance;/* =error_cov_pre->data.fl */ + float* PosterErrorCovariance;/* =error_cov_post->data.fl */ + float* Temp1; /* temp1->data.fl */ + float* Temp2; /* temp2->data.fl */ +#endif + + CvMat* state_pre; /* predicted state (x'(k)): + x(k)=A*x(k-1)+B*u(k) */ + CvMat* state_post; /* corrected state (x(k)): + x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) */ + CvMat* transition_matrix; /* state transition matrix (A) */ + CvMat* control_matrix; /* control matrix (B) + (it is not used if there is no control)*/ + CvMat* measurement_matrix; /* measurement matrix (H) */ + CvMat* process_noise_cov; /* process noise covariance matrix (Q) */ + CvMat* measurement_noise_cov; /* measurement noise covariance matrix (R) */ + CvMat* error_cov_pre; /* priori error estimate covariance matrix (P'(k)): + P'(k)=A*P(k-1)*At + Q)*/ + CvMat* gain; /* Kalman gain matrix (K(k)): + K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)*/ + CvMat* error_cov_post; /* posteriori error estimate covariance matrix (P(k)): + P(k)=(I-K(k)*H)*P'(k) */ + CvMat* temp1; /* temporary matrices */ + CvMat* temp2; + CvMat* temp3; + CvMat* temp4; + CvMat* temp5; +} CvKalman; + +/* Creates Kalman filter and sets A, B, Q, R and state to some initial values */ +CVAPI(CvKalman*) cvCreateKalman( int dynam_params, int measure_params, + int control_params CV_DEFAULT(0)); + +/* Releases Kalman filter state */ +CVAPI(void) cvReleaseKalman( CvKalman** kalman); + +/* Updates Kalman filter by time (predicts future state of the system) */ +CVAPI(const CvMat*) cvKalmanPredict( CvKalman* kalman, + const CvMat* control CV_DEFAULT(NULL)); + +/* Updates Kalman filter by measurement + (corrects state of the system and internal matrices) */ +CVAPI(const CvMat*) cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement ); + +#define cvKalmanUpdateByTime cvKalmanPredict +#define cvKalmanUpdateByMeasurement cvKalmanCorrect + + +#ifdef __cplusplus +} // extern "C" +#endif + + +#endif // __OPENCV_TRACKING_C_H__ diff --git a/modules/video/perf/perf_ecc.cpp b/modules/video/perf/perf_ecc.cpp index 66fad48bb..4f0709b88 100644 --- a/modules/video/perf/perf_ecc.cpp +++ b/modules/video/perf/perf_ecc.cpp @@ -35,7 +35,7 @@ PERF_TEST_P(TransformationType, findTransformECC, /*testing::ValuesIn(MotionType 0.f, 1.f, 11.839f); warpAffine(img, templateImage, warpGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; case MOTION_EUCLIDEAN: angle = CV_PI/30; @@ -43,20 +43,20 @@ PERF_TEST_P(TransformationType, findTransformECC, /*testing::ValuesIn(MotionType warpGround = (Mat_(2,3) << (float)cos(angle), (float)-sin(angle), 12.123f, (float)sin(angle), (float)cos(angle), 14.789f); warpAffine(img, templateImage, warpGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; case MOTION_AFFINE: warpGround = (Mat_(2,3) << 0.98f, 0.03f, 15.523f, -0.02f, 0.95f, 10.456f); warpAffine(img, templateImage, warpGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; case MOTION_HOMOGRAPHY: warpGround = (Mat_(3,3) << 0.98f, 0.03f, 15.523f, -0.02f, 0.95f, 10.456f, 0.0002f, 0.0003f, 1.f); warpPerspective(img, templateImage, warpGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; } diff --git a/modules/video/perf/perf_optflowpyrlk.cpp b/modules/video/perf/perf_optflowpyrlk.cpp index d34bd7215..9ea3190c5 100644 --- a/modules/video/perf/perf_optflowpyrlk.cpp +++ b/modules/video/perf/perf_optflowpyrlk.cpp @@ -50,7 +50,7 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize, OpticalFlowPyrLK_full, testing::Combine( int winSize = get<4>(GetParam()); int maxLevel = 2; - TermCriteria criteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 7, 0.001); + TermCriteria criteria(TermCriteria::COUNT|TermCriteria::EPS, 7, 0.001); int flags = 0; double minEigThreshold = 1e-4; @@ -124,7 +124,7 @@ PERF_TEST_P(Path_Idx_Cn_NPoints_WSize_Deriv, OpticalFlowPyrLK_self, testing::Com bool withDerivatives = get<5>(GetParam()); int maxLevel = 2; - TermCriteria criteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 7, 0.001); + TermCriteria criteria(TermCriteria::COUNT|TermCriteria::EPS, 7, 0.001); int flags = 0; double minEigThreshold = 1e-4; diff --git a/modules/video/src/affineflow.cpp b/modules/video/src/affineflow.cpp index bc3fdba2f..bad9da8af 100644 --- a/modules/video/src/affineflow.cpp +++ b/modules/video/src/affineflow.cpp @@ -42,6 +42,7 @@ #include "precomp.hpp" #include "opencv2/imgproc/imgproc_c.h" +#include "opencv2/video/tracking_c.h" // to be moved to legacy @@ -541,7 +542,7 @@ cvCalcAffineFlowPyrLK( const void* arrA, const void* arrB, if( !matrices ) CV_Error( CV_StsNullPtr, "" ); - imgSize = cvGetMatSize( imgA ); + imgSize = cv::Size(imgA->cols, imgA->rows); if( pyrA ) { diff --git a/modules/video/src/bgfg_gaussmix.cpp b/modules/video/src/bgfg_gaussmix.cpp index 2be2691c4..ebdd19bd0 100644 --- a/modules/video/src/bgfg_gaussmix.cpp +++ b/modules/video/src/bgfg_gaussmix.cpp @@ -124,7 +124,7 @@ public: virtual void getBackgroundImage(OutputArray) const { - CV_Error( CV_StsNotImplemented, "" ); + CV_Error( Error::StsNotImplemented, "" ); } virtual int getHistory() const { return history; } @@ -458,7 +458,7 @@ void BackgroundSubtractorMOGImpl::apply(InputArray _image, OutputArray _fgmask, else if( image.type() == CV_8UC3 ) process8uC3( image, fgmask, learningRate, bgmodel, nmixtures, backgroundRatio, varThreshold, noiseSigma ); else - CV_Error( CV_StsUnsupportedFormat, "Only 1- and 3-channel 8-bit images are supported in BackgroundSubtractorMOG" ); + CV_Error( Error::StsUnsupportedFormat, "Only 1- and 3-channel 8-bit images are supported in BackgroundSubtractorMOG" ); } Ptr createBackgroundSubtractorMOG(int history, int nmixtures, diff --git a/modules/video/src/bgfg_gaussmix2.cpp b/modules/video/src/bgfg_gaussmix2.cpp index 1337a1f5b..35f5d0678 100644 --- a/modules/video/src/bgfg_gaussmix2.cpp +++ b/modules/video/src/bgfg_gaussmix2.cpp @@ -761,7 +761,7 @@ void BackgroundSubtractorMOG2Impl::getBackgroundImage(OutputArray backgroundImag } default: - CV_Error(CV_StsUnsupportedFormat, ""); + CV_Error(Error::StsUnsupportedFormat, ""); } } diff --git a/modules/video/src/bgfg_gmg.cpp b/modules/video/src/bgfg_gmg.cpp index 20ddeba44..e3e423211 100644 --- a/modules/video/src/bgfg_gmg.cpp +++ b/modules/video/src/bgfg_gmg.cpp @@ -134,7 +134,7 @@ public: virtual void getBackgroundImage(OutputArray) const { - CV_Error( CV_StsNotImplemented, "" ); + CV_Error( Error::StsNotImplemented, "" ); } virtual void write(FileStorage& fs) const diff --git a/modules/video/src/camshift.cpp b/modules/video/src/camshift.cpp index 5cad1b82a..9ba02381d 100644 --- a/modules/video/src/camshift.cpp +++ b/modules/video/src/camshift.cpp @@ -49,7 +49,7 @@ int cv::meanShift( InputArray _probImage, Rect& window, TermCriteria criteria ) CV_Assert( mat.channels() == 1 ); if( window.height <= 0 || window.width <= 0 ) - CV_Error( CV_StsBadArg, "Input window has non-positive sizes" ); + CV_Error( Error::StsBadArg, "Input window has non-positive sizes" ); window = window & Rect(0, 0, mat.cols, mat.rows); diff --git a/modules/video/src/compat_video.cpp b/modules/video/src/compat_video.cpp index 5f70c893e..e6dc96030 100644 --- a/modules/video/src/compat_video.cpp +++ b/modules/video/src/compat_video.cpp @@ -41,6 +41,7 @@ //M*/ #include "precomp.hpp" +#include "opencv2/video/tracking_c.h" /////////////////////////// Meanshift & CAMShift /////////////////////////// diff --git a/modules/video/src/ecc.cpp b/modules/video/src/ecc.cpp index ac710d445..f56e1f24b 100644 --- a/modules/video/src/ecc.cpp +++ b/modules/video/src/ecc.cpp @@ -325,14 +325,14 @@ double cv::findTransformECC(InputArray templateImage, if( ! (src.type()==dst.type())) - CV_Error( CV_StsUnmatchedFormats, "Both input images must have the same data type" ); + CV_Error( Error::StsUnmatchedFormats, "Both input images must have the same data type" ); //accept only 1-channel images if( src.type() != CV_8UC1 && src.type()!= CV_32FC1) - CV_Error( CV_StsUnsupportedFormat, "Images must have 8uC1 or 32fC1 type"); + CV_Error( Error::StsUnsupportedFormat, "Images must have 8uC1 or 32fC1 type"); if( map.type() != CV_32FC1) - CV_Error( CV_StsUnsupportedFormat, "warpMatrix must be single-channel floating-point matrix"); + CV_Error( Error::StsUnsupportedFormat, "warpMatrix must be single-channel floating-point matrix"); CV_Assert (map.cols == 3); CV_Assert (map.rows == 2 || map.rows ==3); @@ -428,8 +428,8 @@ double cv::findTransformECC(InputArray templateImage, Mat deltaP = Mat(numberOfParameters, 1, CV_32F);//transformation parameter correction Mat error = Mat(hs, ws, CV_32F);//error as 2D matrix - const int imageFlags = CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP; - const int maskFlags = CV_INTER_NN+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP; + const int imageFlags = INTER_LINEAR + WARP_INVERSE_MAP; + const int maskFlags = INTER_NEAREST + WARP_INVERSE_MAP; // iteratively update map_matrix @@ -504,7 +504,7 @@ double cv::findTransformECC(InputArray templateImage, if (lambda_d <= 0.0) { rho = -1; - CV_Error(CV_StsNoConv, "The algorithm stopped before its convergence. The correlation is going to be minimized. Images may be uncorrelated or non-overlapped"); + CV_Error(Error::StsNoConv, "The algorithm stopped before its convergence. The correlation is going to be minimized. Images may be uncorrelated or non-overlapped"); } const double lambda = (lambda_n/lambda_d); diff --git a/modules/video/src/lkpyramid.cpp b/modules/video/src/lkpyramid.cpp index 019397f94..e46517268 100644 --- a/modules/video/src/lkpyramid.cpp +++ b/modules/video/src/lkpyramid.cpp @@ -328,7 +328,7 @@ void cv::detail::LKTrackerInvoker::operator()(const BlockedRange& range) const float minEig = (A22 + A11 - std::sqrt((A11-A22)*(A11-A22) + 4.f*A12*A12))/(2*winSize.width*winSize.height); - if( err && (flags & CV_LKFLOW_GET_MIN_EIGENVALS) != 0 ) + if( err && (flags & OPTFLOW_LK_GET_MIN_EIGENVALS) != 0 ) err[ptidx] = (float)minEig; if( minEig < minEigThreshold || D < FLT_EPSILON ) @@ -452,7 +452,7 @@ void cv::detail::LKTrackerInvoker::operator()(const BlockedRange& range) const prevDelta = delta; } - if( status[ptidx] && err && level == 0 && (flags & CV_LKFLOW_GET_MIN_EIGENVALS) == 0 ) + if( status[ptidx] && err && level == 0 && (flags & OPTFLOW_LK_GET_MIN_EIGENVALS) == 0 ) { Point2f nextPoint = nextPts[ptidx] - halfWin; Point inextPoint; @@ -864,10 +864,10 @@ cv::Mat cv::estimateRigidTransform( InputArray src1, InputArray src2, bool fullA int good_count = 0; if( A.size() != B.size() ) - CV_Error( CV_StsUnmatchedSizes, "Both input images must have the same size" ); + CV_Error( Error::StsUnmatchedSizes, "Both input images must have the same size" ); if( A.type() != B.type() ) - CV_Error( CV_StsUnmatchedFormats, "Both input images must have the same data type" ); + CV_Error( Error::StsUnmatchedFormats, "Both input images must have the same data type" ); int count = A.checkVector(2); @@ -947,7 +947,7 @@ cv::Mat cv::estimateRigidTransform( InputArray src1, InputArray src2, bool fullA pB.resize(count); } else - CV_Error( CV_StsUnsupportedFormat, "Both input images must have either 8uC1 or 8uC3 type" ); + CV_Error( Error::StsUnsupportedFormat, "Both input images must have either 8uC1 or 8uC3 type" ); good_idx.resize(count); diff --git a/modules/video/src/motempl.cpp b/modules/video/src/motempl.cpp index 7d992684b..aa6d12d8d 100644 --- a/modules/video/src/motempl.cpp +++ b/modules/video/src/motempl.cpp @@ -123,13 +123,13 @@ void cv::calcMotionGradient( InputArray _mhi, OutputArray _mask, Mat orient = _orientation.getMat(); if( aperture_size < 3 || aperture_size > 7 || (aperture_size & 1) == 0 ) - CV_Error( CV_StsOutOfRange, "aperture_size must be 3, 5 or 7" ); + CV_Error( Error::StsOutOfRange, "aperture_size must be 3, 5 or 7" ); if( delta1 <= 0 || delta2 <= 0 ) - CV_Error( CV_StsOutOfRange, "both delta's must be positive" ); + CV_Error( Error::StsOutOfRange, "both delta's must be positive" ); if( mhi.type() != CV_32FC1 ) - CV_Error( CV_StsUnsupportedFormat, + CV_Error( Error::StsUnsupportedFormat, "MHI must be single-channel floating-point images" ); if( orient.data == mhi.data ) diff --git a/modules/video/src/optflowgf.cpp b/modules/video/src/optflowgf.cpp index 6784a55cd..df2559a3e 100644 --- a/modules/video/src/optflowgf.cpp +++ b/modules/video/src/optflowgf.cpp @@ -627,7 +627,7 @@ void cv::calcOpticalFlowFarneback( InputArray _prev0, InputArray _next0, { img[i]->convertTo(fimg, CV_32F); GaussianBlur(fimg, fimg, Size(smooth_sz, smooth_sz), sigma, sigma); - resize( fimg, I, Size(width, height), CV_INTER_LINEAR ); + resize( fimg, I, Size(width, height), INTER_LINEAR ); FarnebackPolyExp( I, R[i], poly_n, poly_sigma ); } diff --git a/modules/video/src/precomp.hpp b/modules/video/src/precomp.hpp index fdbbb0ae1..5cd7ec381 100644 --- a/modules/video/src/precomp.hpp +++ b/modules/video/src/precomp.hpp @@ -44,12 +44,11 @@ #define __OPENCV_PRECOMP_H__ #include "opencv2/video.hpp" +#include "opencv2/video/tracking_c.h" #include "opencv2/core/utility.hpp" #include "opencv2/core/private.hpp" -#include - #ifdef HAVE_TEGRA_OPTIMIZATION #include "opencv2/video/video_tegra.hpp" #endif diff --git a/modules/video/test/test_backgroundsubtractor_gbh.cpp b/modules/video/test/test_backgroundsubtractor_gbh.cpp index 649a18b85..a7261516a 100644 --- a/modules/video/test/test_backgroundsubtractor_gbh.cpp +++ b/modules/video/test/test_backgroundsubtractor_gbh.cpp @@ -41,7 +41,7 @@ void CV_BackgroundSubtractorTest::run(int) Mat fgmask; if (fgbg.empty()) - CV_Error(CV_StsError,"Failed to create Algorithm\n"); + CV_Error(Error::StsError,"Failed to create Algorithm\n"); /** * Set a few parameters diff --git a/modules/video/test/test_camshift.cpp b/modules/video/test/test_camshift.cpp index 4a2ddc734..f003286d4 100644 --- a/modules/video/test/test_camshift.cpp +++ b/modules/video/test/test_camshift.cpp @@ -40,6 +40,7 @@ //M*/ #include "test_precomp.hpp" +#include "opencv2/video/tracking_c.h" using namespace cv; using namespace std; diff --git a/modules/video/test/test_ecc.cpp b/modules/video/test/test_ecc.cpp index 58389290b..4065e6182 100644 --- a/modules/video/test/test_ecc.cpp +++ b/modules/video/test/test_ecc.cpp @@ -138,7 +138,7 @@ bool CV_ECC_Test_Translation::testTranslation(int from) Mat warpedImage; warpAffine(testImg, warpedImage, translationGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); Mat mapTranslation = (Mat_(2,3) << 1, 0, 0, 0, 1, 0); @@ -213,7 +213,7 @@ bool CV_ECC_Test_Euclidean::testEuclidean(int from) Mat warpedImage; warpAffine(testImg, warpedImage, euclideanGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); Mat mapEuclidean = (Mat_(2,3) << 1, 0, 0, 0, 1, 0); @@ -288,7 +288,7 @@ bool CV_ECC_Test_Affine::testAffine(int from) Mat warpedImage; warpAffine(testImg, warpedImage, affineGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); Mat mapAffine = (Mat_(2,3) << 1, 0, 0, 0, 1, 0); @@ -363,7 +363,7 @@ bool CV_ECC_Test_Homography::testHomography(int from) Mat warpedImage; warpPerspective(testImg, warpedImage, homoGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); Mat mapHomography = Mat::eye(3, 3, CV_32F); diff --git a/modules/video/test/test_estimaterigid.cpp b/modules/video/test/test_estimaterigid.cpp index 47122fe59..5259ce7ee 100644 --- a/modules/video/test/test_estimaterigid.cpp +++ b/modules/video/test/test_estimaterigid.cpp @@ -93,18 +93,18 @@ bool CV_RigidTransform_Test::testNPoints(int from) progress = update_progress(progress, k, ntests, 0); Mat aff(2, 3, CV_64F); - rng.fill(aff, CV_RAND_UNI, Scalar(-2), Scalar(2)); + rng.fill(aff, RNG::UNIFORM, Scalar(-2), Scalar(2)); int n = (unsigned)rng % 100 + 10; Mat fpts(1, n, CV_32FC2); Mat tpts(1, n, CV_32FC2); - rng.fill(fpts, CV_RAND_UNI, Scalar(0,0), Scalar(10,10)); + rng.fill(fpts, RNG::UNIFORM, Scalar(0,0), Scalar(10,10)); transform(fpts.ptr(), fpts.ptr() + n, tpts.ptr(), WrapAff2D(aff)); Mat noise(1, n, CV_32FC2); - rng.fill(noise, CV_RAND_NORMAL, Scalar::all(0), Scalar::all(0.001*(n<=7 ? 0 : n <= 30 ? 1 : 10))); + rng.fill(noise, RNG::NORMAL, Scalar::all(0), Scalar::all(0.001*(n<=7 ? 0 : n <= 30 ? 1 : 10))); tpts += noise; Mat aff_est = estimateRigidTransform(fpts, tpts, true); diff --git a/modules/video/test/test_kalman.cpp b/modules/video/test/test_kalman.cpp index 17b3ee6a4..2aa74e1c2 100644 --- a/modules/video/test/test_kalman.cpp +++ b/modules/video/test/test_kalman.cpp @@ -40,6 +40,7 @@ //M*/ #include "test_precomp.hpp" +#include "opencv2/video/tracking_c.h" using namespace cv; diff --git a/modules/video/test/test_motiontemplates.cpp b/modules/video/test/test_motiontemplates.cpp index 082131737..7779327b1 100644 --- a/modules/video/test/test_motiontemplates.cpp +++ b/modules/video/test/test_motiontemplates.cpp @@ -169,9 +169,7 @@ double CV_UpdateMHITest::get_success_error_level( int /*test_case_idx*/, int /*i void CV_UpdateMHITest::run_func() { - CvMat m = test_mat[INPUT_OUTPUT][0]; cv::updateMotionHistory( test_mat[INPUT][0], test_mat[INPUT_OUTPUT][0], timestamp, duration); - m = test_mat[INPUT_OUTPUT][0]; } @@ -203,8 +201,7 @@ static void test_MHIGradient( const Mat& mhi, Mat& mask, Mat& orientation, if( delta1 > delta2 ) { - double t; - CV_SWAP( delta1, delta2, t ); + std::swap( delta1, delta2 ); } for( int i = 0; i < mhi.rows; i++ ) @@ -417,7 +414,7 @@ void CV_MHIGlobalOrientTest::get_test_array_types_and_sizes( int test_case_idx, { RNG& rng = ts->get_rng(); CV_MHIBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types ); - CvSize size = sizes[INPUT][0]; + Size size = sizes[INPUT][0]; size.width = MAX( size.width, 16 ); size.height = MAX( size.height, 16 ); @@ -430,8 +427,7 @@ void CV_MHIGlobalOrientTest::get_test_array_types_and_sizes( int test_case_idx, max_angle = cvtest::randReal(rng)*359.9; if( min_angle >= max_angle ) { - double t; - CV_SWAP( min_angle, max_angle, t ); + std::swap( min_angle, max_angle); } max_angle += 0.1; duration = exp(cvtest::randReal(rng)*max_log_duration); @@ -474,7 +470,7 @@ int CV_MHIGlobalOrientTest::validate_test_results( int test_case_idx ) test_mat[INPUT][0], timestamp, duration ); double err_level = get_success_error_level( test_case_idx, 0, 0 ); int code = cvtest::TS::OK; - int nz = cvCountNonZero( test_array[INPUT][1] ); + int nz = countNonZero( test_mat[INPUT][1] ); if( nz > 32 && !(min_angle - err_level <= angle && max_angle + err_level >= angle) && diff --git a/modules/video/test/test_optflowpyrlk.cpp b/modules/video/test/test_optflowpyrlk.cpp index 309bf5e30..e4aa5e572 100644 --- a/modules/video/test/test_optflowpyrlk.cpp +++ b/modules/video/test/test_optflowpyrlk.cpp @@ -40,6 +40,7 @@ //M*/ #include "test_precomp.hpp" +#include "opencv2/video/tracking_c.h" /* ///////////////////// pyrlk_test ///////////////////////// */ diff --git a/modules/videostab/src/global_motion.cpp b/modules/videostab/src/global_motion.cpp index 0af1129a9..fcaf9932e 100644 --- a/modules/videostab/src/global_motion.cpp +++ b/modules/videostab/src/global_motion.cpp @@ -754,7 +754,7 @@ Mat KeypointBasedMotionEstimatorGpu::estimate(const gpu::GpuMat &frame0, const g grayFrame0 = frame0; else { - gpu::cvtColor(frame0, grayFrame0_, CV_BGR2GRAY); + gpu::cvtColor(frame0, grayFrame0_, COLOR_BGR2GRAY); grayFrame0 = grayFrame0_; } diff --git a/modules/videostab/src/inpainting.cpp b/modules/videostab/src/inpainting.cpp index e24281b5e..09ae1423c 100644 --- a/modules/videostab/src/inpainting.cpp +++ b/modules/videostab/src/inpainting.cpp @@ -357,7 +357,7 @@ void MotionInpainter::inpaint(int idx, Mat &frame, Mat &mask) mask1_.setTo(255); } - cvtColor(frame, grayFrame_, CV_BGR2GRAY); + cvtColor(frame, grayFrame_, COLOR_BGR2GRAY); MotionInpaintBody body; body.rad = 2; @@ -383,7 +383,7 @@ void MotionInpainter::inpaint(int idx, Mat &frame, Mat &mask) frame1_, transformedFrame1_, motion1to0, frame1_.size(), INTER_LINEAR, borderMode_); - cvtColor(transformedFrame1_, transformedGrayFrame1_, CV_BGR2GRAY); + cvtColor(transformedFrame1_, transformedGrayFrame1_, COLOR_BGR2GRAY); // warp mask diff --git a/samples/c/fback_c.c b/samples/c/fback_c.c index 0fd85688d..e0317a442 100644 --- a/samples/c/fback_c.c +++ b/samples/c/fback_c.c @@ -1,4 +1,4 @@ -#include "opencv2/video/tracking.hpp" +#include "opencv2/video/tracking_c.h" #include "opencv2/highgui/highgui_c.h" #include "opencv2/imgproc/imgproc_c.h" #include diff --git a/samples/c/motempl.c b/samples/c/motempl.c index 56ec2f104..76b69ade7 100644 --- a/samples/c/motempl.c +++ b/samples/c/motempl.c @@ -1,6 +1,6 @@ -#include "opencv2/video/tracking.hpp" -#include "opencv2/highgui/highgui_c.h" +#include "opencv2/video/tracking_c.h" #include "opencv2/imgproc/imgproc_c.h" +#include "opencv2/highgui/highgui_c.h" #include #include #include diff --git a/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp b/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp index bfae1ebce..6a9bcb383 100644 --- a/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp +++ b/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp @@ -69,7 +69,7 @@ static void drawPlot(const cv::Mat curve, const std::string figureTitle, const i { cv::Mat rgbIntImg; outputMat.convertTo(rgbIntImg, CV_8UC3); - cvtColor(rgbIntImg, intGrayImage, CV_BGR2GRAY); + cv::cvtColor(rgbIntImg, intGrayImage, cv::COLOR_BGR2GRAY); } // get histogram density probability in order to cut values under above edges limits (here 5-95%)... usefull for HDR pixel errors cancellation diff --git a/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp b/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp index 7c47fcf66..ee28fafda 100644 --- a/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp +++ b/samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping_video.cpp @@ -88,7 +88,7 @@ static void rescaleGrayLevelMat(const cv::Mat &inputMat, cv::Mat &outputMat, con { cv::Mat rgbIntImg; normalisedImage.convertTo(rgbIntImg, CV_8UC3); - cvtColor(rgbIntImg, intGrayImage, CV_BGR2GRAY); + cv::cvtColor(rgbIntImg, intGrayImage, cv::COLOR_BGR2GRAY); } // get histogram density probability in order to cut values under above edges limits (here 5-95%)... usefull for HDR pixel errors cancellation diff --git a/samples/cpp/camshiftdemo.cpp b/samples/cpp/camshiftdemo.cpp index a61996e48..6439cef78 100644 --- a/samples/cpp/camshiftdemo.cpp +++ b/samples/cpp/camshiftdemo.cpp @@ -114,7 +114,7 @@ int main( int argc, const char** argv ) if( !paused ) { - cvtColor(image, hsv, CV_BGR2HSV); + cvtColor(image, hsv, COLOR_BGR2HSV); if( trackObject ) { @@ -130,7 +130,7 @@ int main( int argc, const char** argv ) { Mat roi(hue, selection), maskroi(mask, selection); calcHist(&roi, 1, 0, maskroi, hist, 1, &hsize, &phranges); - normalize(hist, hist, 0, 255, CV_MINMAX); + normalize(hist, hist, 0, 255, NORM_MINMAX); trackWindow = selection; trackObject = 1; @@ -140,7 +140,7 @@ int main( int argc, const char** argv ) Mat buf(1, hsize, CV_8UC3); for( int i = 0; i < hsize; i++ ) buf.at(i) = Vec3b(saturate_cast(i*180./hsize), 255, 255); - cvtColor(buf, buf, CV_HSV2BGR); + cvtColor(buf, buf, COLOR_HSV2BGR); for( int i = 0; i < hsize; i++ ) { @@ -154,7 +154,7 @@ int main( int argc, const char** argv ) calcBackProject(&hue, 1, 0, hist, backproj, &phranges); backproj &= mask; RotatedRect trackBox = CamShift(backproj, trackWindow, - TermCriteria( CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 10, 1 )); + TermCriteria( TermCriteria::EPS | TermCriteria::COUNT, 10, 1 )); if( trackWindow.area() <= 1 ) { int cols = backproj.cols, rows = backproj.rows, r = (MIN(cols, rows) + 5)/6; @@ -164,8 +164,8 @@ int main( int argc, const char** argv ) } if( backprojMode ) - cvtColor( backproj, image, CV_GRAY2BGR ); - ellipse( image, trackBox, Scalar(0,0,255), 3, CV_AA ); + cvtColor( backproj, image, COLOR_GRAY2BGR ); + ellipse( image, trackBox, Scalar(0,0,255), 3, LINE_AA ); } } else if( trackObject < 0 ) diff --git a/samples/cpp/fabmap_sample.cpp b/samples/cpp/fabmap_sample.cpp index bbe5f2b4c..8fa5b5dc0 100644 --- a/samples/cpp/fabmap_sample.cpp +++ b/samples/cpp/fabmap_sample.cpp @@ -204,7 +204,7 @@ int main(int argc, char * argv[]) { } Mat result_large(100, 100, CV_8UC1); - resize(result_small, result_large, Size(500, 500), 0, 0, CV_INTER_NN); + resize(result_small, result_large, Size(500, 500), 0, 0, INTER_NEAREST); cout << endl << "Press any key to exit" << endl; imshow("Confusion Matrix", result_large); diff --git a/samples/cpp/fback.cpp b/samples/cpp/fback.cpp index 4923e8abc..5293fd1f7 100644 --- a/samples/cpp/fback.cpp +++ b/samples/cpp/fback.cpp @@ -42,13 +42,13 @@ int main(int, char**) for(;;) { cap >> frame; - cvtColor(frame, gray, CV_BGR2GRAY); + cvtColor(frame, gray, COLOR_BGR2GRAY); if( prevgray.data ) { calcOpticalFlowFarneback(prevgray, gray, flow, 0.5, 3, 15, 3, 5, 1.2, 0); - cvtColor(prevgray, cflow, CV_GRAY2BGR); - drawOptFlowMap(flow, cflow, 16, 1.5, CV_RGB(0, 255, 0)); + cvtColor(prevgray, cflow, COLOR_GRAY2BGR); + drawOptFlowMap(flow, cflow, 16, 1.5, Scalar(0, 255, 0)); imshow("flow", cflow); } if(waitKey(30)>=0) diff --git a/samples/cpp/image_alignment.cpp b/samples/cpp/image_alignment.cpp index b251e7253..56e8209dd 100644 --- a/samples/cpp/image_alignment.cpp +++ b/samples/cpp/image_alignment.cpp @@ -238,7 +238,7 @@ int main (const int argc, const char * argv[]) warpGround = (Mat_(2,3) << 1, 0, (rng.uniform(10.f, 20.f)), 0, 1, (rng.uniform(10.f, 20.f))); warpAffine(target_image, template_image, warpGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; case MOTION_EUCLIDEAN: angle = CV_PI/30 + CV_PI*rng.uniform((double)-2.f, (double)2.f)/180; @@ -246,7 +246,7 @@ int main (const int argc, const char * argv[]) warpGround = (Mat_(2,3) << cos(angle), -sin(angle), (rng.uniform(10.f, 20.f)), sin(angle), cos(angle), (rng.uniform(10.f, 20.f))); warpAffine(target_image, template_image, warpGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; case MOTION_AFFINE: @@ -255,7 +255,7 @@ int main (const int argc, const char * argv[]) (rng.uniform(-0.03f, 0.03f)), (1-rng.uniform(-0.05f, 0.05f)), (rng.uniform(10.f, 20.f))); warpAffine(target_image, template_image, warpGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; case MOTION_HOMOGRAPHY: warpGround = (Mat_(3,3) << (1-rng.uniform(-0.05f, 0.05f)), @@ -263,7 +263,7 @@ int main (const int argc, const char * argv[]) (rng.uniform(-0.03f, 0.03f)), (1-rng.uniform(-0.05f, 0.05f)),(rng.uniform(10.f, 20.f)), (rng.uniform(0.0001f, 0.0003f)), (rng.uniform(0.0001f, 0.0003f)), 1.f); warpPerspective(target_image, template_image, warpGround, - Size(200,200), CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + Size(200,200), INTER_LINEAR + WARP_INVERSE_MAP); break; } } @@ -333,10 +333,10 @@ int main (const int argc, const char * argv[]) Mat warped_image = Mat(template_image.rows, template_image.cols, CV_32FC1); if (warp_mode != MOTION_HOMOGRAPHY) warpAffine (target_image, warped_image, warp_matrix, warped_image.size(), - CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + INTER_LINEAR + WARP_INVERSE_MAP); else warpPerspective (target_image, warped_image, warp_matrix, warped_image.size(), - CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP); + INTER_LINEAR + WARP_INVERSE_MAP); //save the warped image imwrite(warpedImFile, warped_image); diff --git a/samples/cpp/kalman.cpp b/samples/cpp/kalman.cpp index c5bb96930..1f170d384 100644 --- a/samples/cpp/kalman.cpp +++ b/samples/cpp/kalman.cpp @@ -69,18 +69,18 @@ int main(int, char**) Point measPt = calcPoint(center, R, measAngle); // plot points - #define drawCross( center, color, d ) \ - line( img, Point( center.x - d, center.y - d ), \ - Point( center.x + d, center.y + d ), color, 1, CV_AA, 0); \ - line( img, Point( center.x + d, center.y - d ), \ - Point( center.x - d, center.y + d ), color, 1, CV_AA, 0 ) + #define drawCross( center, color, d ) \ + line( img, Point( center.x - d, center.y - d ), \ + Point( center.x + d, center.y + d ), color, 1, LINE_AA, 0); \ + line( img, Point( center.x + d, center.y - d ), \ + Point( center.x - d, center.y + d ), color, 1, LINE_AA, 0 ) img = Scalar::all(0); drawCross( statePt, Scalar(255,255,255), 3 ); drawCross( measPt, Scalar(0,0,255), 3 ); drawCross( predictPt, Scalar(0,255,0), 3 ); - line( img, statePt, measPt, Scalar(0,0,255), 3, CV_AA, 0 ); - line( img, statePt, predictPt, Scalar(0,255,255), 3, CV_AA, 0 ); + line( img, statePt, measPt, Scalar(0,0,255), 3, LINE_AA, 0 ); + line( img, statePt, predictPt, Scalar(0,255,255), 3, LINE_AA, 0 ); if(theRNG().uniform(0,4) != 0) KF.correct(measurement); diff --git a/samples/cpp/lkdemo.cpp b/samples/cpp/lkdemo.cpp index 3b7fb8bcb..3913e2c2d 100644 --- a/samples/cpp/lkdemo.cpp +++ b/samples/cpp/lkdemo.cpp @@ -38,7 +38,7 @@ static void onMouse( int event, int x, int y, int /*flags*/, void* /*param*/ ) int main( int argc, char** argv ) { VideoCapture cap; - TermCriteria termcrit(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03); + TermCriteria termcrit(TermCriteria::COUNT|TermCriteria::EPS,20,0.03); Size subPixWinSize(10,10), winSize(31,31); const int MAX_COUNT = 500; @@ -72,7 +72,7 @@ int main( int argc, char** argv ) break; frame.copyTo(image); - cvtColor(image, gray, CV_BGR2GRAY); + cvtColor(image, gray, COLOR_BGR2GRAY); if( nightMode ) image = Scalar::all(0); @@ -117,7 +117,7 @@ int main( int argc, char** argv ) { vector tmp; tmp.push_back(point); - cornerSubPix( gray, tmp, winSize, cvSize(-1,-1), termcrit); + cornerSubPix( gray, tmp, winSize, Size(-1,-1), termcrit); points[1].push_back(tmp[0]); addRemovePt = false; }