Skip to main content

Tracking parameters

This section details how to select the relevant tracking features to be included in the cost function and how to tune them.

How it works

FastTrack uses the so-called Hungarian method to solve the assignment problem of each object between two frames. This method is based on minimizing the global cost of the association pairs of objects.

Cost function

The cost is calculated from a cost function that can be constructed from several parameters, in the following, i is indexing the image n, and j the image n + 1:

  • The distance dij=(xixj)2+(yiyj)2d{ij} = \sqrt{(x_i - x_j)^2 + (y_i - y_j)^2}
  • The angle aij=min(θiθj)a_{ij} = min(\theta_i - \theta_j)
  • The area arij=abs(areaiareaj)ar_{ij} = abs(area_i - area_j)
  • The perimeter pij=abs(perimeteriperimeterj)p_{ij} = abs(perimeter_i - perimeter_j)

The relative weight of these contributions to the cost function are set by 4 normalization parameters:

cij=dijD+aijA+arijAR+pijPc_{ij} = \frac{d{ij}}{D} + \frac{a{ij}}{A}+ \frac{ar{ij}}{AR} + \frac{p{ij}}{P}

These parameters can be set to 0 to cancel one or several tracking feature from the cost computation. All these features are not always relevant and has to be chosen carrefully for the best tracking accuracy. For example, for tracking circles of radius r, and squares of the same area moving at 10px/image, it is best to set

(D=10,A=0,AR=0,P=2r(π2π))(D=10, A=0, AR=0, P=2r(\pi-2\sqrt{\pi}))

For tracking fish of the same size, travelling at 35px/image, doing small reorientation of 20°, it is best to set

(D=35,A=20,AR=0,P=0))(D=35, A=20, AR=0, P=0))

For tracking fish of different size, travelling at 35px/image, doing small reorientation of 20°, with size difference of 100px it is best to set

(D=35,A=20,AR=100,P=0))(D=35, A=20, AR=100, P=0))

The best way to set the parameter is to first set the normalization parameters to the mean of the variable, .ie the typical change between two consecutive images:

  • D=mean(dij)D = mean(d_{ij}) where i and j are the same object.
  • A=mean(aij)A = mean(a_{ij}) where i and j are the same object.
  • AR=mean(arij)AR = mean(ar_{ij}) where i and j are the same object.
  • P=mean(pij)P = mean(p_{ij}) where i and j are the same object. In this case, each tracking feature has the same contribution to the cost. To tune the cost function by weighting more (resp. less) a tracking feature, decrease (resp. increase) the normalization parameter of this feature, or increase (resp. decrease) all the normalization parameters of the others.

Memory and distance

A parameter of memory named maximal time can be set to account for disappearing objects. If the maximal time is set to m, one object can only disappear during m image. If it reappears after, it will be considered as a new object.

To speed-up the tracking, the maximal distance (L) parameter sets an infinite cost for all the pairs of objects to such as dij>Ld_{ij} > L. In practice, L is corresponding to the maximal distance an object can disappear.


The spot to track will determine if the distance and the angular difference will be calculated from the head, the tail, or the body of the object. Area and perimeter are always computed from the body. Head is defined as the bigger half of the object, separated alongside the object's minor axis.


Setting the tracking parameters can be tedious. It can be best achieved by trials and errors (see the Preview option in the Interactive panel). to summarize:

  1. Choose the right tracking features.
  2. Set the normalization parameters equal to the tracking feature's std, ie, the typical value change.
  3. Tune the normalization parameters to increase or decrease the relative weight between each contribution.