点阵完成,加入opencv
This commit is contained in:
344
3rdpart/OpenCV/include/opencv2/video/background_segm.hpp
Normal file
344
3rdpart/OpenCV/include/opencv2/video/background_segm.hpp
Normal file
@@ -0,0 +1,344 @@
|
||||
/*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_BACKGROUND_SEGM_HPP
|
||||
#define OPENCV_BACKGROUND_SEGM_HPP
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @addtogroup video_motion
|
||||
//! @{
|
||||
|
||||
/** @brief Base class for background/foreground segmentation. :
|
||||
|
||||
The class is only used to define the common interface for the whole family of background/foreground
|
||||
segmentation algorithms.
|
||||
*/
|
||||
class CV_EXPORTS_W BackgroundSubtractor : public Algorithm
|
||||
{
|
||||
public:
|
||||
/** @brief Computes a foreground mask.
|
||||
|
||||
@param image Next video frame.
|
||||
@param fgmask The output foreground mask as an 8-bit binary image.
|
||||
@param learningRate The value between 0 and 1 that indicates how fast the background model is
|
||||
learnt. Negative parameter value makes the algorithm to use some automatically chosen learning
|
||||
rate. 0 means that the background model is not updated at all, 1 means that the background model
|
||||
is completely reinitialized from the last frame.
|
||||
*/
|
||||
CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) = 0;
|
||||
|
||||
/** @brief Computes a foreground mask with known foreground mask input.
|
||||
|
||||
@param image Next video frame. Floating point frame will be used without scaling and should be in range \f$[0,255]\f$.
|
||||
@param fgmask The output foreground mask as an 8-bit binary image.
|
||||
@param knownForegroundMask The mask for inputting already known foreground, allows model to ignore pixels.
|
||||
@param learningRate The value between 0 and 1 that indicates how fast the background model is
|
||||
learnt. Negative parameter value makes the algorithm to use some automatically chosen learning
|
||||
rate. 0 means that the background model is not updated at all, 1 means that the background model
|
||||
is completely reinitialized from the last frame.
|
||||
|
||||
@note This method has a default virtual implementation that throws a "not impemented" error.
|
||||
Foreground masking may not be supported by all background subtractors.
|
||||
*/
|
||||
CV_WRAP virtual void apply(InputArray image, InputArray knownForegroundMask, OutputArray fgmask, double learningRate=-1) = 0;
|
||||
|
||||
/** @brief Computes a background image.
|
||||
|
||||
@param backgroundImage The output background image.
|
||||
|
||||
@note Sometimes the background image can be very blurry, as it contain the average background
|
||||
statistics.
|
||||
*/
|
||||
CV_WRAP virtual void getBackgroundImage(OutputArray backgroundImage) const = 0;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
|
||||
|
||||
The class implements the Gaussian mixture model background subtraction described in @cite Zivkovic2004
|
||||
and @cite Zivkovic2006 .
|
||||
*/
|
||||
class CV_EXPORTS_W BackgroundSubtractorMOG2 : public BackgroundSubtractor
|
||||
{
|
||||
public:
|
||||
/** @brief Returns the number of last frames that affect the background model
|
||||
*/
|
||||
CV_WRAP virtual int getHistory() const = 0;
|
||||
/** @brief Sets the number of last frames that affect the background model
|
||||
*/
|
||||
CV_WRAP virtual void setHistory(int history) = 0;
|
||||
|
||||
/** @brief Returns the number of gaussian components in the background model
|
||||
*/
|
||||
CV_WRAP virtual int getNMixtures() const = 0;
|
||||
/** @brief Sets the number of gaussian components in the background model.
|
||||
|
||||
The model needs to be reinitialized to reserve memory.
|
||||
*/
|
||||
CV_WRAP virtual void setNMixtures(int nmixtures) = 0;//needs reinitialization!
|
||||
|
||||
/** @brief Returns the "background ratio" parameter of the algorithm
|
||||
|
||||
If a foreground pixel keeps semi-constant value for about backgroundRatio\*history frames, it's
|
||||
considered background and added to the model as a center of a new component. It corresponds to TB
|
||||
parameter in the paper.
|
||||
*/
|
||||
CV_WRAP virtual double getBackgroundRatio() const = 0;
|
||||
/** @brief Sets the "background ratio" parameter of the algorithm
|
||||
*/
|
||||
CV_WRAP virtual void setBackgroundRatio(double ratio) = 0;
|
||||
|
||||
/** @brief Returns the variance threshold for the pixel-model match
|
||||
|
||||
The main threshold on the squared Mahalanobis distance to decide if the sample is well described by
|
||||
the background model or not. Related to Cthr from the paper.
|
||||
*/
|
||||
CV_WRAP virtual double getVarThreshold() const = 0;
|
||||
/** @brief Sets the variance threshold for the pixel-model match
|
||||
*/
|
||||
CV_WRAP virtual void setVarThreshold(double varThreshold) = 0;
|
||||
|
||||
/** @brief Returns the variance threshold for the pixel-model match used for new mixture component generation
|
||||
|
||||
Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the
|
||||
existing components (corresponds to Tg in the paper). If a pixel is not close to any component, it
|
||||
is considered foreground or added as a new component. 3 sigma =\> Tg=3\*3=9 is default. A smaller Tg
|
||||
value generates more components. A higher Tg value may result in a small number of components but
|
||||
they can grow too large.
|
||||
*/
|
||||
CV_WRAP virtual double getVarThresholdGen() const = 0;
|
||||
/** @brief Sets the variance threshold for the pixel-model match used for new mixture component generation
|
||||
*/
|
||||
CV_WRAP virtual void setVarThresholdGen(double varThresholdGen) = 0;
|
||||
|
||||
/** @brief Returns the initial variance of each gaussian component
|
||||
*/
|
||||
CV_WRAP virtual double getVarInit() const = 0;
|
||||
/** @brief Sets the initial variance of each gaussian component
|
||||
*/
|
||||
CV_WRAP virtual void setVarInit(double varInit) = 0;
|
||||
|
||||
CV_WRAP virtual double getVarMin() const = 0;
|
||||
CV_WRAP virtual void setVarMin(double varMin) = 0;
|
||||
|
||||
CV_WRAP virtual double getVarMax() const = 0;
|
||||
CV_WRAP virtual void setVarMax(double varMax) = 0;
|
||||
|
||||
/** @brief Returns the complexity reduction threshold
|
||||
|
||||
This parameter defines the number of samples needed to accept to prove the component exists. CT=0.05
|
||||
is a default value for all the samples. By setting CT=0 you get an algorithm very similar to the
|
||||
standard Stauffer&Grimson algorithm.
|
||||
*/
|
||||
CV_WRAP virtual double getComplexityReductionThreshold() const = 0;
|
||||
/** @brief Sets the complexity reduction threshold
|
||||
*/
|
||||
CV_WRAP virtual void setComplexityReductionThreshold(double ct) = 0;
|
||||
|
||||
/** @brief Returns the shadow detection flag
|
||||
|
||||
If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorMOG2 for
|
||||
details.
|
||||
*/
|
||||
CV_WRAP virtual bool getDetectShadows() const = 0;
|
||||
/** @brief Enables or disables shadow detection
|
||||
*/
|
||||
CV_WRAP virtual void setDetectShadows(bool detectShadows) = 0;
|
||||
|
||||
/** @brief Returns the shadow value
|
||||
|
||||
Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0
|
||||
in the mask always means background, 255 means foreground.
|
||||
*/
|
||||
CV_WRAP virtual int getShadowValue() const = 0;
|
||||
/** @brief Sets the shadow value
|
||||
*/
|
||||
CV_WRAP virtual void setShadowValue(int value) = 0;
|
||||
|
||||
/** @brief Returns the shadow threshold
|
||||
|
||||
A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in
|
||||
the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel
|
||||
is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara,
|
||||
*Detecting Moving Shadows...*, IEEE PAMI,2003.
|
||||
*/
|
||||
CV_WRAP virtual double getShadowThreshold() const = 0;
|
||||
/** @brief Sets the shadow threshold
|
||||
*/
|
||||
CV_WRAP virtual void setShadowThreshold(double threshold) = 0;
|
||||
|
||||
/** @brief Computes a foreground mask.
|
||||
|
||||
@param image Next video frame. Floating point frame will be used without scaling and should be in range \f$[0,255]\f$.
|
||||
@param fgmask The output foreground mask as an 8-bit binary image.
|
||||
@param learningRate The value between 0 and 1 that indicates how fast the background model is
|
||||
learnt. Negative parameter value makes the algorithm to use some automatically chosen learning
|
||||
rate. 0 means that the background model is not updated at all, 1 means that the background model
|
||||
is completely reinitialized from the last frame.
|
||||
*/
|
||||
CV_WRAP virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1) CV_OVERRIDE = 0;
|
||||
|
||||
/** @brief Computes a foreground mask and skips known foreground in evaluation.
|
||||
|
||||
@param image Next video frame. Floating point frame will be used without scaling and should be in range \f$[0,255]\f$.
|
||||
@param fgmask The output foreground mask as an 8-bit binary image.
|
||||
@param knownForegroundMask The mask for inputting already known foreground, allows model to ignore pixels.
|
||||
@param learningRate The value between 0 and 1 that indicates how fast the background model is
|
||||
learnt. Negative parameter value makes the algorithm to use some automatically chosen learning
|
||||
rate. 0 means that the background model is not updated at all, 1 means that the background model
|
||||
is completely reinitialized from the last frame.
|
||||
*/
|
||||
CV_WRAP virtual void apply(InputArray image, InputArray knownForegroundMask, OutputArray fgmask, double learningRate=-1) CV_OVERRIDE = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates MOG2 Background Subtractor
|
||||
|
||||
@param history Length of the history.
|
||||
@param varThreshold Threshold on the squared Mahalanobis distance between the pixel and the model
|
||||
to decide whether a pixel is well described by the background model. This parameter does not
|
||||
affect the background update.
|
||||
@param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the
|
||||
speed a bit, so if you do not need this feature, set the parameter to false.
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<BackgroundSubtractorMOG2>
|
||||
createBackgroundSubtractorMOG2(int history=500, double varThreshold=16,
|
||||
bool detectShadows=true);
|
||||
|
||||
/** @brief K-nearest neighbours - based Background/Foreground Segmentation Algorithm.
|
||||
|
||||
The class implements the K-nearest neighbours background subtraction described in @cite Zivkovic2006 .
|
||||
Very efficient if number of foreground pixels is low.
|
||||
*/
|
||||
class CV_EXPORTS_W BackgroundSubtractorKNN : public BackgroundSubtractor
|
||||
{
|
||||
public:
|
||||
/** @brief Returns the number of last frames that affect the background model
|
||||
*/
|
||||
CV_WRAP virtual int getHistory() const = 0;
|
||||
/** @brief Sets the number of last frames that affect the background model
|
||||
*/
|
||||
CV_WRAP virtual void setHistory(int history) = 0;
|
||||
|
||||
/** @brief Returns the number of data samples in the background model
|
||||
*/
|
||||
CV_WRAP virtual int getNSamples() const = 0;
|
||||
/** @brief Sets the number of data samples in the background model.
|
||||
|
||||
The model needs to be reinitialized to reserve memory.
|
||||
*/
|
||||
CV_WRAP virtual void setNSamples(int _nN) = 0;//needs reinitialization!
|
||||
|
||||
/** @brief Returns the threshold on the squared distance between the pixel and the sample
|
||||
|
||||
The threshold on the squared distance between the pixel and the sample to decide whether a pixel is
|
||||
close to a data sample.
|
||||
*/
|
||||
CV_WRAP virtual double getDist2Threshold() const = 0;
|
||||
/** @brief Sets the threshold on the squared distance
|
||||
*/
|
||||
CV_WRAP virtual void setDist2Threshold(double _dist2Threshold) = 0;
|
||||
|
||||
/** @brief Returns the number of neighbours, the k in the kNN.
|
||||
|
||||
K is the number of samples that need to be within dist2Threshold in order to decide that that
|
||||
pixel is matching the kNN background model.
|
||||
*/
|
||||
CV_WRAP virtual int getkNNSamples() const = 0;
|
||||
/** @brief Sets the k in the kNN. How many nearest neighbours need to match.
|
||||
*/
|
||||
CV_WRAP virtual void setkNNSamples(int _nkNN) = 0;
|
||||
|
||||
/** @brief Returns the shadow detection flag
|
||||
|
||||
If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for
|
||||
details.
|
||||
*/
|
||||
CV_WRAP virtual bool getDetectShadows() const = 0;
|
||||
/** @brief Enables or disables shadow detection
|
||||
*/
|
||||
CV_WRAP virtual void setDetectShadows(bool detectShadows) = 0;
|
||||
|
||||
/** @brief Returns the shadow value
|
||||
|
||||
Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0
|
||||
in the mask always means background, 255 means foreground.
|
||||
*/
|
||||
CV_WRAP virtual int getShadowValue() const = 0;
|
||||
/** @brief Sets the shadow value
|
||||
*/
|
||||
CV_WRAP virtual void setShadowValue(int value) = 0;
|
||||
|
||||
/** @brief Returns the shadow threshold
|
||||
|
||||
A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in
|
||||
the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel
|
||||
is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiara,
|
||||
*Detecting Moving Shadows...*, IEEE PAMI,2003.
|
||||
*/
|
||||
CV_WRAP virtual double getShadowThreshold() const = 0;
|
||||
/** @brief Sets the shadow threshold
|
||||
*/
|
||||
CV_WRAP virtual void setShadowThreshold(double threshold) = 0;
|
||||
};
|
||||
|
||||
/** @brief Creates KNN Background Subtractor
|
||||
|
||||
@param history Length of the history.
|
||||
@param dist2Threshold Threshold on the squared distance between the pixel and the sample to decide
|
||||
whether a pixel is close to that sample. This parameter does not affect the background update.
|
||||
@param detectShadows If true, the algorithm will detect shadows and mark them. It decreases the
|
||||
speed a bit, so if you do not need this feature, set the parameter to false.
|
||||
*/
|
||||
CV_EXPORTS_W Ptr<BackgroundSubtractorKNN>
|
||||
createBackgroundSubtractorKNN(int history=500, double dist2Threshold=400.0,
|
||||
bool detectShadows=true);
|
||||
|
||||
//! @} video_motion
|
||||
|
||||
} // cv
|
||||
|
||||
#endif
|
||||
406
3rdpart/OpenCV/include/opencv2/video/detail/tracking.detail.hpp
Normal file
406
3rdpart/OpenCV/include/opencv2/video/detail/tracking.detail.hpp
Normal file
@@ -0,0 +1,406 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#ifndef OPENCV_VIDEO_DETAIL_TRACKING_HPP
|
||||
#define OPENCV_VIDEO_DETAIL_TRACKING_HPP
|
||||
|
||||
/*
|
||||
* Partially based on:
|
||||
* ====================================================================================================================
|
||||
* - [AAM] S. Salti, A. Cavallaro, L. Di Stefano, Adaptive Appearance Modeling for Video Tracking: Survey and Evaluation
|
||||
* - [AMVOT] X. Li, W. Hu, C. Shen, Z. Zhang, A. Dick, A. van den Hengel, A Survey of Appearance Models in Visual Object Tracking
|
||||
*
|
||||
* This Tracking API has been designed with PlantUML. If you modify this API please change UML files under modules/tracking/doc/uml
|
||||
*
|
||||
*/
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
inline namespace tracking {
|
||||
|
||||
/** @addtogroup tracking_detail
|
||||
@{
|
||||
*/
|
||||
|
||||
/************************************ TrackerFeature Base Classes ************************************/
|
||||
|
||||
/** @brief Abstract base class for TrackerFeature that represents the feature.
|
||||
*/
|
||||
class CV_EXPORTS TrackerFeature
|
||||
{
|
||||
public:
|
||||
virtual ~TrackerFeature();
|
||||
|
||||
/** @brief Compute the features in the images collection
|
||||
@param images The images
|
||||
@param response The output response
|
||||
*/
|
||||
void compute(const std::vector<Mat>& images, Mat& response);
|
||||
|
||||
protected:
|
||||
virtual bool computeImpl(const std::vector<Mat>& images, Mat& response) = 0;
|
||||
};
|
||||
|
||||
/** @brief Class that manages the extraction and selection of features
|
||||
|
||||
@cite AAM Feature Extraction and Feature Set Refinement (Feature Processing and Feature Selection).
|
||||
See table I and section III C @cite AMVOT Appearance modelling -\> Visual representation (Table II,
|
||||
section 3.1 - 3.2)
|
||||
|
||||
TrackerFeatureSet is an aggregation of TrackerFeature
|
||||
|
||||
@sa
|
||||
TrackerFeature
|
||||
|
||||
*/
|
||||
class CV_EXPORTS TrackerFeatureSet
|
||||
{
|
||||
public:
|
||||
TrackerFeatureSet();
|
||||
|
||||
~TrackerFeatureSet();
|
||||
|
||||
/** @brief Extract features from the images collection
|
||||
@param images The input images
|
||||
*/
|
||||
void extraction(const std::vector<Mat>& images);
|
||||
|
||||
/** @brief Add TrackerFeature in the collection. Return true if TrackerFeature is added, false otherwise
|
||||
@param feature The TrackerFeature class
|
||||
*/
|
||||
bool addTrackerFeature(const Ptr<TrackerFeature>& feature);
|
||||
|
||||
/** @brief Get the TrackerFeature collection (TrackerFeature name, TrackerFeature pointer)
|
||||
*/
|
||||
const std::vector<Ptr<TrackerFeature>>& getTrackerFeatures() const;
|
||||
|
||||
/** @brief Get the responses
|
||||
@note Be sure to call extraction before getResponses Example TrackerFeatureSet::getResponses
|
||||
*/
|
||||
const std::vector<Mat>& getResponses() const;
|
||||
|
||||
private:
|
||||
void clearResponses();
|
||||
bool blockAddTrackerFeature;
|
||||
|
||||
std::vector<Ptr<TrackerFeature>> features; // list of features
|
||||
std::vector<Mat> responses; // list of response after compute
|
||||
};
|
||||
|
||||
/************************************ TrackerSampler Base Classes ************************************/
|
||||
|
||||
/** @brief Abstract base class for TrackerSamplerAlgorithm that represents the algorithm for the specific
|
||||
sampler.
|
||||
*/
|
||||
class CV_EXPORTS TrackerSamplerAlgorithm
|
||||
{
|
||||
public:
|
||||
virtual ~TrackerSamplerAlgorithm();
|
||||
|
||||
/** @brief Computes the regions starting from a position in an image.
|
||||
|
||||
Return true if samples are computed, false otherwise
|
||||
|
||||
@param image The current frame
|
||||
@param boundingBox The bounding box from which regions can be calculated
|
||||
|
||||
@param sample The computed samples @cite AAM Fig. 1 variable Sk
|
||||
*/
|
||||
virtual bool sampling(const Mat& image, const Rect& boundingBox, std::vector<Mat>& sample) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Class that manages the sampler in order to select regions for the update the model of the tracker
|
||||
* [AAM] Sampling e Labeling. See table I and section III B
|
||||
*/
|
||||
|
||||
/** @brief Class that manages the sampler in order to select regions for the update the model of the tracker
|
||||
|
||||
@cite AAM Sampling e Labeling. See table I and section III B
|
||||
|
||||
TrackerSampler is an aggregation of TrackerSamplerAlgorithm
|
||||
@sa
|
||||
TrackerSamplerAlgorithm
|
||||
*/
|
||||
class CV_EXPORTS TrackerSampler
|
||||
{
|
||||
public:
|
||||
TrackerSampler();
|
||||
|
||||
~TrackerSampler();
|
||||
|
||||
/** @brief Computes the regions starting from a position in an image
|
||||
@param image The current frame
|
||||
@param boundingBox The bounding box from which regions can be calculated
|
||||
*/
|
||||
void sampling(const Mat& image, Rect boundingBox);
|
||||
|
||||
/** @brief Return the collection of the TrackerSamplerAlgorithm
|
||||
*/
|
||||
const std::vector<Ptr<TrackerSamplerAlgorithm>>& getSamplers() const;
|
||||
|
||||
/** @brief Return the samples from all TrackerSamplerAlgorithm, @cite AAM Fig. 1 variable Sk
|
||||
*/
|
||||
const std::vector<Mat>& getSamples() const;
|
||||
|
||||
/** @brief Add TrackerSamplerAlgorithm in the collection. Return true if sampler is added, false otherwise
|
||||
@param sampler The TrackerSamplerAlgorithm
|
||||
*/
|
||||
bool addTrackerSamplerAlgorithm(const Ptr<TrackerSamplerAlgorithm>& sampler);
|
||||
|
||||
private:
|
||||
std::vector<Ptr<TrackerSamplerAlgorithm>> samplers;
|
||||
std::vector<Mat> samples;
|
||||
bool blockAddTrackerSampler;
|
||||
|
||||
void clearSamples();
|
||||
};
|
||||
|
||||
/************************************ TrackerModel Base Classes ************************************/
|
||||
|
||||
/** @brief Abstract base class for TrackerTargetState that represents a possible state of the target.
|
||||
|
||||
See @cite AAM \f$\hat{x}^{i}_{k}\f$ all the states candidates.
|
||||
|
||||
Inherits this class with your Target state, In own implementation you can add scale variation,
|
||||
width, height, orientation, etc.
|
||||
*/
|
||||
class CV_EXPORTS TrackerTargetState
|
||||
{
|
||||
public:
|
||||
virtual ~TrackerTargetState() {}
|
||||
/** @brief Get the position
|
||||
* @return The position
|
||||
*/
|
||||
Point2f getTargetPosition() const;
|
||||
|
||||
/** @brief Set the position
|
||||
* @param position The position
|
||||
*/
|
||||
void setTargetPosition(const Point2f& position);
|
||||
/** @brief Get the width of the target
|
||||
* @return The width of the target
|
||||
*/
|
||||
int getTargetWidth() const;
|
||||
|
||||
/** @brief Set the width of the target
|
||||
* @param width The width of the target
|
||||
*/
|
||||
void setTargetWidth(int width);
|
||||
/** @brief Get the height of the target
|
||||
* @return The height of the target
|
||||
*/
|
||||
int getTargetHeight() const;
|
||||
|
||||
/** @brief Set the height of the target
|
||||
* @param height The height of the target
|
||||
*/
|
||||
void setTargetHeight(int height);
|
||||
|
||||
protected:
|
||||
Point2f targetPosition;
|
||||
int targetWidth;
|
||||
int targetHeight;
|
||||
};
|
||||
|
||||
/** @brief Represents the model of the target at frame \f$k\f$ (all states and scores)
|
||||
|
||||
See @cite AAM The set of the pair \f$\langle \hat{x}^{i}_{k}, C^{i}_{k} \rangle\f$
|
||||
@sa TrackerTargetState
|
||||
*/
|
||||
typedef std::vector<std::pair<Ptr<TrackerTargetState>, float>> ConfidenceMap;
|
||||
|
||||
/** @brief Represents the estimate states for all frames
|
||||
|
||||
@cite AAM \f$x_{k}\f$ is the trajectory of the target up to time \f$k\f$
|
||||
|
||||
@sa TrackerTargetState
|
||||
*/
|
||||
typedef std::vector<Ptr<TrackerTargetState>> Trajectory;
|
||||
|
||||
/** @brief Abstract base class for TrackerStateEstimator that estimates the most likely target state.
|
||||
|
||||
See @cite AAM State estimator
|
||||
|
||||
See @cite AMVOT Statistical modeling (Fig. 3), Table III (generative) - IV (discriminative) - V (hybrid)
|
||||
*/
|
||||
class CV_EXPORTS TrackerStateEstimator
|
||||
{
|
||||
public:
|
||||
virtual ~TrackerStateEstimator();
|
||||
|
||||
/** @brief Estimate the most likely target state, return the estimated state
|
||||
@param confidenceMaps The overall appearance model as a list of :cConfidenceMap
|
||||
*/
|
||||
Ptr<TrackerTargetState> estimate(const std::vector<ConfidenceMap>& confidenceMaps);
|
||||
|
||||
/** @brief Update the ConfidenceMap with the scores
|
||||
@param confidenceMaps The overall appearance model as a list of :cConfidenceMap
|
||||
*/
|
||||
void update(std::vector<ConfidenceMap>& confidenceMaps);
|
||||
|
||||
/** @brief Create TrackerStateEstimator by tracker state estimator type
|
||||
@param trackeStateEstimatorType The TrackerStateEstimator name
|
||||
|
||||
The modes available now:
|
||||
|
||||
- "BOOSTING" -- Boosting-based discriminative appearance models. See @cite AMVOT section 4.4
|
||||
|
||||
The modes available soon:
|
||||
|
||||
- "SVM" -- SVM-based discriminative appearance models. See @cite AMVOT section 4.5
|
||||
*/
|
||||
static Ptr<TrackerStateEstimator> create(const String& trackeStateEstimatorType);
|
||||
|
||||
/** @brief Get the name of the specific TrackerStateEstimator
|
||||
*/
|
||||
String getClassName() const;
|
||||
|
||||
protected:
|
||||
virtual Ptr<TrackerTargetState> estimateImpl(const std::vector<ConfidenceMap>& confidenceMaps) = 0;
|
||||
virtual void updateImpl(std::vector<ConfidenceMap>& confidenceMaps) = 0;
|
||||
String className;
|
||||
};
|
||||
|
||||
/** @brief Abstract class that represents the model of the target.
|
||||
|
||||
It must be instantiated by specialized tracker
|
||||
|
||||
See @cite AAM Ak
|
||||
|
||||
Inherits this with your TrackerModel
|
||||
*/
|
||||
class CV_EXPORTS TrackerModel
|
||||
{
|
||||
public:
|
||||
TrackerModel();
|
||||
|
||||
virtual ~TrackerModel();
|
||||
|
||||
/** @brief Set TrackerEstimator, return true if the tracker state estimator is added, false otherwise
|
||||
@param trackerStateEstimator The TrackerStateEstimator
|
||||
@note You can add only one TrackerStateEstimator
|
||||
*/
|
||||
bool setTrackerStateEstimator(Ptr<TrackerStateEstimator> trackerStateEstimator);
|
||||
|
||||
/** @brief Estimate the most likely target location
|
||||
|
||||
@cite AAM ME, Model Estimation table I
|
||||
@param responses Features extracted from TrackerFeatureSet
|
||||
*/
|
||||
void modelEstimation(const std::vector<Mat>& responses);
|
||||
|
||||
/** @brief Update the model
|
||||
|
||||
@cite AAM MU, Model Update table I
|
||||
*/
|
||||
void modelUpdate();
|
||||
|
||||
/** @brief Run the TrackerStateEstimator, return true if is possible to estimate a new state, false otherwise
|
||||
*/
|
||||
bool runStateEstimator();
|
||||
|
||||
/** @brief Set the current TrackerTargetState in the Trajectory
|
||||
@param lastTargetState The current TrackerTargetState
|
||||
*/
|
||||
void setLastTargetState(const Ptr<TrackerTargetState>& lastTargetState);
|
||||
|
||||
/** @brief Get the last TrackerTargetState from Trajectory
|
||||
*/
|
||||
Ptr<TrackerTargetState> getLastTargetState() const;
|
||||
|
||||
/** @brief Get the list of the ConfidenceMap
|
||||
*/
|
||||
const std::vector<ConfidenceMap>& getConfidenceMaps() const;
|
||||
|
||||
/** @brief Get the last ConfidenceMap for the current frame
|
||||
*/
|
||||
const ConfidenceMap& getLastConfidenceMap() const;
|
||||
|
||||
/** @brief Get the TrackerStateEstimator
|
||||
*/
|
||||
Ptr<TrackerStateEstimator> getTrackerStateEstimator() const;
|
||||
|
||||
private:
|
||||
void clearCurrentConfidenceMap();
|
||||
|
||||
protected:
|
||||
std::vector<ConfidenceMap> confidenceMaps;
|
||||
Ptr<TrackerStateEstimator> stateEstimator;
|
||||
ConfidenceMap currentConfidenceMap;
|
||||
Trajectory trajectory;
|
||||
int maxCMLength;
|
||||
|
||||
virtual void modelEstimationImpl(const std::vector<Mat>& responses) = 0;
|
||||
virtual void modelUpdateImpl() = 0;
|
||||
};
|
||||
|
||||
/************************************ Specific TrackerStateEstimator Classes ************************************/
|
||||
|
||||
// None
|
||||
|
||||
/************************************ Specific TrackerSamplerAlgorithm Classes ************************************/
|
||||
|
||||
/** @brief TrackerSampler based on CSC (current state centered), used by MIL algorithm TrackerMIL
|
||||
*/
|
||||
class CV_EXPORTS TrackerSamplerCSC : public TrackerSamplerAlgorithm
|
||||
{
|
||||
public:
|
||||
~TrackerSamplerCSC();
|
||||
|
||||
enum MODE
|
||||
{
|
||||
MODE_INIT_POS = 1, //!< mode for init positive samples
|
||||
MODE_INIT_NEG = 2, //!< mode for init negative samples
|
||||
MODE_TRACK_POS = 3, //!< mode for update positive samples
|
||||
MODE_TRACK_NEG = 4, //!< mode for update negative samples
|
||||
MODE_DETECT = 5 //!< mode for detect samples
|
||||
};
|
||||
|
||||
struct CV_EXPORTS Params
|
||||
{
|
||||
Params();
|
||||
float initInRad; //!< radius for gathering positive instances during init
|
||||
float trackInPosRad; //!< radius for gathering positive instances during tracking
|
||||
float searchWinSize; //!< size of search window
|
||||
int initMaxNegNum; //!< # negative samples to use during init
|
||||
int trackMaxPosNum; //!< # positive samples to use during training
|
||||
int trackMaxNegNum; //!< # negative samples to use during training
|
||||
};
|
||||
|
||||
/** @brief Constructor
|
||||
@param parameters TrackerSamplerCSC parameters TrackerSamplerCSC::Params
|
||||
*/
|
||||
TrackerSamplerCSC(const TrackerSamplerCSC::Params& parameters = TrackerSamplerCSC::Params());
|
||||
|
||||
/** @brief Set the sampling mode of TrackerSamplerCSC
|
||||
@param samplingMode The sampling mode
|
||||
|
||||
The modes are:
|
||||
|
||||
- "MODE_INIT_POS = 1" -- for the positive sampling in initialization step
|
||||
- "MODE_INIT_NEG = 2" -- for the negative sampling in initialization step
|
||||
- "MODE_TRACK_POS = 3" -- for the positive sampling in update step
|
||||
- "MODE_TRACK_NEG = 4" -- for the negative sampling in update step
|
||||
- "MODE_DETECT = 5" -- for the sampling in detection step
|
||||
*/
|
||||
void setMode(int samplingMode);
|
||||
|
||||
bool sampling(const Mat& image, const Rect& boundingBox, std::vector<Mat>& sample) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
Params params;
|
||||
int mode;
|
||||
RNG rng;
|
||||
|
||||
std::vector<Mat> sampleImage(const Mat& img, int x, int y, int w, int h, float inrad, float outrad = 0, int maxnum = 1000000);
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
}}} // namespace cv::detail::tracking
|
||||
|
||||
#endif // OPENCV_VIDEO_DETAIL_TRACKING_HPP
|
||||
16
3rdpart/OpenCV/include/opencv2/video/legacy/constants_c.h
Normal file
16
3rdpart/OpenCV/include/opencv2/video/legacy/constants_c.h
Normal file
@@ -0,0 +1,16 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#ifndef OPENCV_VIDEO_LEGACY_CONSTANTS_H
|
||||
#define OPENCV_VIDEO_LEGACY_CONSTANTS_H
|
||||
|
||||
enum
|
||||
{
|
||||
CV_LKFLOW_PYR_A_READY = 1,
|
||||
CV_LKFLOW_PYR_B_READY = 2,
|
||||
CV_LKFLOW_INITIAL_GUESSES = 4,
|
||||
CV_LKFLOW_GET_MIN_EIGENVALS = 8
|
||||
};
|
||||
|
||||
#endif // OPENCV_VIDEO_LEGACY_CONSTANTS_H
|
||||
1066
3rdpart/OpenCV/include/opencv2/video/tracking.hpp
Normal file
1066
3rdpart/OpenCV/include/opencv2/video/tracking.hpp
Normal file
File diff suppressed because it is too large
Load Diff
48
3rdpart/OpenCV/include/opencv2/video/video.hpp
Normal file
48
3rdpart/OpenCV/include/opencv2/video/video.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/*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*/
|
||||
|
||||
#ifdef __OPENCV_BUILD
|
||||
#error this is a compatibility header which should not be used inside the OpenCV library
|
||||
#endif
|
||||
|
||||
#include "opencv2/video.hpp"
|
||||
Reference in New Issue
Block a user