removed C API in the following modules: photo, video, imgcodecs, videoio (#13060)
* removed C API in the following modules: photo, video, imgcodecs, videoio * trying to fix various compile errors and warnings on Windows and Linux * continue to fix compile errors and warnings * continue to fix compile errors, warnings, as well as the test failures * trying to resolve compile warnings on Android * Update cap_dc1394_v2.cpp fix warning from the new GCCpull/13088/head
parent
5087ff0814
commit
11eafca3e2
34 changed files with 389 additions and 1403 deletions
@ -1,149 +0,0 @@ |
|||||||
/*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.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Intel License Agreement
|
|
||||||
// For Open Source Computer Vision Library
|
|
||||||
//
|
|
||||||
// Copyright (C) 2000, Intel Corporation, 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 Intel Corporation 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_IMGCODECS_H |
|
||||||
#define OPENCV_IMGCODECS_H |
|
||||||
|
|
||||||
#include "opencv2/core/core_c.h" |
|
||||||
|
|
||||||
#ifdef __cplusplus |
|
||||||
extern "C" { |
|
||||||
#endif /* __cplusplus */ |
|
||||||
|
|
||||||
/** @addtogroup imgcodecs_c
|
|
||||||
@{ |
|
||||||
*/ |
|
||||||
|
|
||||||
enum |
|
||||||
{ |
|
||||||
/* 8bit, color or not */ |
|
||||||
CV_LOAD_IMAGE_UNCHANGED =-1, |
|
||||||
/* 8bit, gray */ |
|
||||||
CV_LOAD_IMAGE_GRAYSCALE =0, |
|
||||||
/* ?, color */ |
|
||||||
CV_LOAD_IMAGE_COLOR =1, |
|
||||||
/* any depth, ? */ |
|
||||||
CV_LOAD_IMAGE_ANYDEPTH =2, |
|
||||||
/* ?, any color */ |
|
||||||
CV_LOAD_IMAGE_ANYCOLOR =4, |
|
||||||
/* ?, no rotate */ |
|
||||||
CV_LOAD_IMAGE_IGNORE_ORIENTATION =128 |
|
||||||
}; |
|
||||||
|
|
||||||
/* load image from file
|
|
||||||
iscolor can be a combination of above flags where CV_LOAD_IMAGE_UNCHANGED |
|
||||||
overrides the other flags |
|
||||||
using CV_LOAD_IMAGE_ANYCOLOR alone is equivalent to CV_LOAD_IMAGE_UNCHANGED |
|
||||||
unless CV_LOAD_IMAGE_ANYDEPTH is specified images are converted to 8bit |
|
||||||
*/ |
|
||||||
CVAPI(IplImage*) cvLoadImage( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR)); |
|
||||||
CVAPI(CvMat*) cvLoadImageM( const char* filename, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR)); |
|
||||||
|
|
||||||
enum |
|
||||||
{ |
|
||||||
CV_IMWRITE_JPEG_QUALITY =1, |
|
||||||
CV_IMWRITE_JPEG_PROGRESSIVE =2, |
|
||||||
CV_IMWRITE_JPEG_OPTIMIZE =3, |
|
||||||
CV_IMWRITE_JPEG_RST_INTERVAL =4, |
|
||||||
CV_IMWRITE_JPEG_LUMA_QUALITY =5, |
|
||||||
CV_IMWRITE_JPEG_CHROMA_QUALITY =6, |
|
||||||
CV_IMWRITE_PNG_COMPRESSION =16, |
|
||||||
CV_IMWRITE_PNG_STRATEGY =17, |
|
||||||
CV_IMWRITE_PNG_BILEVEL =18, |
|
||||||
CV_IMWRITE_PNG_STRATEGY_DEFAULT =0, |
|
||||||
CV_IMWRITE_PNG_STRATEGY_FILTERED =1, |
|
||||||
CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY =2, |
|
||||||
CV_IMWRITE_PNG_STRATEGY_RLE =3, |
|
||||||
CV_IMWRITE_PNG_STRATEGY_FIXED =4, |
|
||||||
CV_IMWRITE_PXM_BINARY =32, |
|
||||||
CV_IMWRITE_EXR_TYPE = 48, |
|
||||||
CV_IMWRITE_WEBP_QUALITY =64, |
|
||||||
CV_IMWRITE_PAM_TUPLETYPE = 128, |
|
||||||
CV_IMWRITE_PAM_FORMAT_NULL = 0, |
|
||||||
CV_IMWRITE_PAM_FORMAT_BLACKANDWHITE = 1, |
|
||||||
CV_IMWRITE_PAM_FORMAT_GRAYSCALE = 2, |
|
||||||
CV_IMWRITE_PAM_FORMAT_GRAYSCALE_ALPHA = 3, |
|
||||||
CV_IMWRITE_PAM_FORMAT_RGB = 4, |
|
||||||
CV_IMWRITE_PAM_FORMAT_RGB_ALPHA = 5, |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* save image to file */ |
|
||||||
CVAPI(int) cvSaveImage( const char* filename, const CvArr* image, |
|
||||||
const int* params CV_DEFAULT(0) ); |
|
||||||
|
|
||||||
/* decode image stored in the buffer */ |
|
||||||
CVAPI(IplImage*) cvDecodeImage( const CvMat* buf, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR)); |
|
||||||
CVAPI(CvMat*) cvDecodeImageM( const CvMat* buf, int iscolor CV_DEFAULT(CV_LOAD_IMAGE_COLOR)); |
|
||||||
|
|
||||||
/* encode image and store the result as a byte vector (single-row 8uC1 matrix) */ |
|
||||||
CVAPI(CvMat*) cvEncodeImage( const char* ext, const CvArr* image, |
|
||||||
const int* params CV_DEFAULT(0) ); |
|
||||||
|
|
||||||
enum |
|
||||||
{ |
|
||||||
CV_CVTIMG_FLIP =1, |
|
||||||
CV_CVTIMG_SWAP_RB =2 |
|
||||||
}; |
|
||||||
|
|
||||||
/* utility function: convert one image to another with optional vertical flip */ |
|
||||||
CVAPI(void) cvConvertImage( const CvArr* src, CvArr* dst, int flags CV_DEFAULT(0)); |
|
||||||
|
|
||||||
CVAPI(int) cvHaveImageReader(const char* filename); |
|
||||||
CVAPI(int) cvHaveImageWriter(const char* filename); |
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************************\
|
|
||||||
* Obsolete functions/synonyms * |
|
||||||
\****************************************************************************************/ |
|
||||||
|
|
||||||
#define cvvLoadImage(name) cvLoadImage((name),1) |
|
||||||
#define cvvSaveImage cvSaveImage |
|
||||||
#define cvvConvertImage cvConvertImage |
|
||||||
|
|
||||||
/** @} imgcodecs_c */ |
|
||||||
|
|
||||||
#ifdef __cplusplus |
|
||||||
} |
|
||||||
#endif |
|
||||||
|
|
||||||
#endif // OPENCV_IMGCODECS_H
|
|
@ -1,74 +0,0 @@ |
|||||||
/*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) 2008-2012, Willow Garage Inc., 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_PHOTO_C_H |
|
||||||
#define OPENCV_PHOTO_C_H |
|
||||||
|
|
||||||
#include "opencv2/core/core_c.h" |
|
||||||
|
|
||||||
#ifdef __cplusplus |
|
||||||
extern "C" { |
|
||||||
#endif |
|
||||||
|
|
||||||
/** @addtogroup photo_c
|
|
||||||
@{ |
|
||||||
*/ |
|
||||||
|
|
||||||
/* Inpainting algorithms */ |
|
||||||
enum InpaintingModes |
|
||||||
{ |
|
||||||
CV_INPAINT_NS =0, |
|
||||||
CV_INPAINT_TELEA =1 |
|
||||||
}; |
|
||||||
|
|
||||||
|
|
||||||
/* Inpaints the selected region in the image */ |
|
||||||
CVAPI(void) cvInpaint( const CvArr* src, const CvArr* inpaint_mask, |
|
||||||
CvArr* dst, double inpaintRange, int flags ); |
|
||||||
|
|
||||||
/** @} */ |
|
||||||
|
|
||||||
#ifdef __cplusplus |
|
||||||
} //extern "C"
|
|
||||||
#endif |
|
||||||
|
|
||||||
#endif //OPENCV_PHOTO_C_H
|
|
@ -1,228 +0,0 @@ |
|||||||
/*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 |
|
||||||
|
|
||||||
/** @addtogroup video_c
|
|
||||||
@{ |
|
||||||
*/ |
|
||||||
|
|
||||||
/****************************************************************************************\
|
|
||||||
* 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 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 |
|
||||||
|
|
||||||
/** @} video_c */ |
|
||||||
|
|
||||||
#ifdef __cplusplus |
|
||||||
} // extern "C"
|
|
||||||
#endif |
|
||||||
|
|
||||||
|
|
||||||
#endif // OPENCV_TRACKING_C_H
|
|
@ -1,301 +0,0 @@ |
|||||||
/*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, Intel Corporation, 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*/
|
|
||||||
|
|
||||||
#include "precomp.hpp" |
|
||||||
#include "opencv2/video/tracking_c.h" |
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////// Meanshift & CAMShift ///////////////////////////
|
|
||||||
|
|
||||||
CV_IMPL int |
|
||||||
cvMeanShift( const void* imgProb, CvRect windowIn, |
|
||||||
CvTermCriteria criteria, CvConnectedComp* comp ) |
|
||||||
{ |
|
||||||
cv::Mat img = cv::cvarrToMat(imgProb); |
|
||||||
cv::Rect window = windowIn; |
|
||||||
int iters = cv::meanShift(img, window, criteria); |
|
||||||
|
|
||||||
if( comp ) |
|
||||||
{ |
|
||||||
comp->rect = cvRect(window); |
|
||||||
comp->area = cvRound(cv::sum(img(window))[0]); |
|
||||||
} |
|
||||||
|
|
||||||
return iters; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL int |
|
||||||
cvCamShift( const void* imgProb, CvRect windowIn, |
|
||||||
CvTermCriteria criteria, |
|
||||||
CvConnectedComp* comp, |
|
||||||
CvBox2D* box ) |
|
||||||
{ |
|
||||||
cv::Mat img = cv::cvarrToMat(imgProb); |
|
||||||
cv::Rect window = windowIn; |
|
||||||
cv::RotatedRect rr = cv::CamShift(img, window, criteria); |
|
||||||
|
|
||||||
if( comp ) |
|
||||||
{ |
|
||||||
comp->rect = cvRect(window); |
|
||||||
cv::Rect roi = rr.boundingRect() & cv::Rect(0, 0, img.cols, img.rows); |
|
||||||
comp->area = cvRound(cv::sum(img(roi))[0]); |
|
||||||
} |
|
||||||
|
|
||||||
if( box ) |
|
||||||
*box = cvBox2D(rr); |
|
||||||
|
|
||||||
return rr.size.width*rr.size.height > 0.f ? 1 : -1; |
|
||||||
} |
|
||||||
|
|
||||||
///////////////////////////////// Kalman ///////////////////////////////
|
|
||||||
|
|
||||||
CV_IMPL CvKalman* |
|
||||||
cvCreateKalman( int DP, int MP, int CP ) |
|
||||||
{ |
|
||||||
CvKalman *kalman = 0; |
|
||||||
|
|
||||||
if( DP <= 0 || MP <= 0 ) |
|
||||||
CV_Error( CV_StsOutOfRange, |
|
||||||
"state and measurement vectors must have positive number of dimensions" ); |
|
||||||
|
|
||||||
if( CP < 0 ) |
|
||||||
CP = DP; |
|
||||||
|
|
||||||
/* allocating memory for the structure */ |
|
||||||
kalman = (CvKalman *)cvAlloc( sizeof( CvKalman )); |
|
||||||
memset( kalman, 0, sizeof(*kalman)); |
|
||||||
|
|
||||||
kalman->DP = DP; |
|
||||||
kalman->MP = MP; |
|
||||||
kalman->CP = CP; |
|
||||||
|
|
||||||
kalman->state_pre = cvCreateMat( DP, 1, CV_32FC1 ); |
|
||||||
cvZero( kalman->state_pre ); |
|
||||||
|
|
||||||
kalman->state_post = cvCreateMat( DP, 1, CV_32FC1 ); |
|
||||||
cvZero( kalman->state_post ); |
|
||||||
|
|
||||||
kalman->transition_matrix = cvCreateMat( DP, DP, CV_32FC1 ); |
|
||||||
cvSetIdentity( kalman->transition_matrix ); |
|
||||||
|
|
||||||
kalman->process_noise_cov = cvCreateMat( DP, DP, CV_32FC1 ); |
|
||||||
cvSetIdentity( kalman->process_noise_cov ); |
|
||||||
|
|
||||||
kalman->measurement_matrix = cvCreateMat( MP, DP, CV_32FC1 ); |
|
||||||
cvZero( kalman->measurement_matrix ); |
|
||||||
|
|
||||||
kalman->measurement_noise_cov = cvCreateMat( MP, MP, CV_32FC1 ); |
|
||||||
cvSetIdentity( kalman->measurement_noise_cov ); |
|
||||||
|
|
||||||
kalman->error_cov_pre = cvCreateMat( DP, DP, CV_32FC1 ); |
|
||||||
|
|
||||||
kalman->error_cov_post = cvCreateMat( DP, DP, CV_32FC1 ); |
|
||||||
cvZero( kalman->error_cov_post ); |
|
||||||
|
|
||||||
kalman->gain = cvCreateMat( DP, MP, CV_32FC1 ); |
|
||||||
|
|
||||||
if( CP > 0 ) |
|
||||||
{ |
|
||||||
kalman->control_matrix = cvCreateMat( DP, CP, CV_32FC1 ); |
|
||||||
cvZero( kalman->control_matrix ); |
|
||||||
} |
|
||||||
|
|
||||||
kalman->temp1 = cvCreateMat( DP, DP, CV_32FC1 ); |
|
||||||
kalman->temp2 = cvCreateMat( MP, DP, CV_32FC1 ); |
|
||||||
kalman->temp3 = cvCreateMat( MP, MP, CV_32FC1 ); |
|
||||||
kalman->temp4 = cvCreateMat( MP, DP, CV_32FC1 ); |
|
||||||
kalman->temp5 = cvCreateMat( MP, 1, CV_32FC1 ); |
|
||||||
|
|
||||||
#if 1 |
|
||||||
kalman->PosterState = kalman->state_pre->data.fl; |
|
||||||
kalman->PriorState = kalman->state_post->data.fl; |
|
||||||
kalman->DynamMatr = kalman->transition_matrix->data.fl; |
|
||||||
kalman->MeasurementMatr = kalman->measurement_matrix->data.fl; |
|
||||||
kalman->MNCovariance = kalman->measurement_noise_cov->data.fl; |
|
||||||
kalman->PNCovariance = kalman->process_noise_cov->data.fl; |
|
||||||
kalman->KalmGainMatr = kalman->gain->data.fl; |
|
||||||
kalman->PriorErrorCovariance = kalman->error_cov_pre->data.fl; |
|
||||||
kalman->PosterErrorCovariance = kalman->error_cov_post->data.fl; |
|
||||||
#endif |
|
||||||
|
|
||||||
return kalman; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL void |
|
||||||
cvReleaseKalman( CvKalman** _kalman ) |
|
||||||
{ |
|
||||||
CvKalman *kalman; |
|
||||||
|
|
||||||
if( !_kalman ) |
|
||||||
CV_Error( CV_StsNullPtr, "" ); |
|
||||||
|
|
||||||
kalman = *_kalman; |
|
||||||
if( !kalman ) |
|
||||||
return; |
|
||||||
|
|
||||||
/* freeing the memory */ |
|
||||||
cvReleaseMat( &kalman->state_pre ); |
|
||||||
cvReleaseMat( &kalman->state_post ); |
|
||||||
cvReleaseMat( &kalman->transition_matrix ); |
|
||||||
cvReleaseMat( &kalman->control_matrix ); |
|
||||||
cvReleaseMat( &kalman->measurement_matrix ); |
|
||||||
cvReleaseMat( &kalman->process_noise_cov ); |
|
||||||
cvReleaseMat( &kalman->measurement_noise_cov ); |
|
||||||
cvReleaseMat( &kalman->error_cov_pre ); |
|
||||||
cvReleaseMat( &kalman->gain ); |
|
||||||
cvReleaseMat( &kalman->error_cov_post ); |
|
||||||
cvReleaseMat( &kalman->temp1 ); |
|
||||||
cvReleaseMat( &kalman->temp2 ); |
|
||||||
cvReleaseMat( &kalman->temp3 ); |
|
||||||
cvReleaseMat( &kalman->temp4 ); |
|
||||||
cvReleaseMat( &kalman->temp5 ); |
|
||||||
|
|
||||||
memset( kalman, 0, sizeof(*kalman)); |
|
||||||
|
|
||||||
/* deallocating the structure */ |
|
||||||
cvFree( _kalman ); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL const CvMat* |
|
||||||
cvKalmanPredict( CvKalman* kalman, const CvMat* control ) |
|
||||||
{ |
|
||||||
if( !kalman ) |
|
||||||
CV_Error( CV_StsNullPtr, "" ); |
|
||||||
|
|
||||||
/* update the state */ |
|
||||||
/* x'(k) = A*x(k) */ |
|
||||||
cvMatMulAdd( kalman->transition_matrix, kalman->state_post, 0, kalman->state_pre ); |
|
||||||
|
|
||||||
if( control && kalman->CP > 0 ) |
|
||||||
/* x'(k) = x'(k) + B*u(k) */ |
|
||||||
cvMatMulAdd( kalman->control_matrix, control, kalman->state_pre, kalman->state_pre ); |
|
||||||
|
|
||||||
/* update error covariance matrices */ |
|
||||||
/* temp1 = A*P(k) */ |
|
||||||
cvMatMulAdd( kalman->transition_matrix, kalman->error_cov_post, 0, kalman->temp1 ); |
|
||||||
|
|
||||||
/* P'(k) = temp1*At + Q */ |
|
||||||
cvGEMM( kalman->temp1, kalman->transition_matrix, 1, kalman->process_noise_cov, 1, |
|
||||||
kalman->error_cov_pre, CV_GEMM_B_T ); |
|
||||||
|
|
||||||
/* handle the case when there will be measurement before the next predict */ |
|
||||||
cvCopy(kalman->state_pre, kalman->state_post); |
|
||||||
|
|
||||||
return kalman->state_pre; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL const CvMat* |
|
||||||
cvKalmanCorrect( CvKalman* kalman, const CvMat* measurement ) |
|
||||||
{ |
|
||||||
if( !kalman || !measurement ) |
|
||||||
CV_Error( CV_StsNullPtr, "" ); |
|
||||||
|
|
||||||
/* temp2 = H*P'(k) */ |
|
||||||
cvMatMulAdd( kalman->measurement_matrix, kalman->error_cov_pre, 0, kalman->temp2 ); |
|
||||||
/* temp3 = temp2*Ht + R */ |
|
||||||
cvGEMM( kalman->temp2, kalman->measurement_matrix, 1, |
|
||||||
kalman->measurement_noise_cov, 1, kalman->temp3, CV_GEMM_B_T ); |
|
||||||
|
|
||||||
/* temp4 = inv(temp3)*temp2 = Kt(k) */ |
|
||||||
cvSolve( kalman->temp3, kalman->temp2, kalman->temp4, CV_SVD ); |
|
||||||
|
|
||||||
/* K(k) */ |
|
||||||
cvTranspose( kalman->temp4, kalman->gain ); |
|
||||||
|
|
||||||
/* temp5 = z(k) - H*x'(k) */ |
|
||||||
cvGEMM( kalman->measurement_matrix, kalman->state_pre, -1, measurement, 1, kalman->temp5 ); |
|
||||||
|
|
||||||
/* x(k) = x'(k) + K(k)*temp5 */ |
|
||||||
cvMatMulAdd( kalman->gain, kalman->temp5, kalman->state_pre, kalman->state_post ); |
|
||||||
|
|
||||||
/* P(k) = P'(k) - K(k)*temp2 */ |
|
||||||
cvGEMM( kalman->gain, kalman->temp2, -1, kalman->error_cov_pre, 1, |
|
||||||
kalman->error_cov_post, 0 ); |
|
||||||
|
|
||||||
return kalman->state_post; |
|
||||||
} |
|
||||||
|
|
||||||
///////////////////////////////////// Optical Flow ////////////////////////////////
|
|
||||||
|
|
||||||
CV_IMPL void |
|
||||||
cvCalcOpticalFlowPyrLK( const void* arrA, const void* arrB, |
|
||||||
void* /*pyrarrA*/, void* /*pyrarrB*/, |
|
||||||
const CvPoint2D32f * featuresA, |
|
||||||
CvPoint2D32f * featuresB, |
|
||||||
int count, CvSize winSize, int level, |
|
||||||
char *status, float *error, |
|
||||||
CvTermCriteria criteria, int flags ) |
|
||||||
{ |
|
||||||
if( count <= 0 ) |
|
||||||
return; |
|
||||||
CV_Assert( featuresA && featuresB ); |
|
||||||
cv::Mat A = cv::cvarrToMat(arrA), B = cv::cvarrToMat(arrB); |
|
||||||
cv::Mat ptA(count, 1, CV_32FC2, (void*)featuresA); |
|
||||||
cv::Mat ptB(count, 1, CV_32FC2, (void*)featuresB); |
|
||||||
cv::Mat st, err; |
|
||||||
|
|
||||||
if( status ) |
|
||||||
st = cv::Mat(count, 1, CV_8U, (void*)status); |
|
||||||
if( error ) |
|
||||||
err = cv::Mat(count, 1, CV_32F, (void*)error); |
|
||||||
cv::calcOpticalFlowPyrLK( A, B, ptA, ptB, st, |
|
||||||
error ? cv::_OutputArray(err) : (cv::_OutputArray)cv::noArray(), |
|
||||||
winSize, level, criteria, flags); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
CV_IMPL 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 ) |
|
||||||
{ |
|
||||||
cv::Mat prev = cv::cvarrToMat(_prev), next = cv::cvarrToMat(_next); |
|
||||||
cv::Mat flow = cv::cvarrToMat(_flow); |
|
||||||
CV_Assert( flow.size() == prev.size() && flow.type() == CV_32FC2 ); |
|
||||||
cv::calcOpticalFlowFarneback( prev, next, flow, pyr_scale, levels, |
|
||||||
winsize, iterations, poly_n, poly_sigma, flags ); |
|
||||||
} |
|
Loading…
Reference in new issue