Skip to content

Commit f99369e

Browse files
committed
Merge pull request #6 from nailbiter/optimPF
The implementation of particle filtering tracker
2 parents dd1fd48 + ceb74ac commit f99369e

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

modules/tracking/doc/common_interfaces_tracker_sampler.rst

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ The modes available now:
8787

8888
* ``"CS"`` -- Current State
8989

90+
* ``"PF"`` -- Particle Filtering
91+
9092
Example ``TrackerSamplerAlgorithm::addTrackerSamplerAlgorithm`` : ::
9193

9294
//sample usage:
@@ -164,7 +166,7 @@ Get the name of the specific TrackerSamplerAlgorithm
164166
Specialized TrackerSamplerAlgorithm
165167
===================================
166168

167-
In [AAM]_ table I are described the most known sampling strategies. At moment :ocv:class:`TrackerSamplerCSC` and :ocv:class:`TrackerSamplerCS` are implemented.
169+
In [AAM]_ table I there are described the most known sampling strategies. At moment :ocv:class:`TrackerSamplerCSC` and :ocv:class:`TrackerSamplerCS` are implemented. Beside these, there is :ocv:class:`TrackerSamplerPF`, sampler based on particle filtering.
168170

169171
TrackerSamplerCSC : TrackerSamplerAlgorithm
170172
-------------------------------------------
@@ -291,3 +293,55 @@ The modes are:
291293
* ``"MODE_POSITIVE = 1"`` -- for the positive sampling
292294
* ``"MODE_NEGATIVE = 2"`` -- for the negative sampling
293295
* ``"MODE_CLASSIFY = 3"`` -- for the sampling in classification step
296+
297+
TrackerSamplerPF : TrackerSamplerAlgorithm
298+
-------------------------------------------
299+
300+
This sampler is based on particle filtering. In principle, it can be thought of as performing some sort of optimization (and indeed, this
301+
tracker uses opencv's ``optim`` module), where tracker seeks to find the rectangle in given frame, which is the most *"similar"* to the initial
302+
rectangle (the one, given through the constructor).
303+
304+
The optimization performed is stochastic and somehow resembles genetic algorithms, where on each new ``image`` received (submitted via ``TrackerSamplerPF::sampling()``) we start with the region bounded by ``boundingBox``, then generate several "perturbed" boxes, take the ones most similar to the original. This selection round is repeated several times. At the end, we hope that only the most promising box remaining, and these are combined to produce the subrectangle of ``image``, which is put as a sole element in array ``sample``.
305+
306+
It should be noted, that the definition of "similarity" between two rectangles is based on comparing their histograms. As experiments show, tracker is *not* very succesfull if target is assumed to strongly change its dimensions.
307+
308+
.. ocv:class:: TrackerSamplerPF
309+
310+
TrackerSamplerPF class::
311+
312+
class CV_EXPORTS_W TrackerSamplerPF : public TrackerSamplerAlgorithm{
313+
public:
314+
TrackerSamplerPF(const Mat& chosenRect,const TrackerSamplerPF::Params &parameters = TrackerSamplerPF::Params());
315+
void sampling( const Mat& image, Rect boundingBox, std::vector<Mat>& sample ); //inherited from TrackerSamplerAlgorithmTrackerSamplerAlgorithm
316+
};
317+
318+
319+
TrackerSamplerPF::Params
320+
-------------------------
321+
322+
.. ocv:struct:: TrackerSamplerPF::Params
323+
324+
This structure contains all the parameters that can be varied during the course of sampling algorithm. Below is the structure exposed,
325+
together with its members briefly explained with reference to the above discussion on algorithm's working.
326+
327+
::
328+
329+
struct CV_EXPORTS Params
330+
{
331+
Params();
332+
int iterationNum; //number of selection rounds
333+
int particlesNum; //number of "perturbed" boxes on each round
334+
double alpha; //with each new round we exponentially decrease the amount of "perturbing" we allow (like in simulated annealing)
335+
//and this very alpha controls how fast annealing happens, ie. how fast perturbing decreases
336+
Mat_<double> std; //initial values for perturbing (1-by-4 array, as each rectangle is given by 4 values -- coordinates of opposite vertices,
337+
//hence we have 4 values to perturb)
338+
};
339+
340+
TrackerSamplerPF::TrackerSamplerPF
341+
------------------------------------
342+
343+
Constructor
344+
345+
.. ocv:function:: TrackerSamplerPF(const Mat& chosenRect,const TrackerSamplerPF::Params &parameters = TrackerSamplerPF::Params())
346+
347+
:param chosenRect: Initial rectangle, that is supposed to contain target we'd like to track.

0 commit comments

Comments
 (0)