common_interfaces_tracker_feature_set.rst 8.97 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
Common Interfaces of TrackerFeatureSet
======================================

.. highlight:: cpp


TrackerFeatureSet
-----------------

Class that manages the extraction and selection of features

[AAM]_ Feature Extraction and Feature Set Refinement (Feature Processing and Feature Selection). See table I and section III C
[AMVOT]_ Appearance modelling -> Visual representation (Table II, section 3.1 - 3.2)

.. ocv:class:: TrackerFeatureSet

TrackerFeatureSet class::

   class CV_EXPORTS_W TrackerFeatureSet
   {
    public:

     TrackerFeatureSet();
     ~TrackerFeatureSet();

     void extraction( const std::vector<Mat>& images );
     void selection();
     void removeOutliers();

     bool addTrackerFeature( String trackerFeatureType );
     bool addTrackerFeature( Ptr<TrackerFeature>& feature );

     const std::vector<std::pair<String, Ptr<TrackerFeature> > >& getTrackerFeature() const;
     const std::vector<Mat>& getResponses() const;

   };


TrackerFeatureSet is an aggregation of :ocv:class:`TrackerFeature`

.. seealso::

   :ocv:class:`TrackerFeature`

TrackerFeatureSet::extraction
-----------------------------

Extract features from the images collection

.. ocv:function:: void TrackerFeatureSet::extraction( const std::vector<Mat>& images )

    :param images: The input images

TrackerFeatureSet::selection
----------------------------

Identify most effective features for all feature types (optional)

.. ocv:function:: void TrackerFeatureSet::selection()

TrackerFeatureSet::removeOutliers
---------------------------------

Remove outliers for all feature types (optional)

.. ocv:function:: void TrackerFeatureSet::removeOutliers()

TrackerFeatureSet::addTrackerFeature
------------------------------------

Add TrackerFeature in the collection. Return true if TrackerFeature is added, false otherwise

.. ocv:function:: bool TrackerFeatureSet::addTrackerFeature( String trackerFeatureType )

   :param trackerFeatureType: The TrackerFeature name

.. ocv:function:: bool TrackerFeatureSet::addTrackerFeature( Ptr<TrackerFeature>& feature )

   :param feature: The TrackerFeature class


The modes available now:

* ``"HAAR"`` -- Haar Feature-based

86
The modes that will be available soon:
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172

* ``"HOG"`` -- Histogram of Oriented Gradients features

* ``"LBP"`` -- Local Binary Pattern features

* ``"FEATURE2D"`` -- All types of Feature2D

Example ``TrackerFeatureSet::addTrackerFeature`` : ::

   //sample usage:

   Ptr<TrackerFeature> trackerFeature = new TrackerFeatureHAAR( HAARparameters );
   featureSet->addTrackerFeature( trackerFeature );

   //or add CSC sampler with default parameters
   //featureSet->addTrackerFeature( "HAAR" );


.. note:: If you use the second method, you must initialize the TrackerFeature

TrackerFeatureSet::getTrackerFeature
------------------------------------

Get the TrackerFeature collection (TrackerFeature name, TrackerFeature pointer)

.. ocv:function:: const std::vector<std::pair<String, Ptr<TrackerFeature> > >& TrackerFeatureSet::getTrackerFeature() const

TrackerFeatureSet::getResponses
-------------------------------

Get the responses

.. ocv:function:: const std::vector<Mat>& TrackerFeatureSet::getResponses() const

.. note:: Be sure to call extraction before getResponses

Example ``TrackerFeatureSet::getResponses`` : ::

   //get the patches from sampler
   std::vector<Mat> detectSamples = sampler->getSamples();

   if( detectSamples.empty() )
      return false;

   //features extraction
   featureSet->extraction( detectSamples );

   //get responses
   std::vector<Mat> response = featureSet->getResponses();

TrackerFeature
--------------

Abstract base class for TrackerFeature that represents the feature.

.. ocv:class:: TrackerFeature

TrackerFeature class::

   class CV_EXPORTS_W TrackerFeature
   {
    public:
     virtual ~TrackerFeature();

     static Ptr<TrackerFeature> create( const String& trackerFeatureType );

     void compute( const std::vector<Mat>& images, Mat& response );

     virtual void selection( Mat& response, int npoints ) = 0;

     String getClassName() const;
   };

TrackerFeature::create
----------------------

Create TrackerFeature by tracker feature type

.. ocv:function:: static Ptr<TrackerFeature> TrackerFeature::create( const String& trackerFeatureType )

   :param trackerFeatureType: The TrackerFeature name

The modes available now:

* ``"HAAR"`` -- Haar Feature-based

173
The modes that will be available soon:
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343

