Move C API of opencv_video to separate file

This commit is contained in:
Andrey Kamaev 2013-04-11 17:38:33 +04:00
parent e27f4da9c6
commit 199a35a105
48 changed files with 409 additions and 376 deletions

View File

@ -1,4 +1,5 @@
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "HOGfeatures.h"
#include "cascadeclassifier.h"

View File

@ -1,4 +1,5 @@
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "haarfeatures.h"
#include "cascadeclassifier.h"

View File

@ -1,4 +1,5 @@
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "lbpfeatures.h"
#include "cascadeclassifier.h"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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);

View File

@ -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<uchar> status;
std::vector<float> 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)
{

View File

@ -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). */

View File

@ -39,6 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "opencv2/video/tracking_c.h"
CvCamShiftTracker::CvCamShiftTracker()
{

View File

@ -42,6 +42,7 @@
#include "test_precomp.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/video/tracking_c.h"
#include <string>
#include <iostream>

View File

@ -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"

View File

@ -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__

View File

@ -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 <list>
namespace cv
{
@ -66,6 +66,7 @@ public:
};
/*!
Gaussian Mixture-based Backbround/Foreground Segmentation Algorithm
@ -97,6 +98,7 @@ CV_EXPORTS_W Ptr<BackgroundSubtractorMOG>
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<BackgroundSubtractorGMG> createBackgroundSubtractorGMG(int initializationFrames=120,
double decisionThreshold=0.8);
}
} // cv
#endif

View File

@ -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<Rect>& boundingRects,
double timestamp, double segThresh);
CV_EXPORTS_W void segmentMotion( InputArray mhi, OutputArray segmask,
CV_OUT std::vector<Rect>& 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<DenseOpticalFlow> createOptFlow_DualTVL1();
}
#endif
} // cv
#endif

View File

@ -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__

View File

@ -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_<float>(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_<float>(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_<float>(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;
}

View File

@ -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;

View File

@ -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 )
{

View File

@ -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<BackgroundSubtractorMOG> createBackgroundSubtractorMOG(int history, int nmixtures,

View File

@ -761,7 +761,7 @@ void BackgroundSubtractorMOG2Impl::getBackgroundImage(OutputArray backgroundImag
}
default:
CV_Error(CV_StsUnsupportedFormat, "");
CV_Error(Error::StsUnsupportedFormat, "");
}
}

View File

@ -134,7 +134,7 @@ public:
virtual void getBackgroundImage(OutputArray) const
{
CV_Error( CV_StsNotImplemented, "" );
CV_Error( Error::StsNotImplemented, "" );
}
virtual void write(FileStorage& fs) const

View File

@ -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);

View File

@ -41,6 +41,7 @@
//M*/
#include "precomp.hpp"
#include "opencv2/video/tracking_c.h"
/////////////////////////// Meanshift & CAMShift ///////////////////////////

View File

@ -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);

View File

@ -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);

View File

@ -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 )

View File

@ -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 );
}

View File

@ -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 <list>
#ifdef HAVE_TEGRA_OPTIMIZATION
#include "opencv2/video/video_tegra.hpp"
#endif

View File

@ -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

View File

@ -40,6 +40,7 @@
//M*/
#include "test_precomp.hpp"
#include "opencv2/video/tracking_c.h"
using namespace cv;
using namespace std;

View File

@ -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_<float>(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_<float>(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_<float>(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);

View File

@ -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<Point2f>(), fpts.ptr<Point2f>() + n, tpts.ptr<Point2f>(), 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);

View File

@ -40,6 +40,7 @@
//M*/
#include "test_precomp.hpp"
#include "opencv2/video/tracking_c.h"
using namespace cv;

View File

@ -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) &&

View File

@ -40,6 +40,7 @@
//M*/
#include "test_precomp.hpp"
#include "opencv2/video/tracking_c.h"
/* ///////////////////// pyrlk_test ///////////////////////// */

View File

@ -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_;
}

View File

@ -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

View File

@ -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 <stdio.h>

View File

@ -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 <time.h>
#include <stdio.h>
#include <ctype.h>

View File

@ -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

View File

@ -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

View File

@ -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<Vec3b>(i) = Vec3b(saturate_cast<uchar>(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 )

View File

@ -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);

View File

@ -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)

View File

@ -238,7 +238,7 @@ int main (const int argc, const char * argv[])
warpGround = (Mat_<float>(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_<float>(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_<float>(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);

View File

@ -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);

View File

@ -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<Point2f> 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;
}