* ``"HOG"`` -- Histogram of Oriented Gradients features

* ``"LBP"`` -- Local Binary Pattern features

* ``"FEATURE2D"`` -- All types of Feature2D

TrackerFeature::compute
-----------------------

Compute the features in the images collection

.. ocv:function:: void TrackerFeature::compute( const std::vector<Mat>& images, Mat& response )

   :param images: The images

   :param response: The output response

TrackerFeature::selection
-------------------------

Identify most effective features

.. ocv:function:: void TrackerFeature::selection( Mat& response, int npoints )

   :param response:  Collection of response for the specific TrackerFeature

   :param npoints: Max number of features

.. note:: This method modifies the response parameter

TrackerFeature::getClassName
----------------------------

Get the name of the specific TrackerFeature

.. ocv:function::  String TrackerFeature::getClassName() const

Specialized TrackerFeature
==========================

In [AAM]_ table I and section III C are described the most known features type. At moment only :ocv:class:`TrackerFeatureHAAR` is implemented.

TrackerFeatureHAAR : TrackerFeature
-----------------------------------

TrackerFeature based on HAAR features, used by TrackerMIL and many others algorithms

.. ocv:class:: TrackerFeatureHAAR

TrackerFeatureHAAR class::

   class CV_EXPORTS_W TrackerFeatureHAAR : TrackerFeature
   {
    public:

     TrackerFeatureHAAR( const TrackerFeatureHAAR::Params &parameters = TrackerFeatureHAAR::Params() );
     ~TrackerFeatureHAAR();

     void selection( Mat& response, int npoints );
     bool extractSelected( const std::vector<int> selFeatures, const std::vector<Mat>& images, Mat& response );
     std::vector<std::pair<float, float> >& getMeanSigmaPairs();
     bool swapFeature( int source, int target );
     bool swapFeature( int id, CvHaarEvaluator::FeatureHaar& feature );
     CvHaarEvaluator::FeatureHaar& getFeatureAt( int id );
   };

.. note:: HAAR features implementation is copied from apps/traincascade and modified according to MIL implementation

TrackerFeatureHAAR::Params
--------------------------

.. ocv:struct:: TrackerFeatureHAAR::Params

List of TrackerFeatureHAAR parameters::

   struct CV_EXPORTS Params
   {
    Params();
    int numFeatures; // # of rects
    Size rectSize;   // rect size
    bool isIntegral;  // true if input images are integral, false otherwise
   };

TrackerFeatureHAAR::TrackerFeatureHAAR
--------------------------------------

Constructor

.. ocv:function:: TrackerFeatureHAAR::TrackerFeatureHAAR( const TrackerFeatureHAAR::Params &parameters = TrackerFeatureHAAR::Params() )

    :param parameters: TrackerFeatureHAAR parameters :ocv:struct:`TrackerFeatureHAAR::Params`


TrackerFeatureHAAR::selection
-----------------------------

Identify most effective features

.. ocv:function:: void TrackerFeatureHAAR::selection( Mat& response, int npoints )

   :param response:  Collection of response for the specific TrackerFeature

   :param npoints: Max number of features

.. note:: This method modifies the response parameter

TrackerFeatureHAAR::extractSelected
-----------------------------------

Compute the features only for the selected indices in the images collection

.. ocv:function:: bool TrackerFeatureHAAR::extractSelected( const std::vector<int> selFeatures, const std::vector<Mat>& images, Mat& response )

   :param selFeatures:  indices of selected features

   :param images:  The images

   :param response:  Collection of response for the specific TrackerFeature

TrackerFeatureHAAR::getMeanSigmaPairs
-------------------------------------

Get the list of mean/sigma. Return the list of mean/sigma

.. ocv:function:: std::vector<std::pair<float, float> >& TrackerFeatureHAAR::getMeanSigmaPairs()

TrackerFeatureHAAR::swapFeature
-------------------------------

Swap the feature in position source with the feature in position target

.. ocv:function:: bool TrackerFeatureHAAR::swapFeature( int source, int target )

   :param source:  The source position

   :param target:  The target position

Swap the feature in position id with the feature input

.. ocv:function:: bool TrackerFeatureHAAR::swapFeature( int id, CvHaarEvaluator::FeatureHaar& feature )

   :param id: The position

   :param feature: The feature

TrackerFeatureHAAR::getFeatureAt
--------------------------------

Get the feature in position id

.. ocv:function:: CvHaarEvaluator::FeatureHaar& TrackerFeatureHAAR::getFeatureAt( int id )

   :param id: The position


TrackerFeatureHOG
-----------------

TODO To be implemented

TrackerFeatureLBP
-----------------

TODO To be implemented

TrackerFeatureFeature2d
-----------------------

TODO To be implemented