Class TrackerMeanShiftComaniciu2003<T extends ImageBase<T>>

java.lang.Object
boofcv.alg.tracker.meanshift.TrackerMeanShiftComaniciu2003<T>

public class TrackerMeanShiftComaniciu2003<T extends ImageBase<T>> extends Object

Mean shift tracker which adjusts the scale (or bandwidth) to account for changes in scale of the target and is based off of [1]. The tracker seeks to minimize the histogram error within the sampled region. The mean-shift region is sampled using an oriented rectangle and weighted using a 2D gaussian. The target is modeled using a color histogram of the input image, which can be optionally updated after each frame is processed. It can also be configured to not allow scale changes, which can improve stability.

Scale selection is done using sum-of-absolute-difference (SAD) error instead of Bhattacharyya as the paper suggests. Situations where found that two errors counteracted each other when using Bhattacharyya and the incorrect scale would be selected even with perfect data.

Another difference from the paper is that mean shift records which hypothesis has the best SAD error. After mean-shift stops iterating it selects the best solution. This is primarily helpful in situations where mean-shift doesn't converge in time and jumped away from the solution.

[1] Dorin Comaniciu, Visvanathan Ramesh, and Peter Meer,"Kernel-Based Object Tracking." IEEE Transactions on Pattern Analysis and Machine Intelligence 25.4 (2003): 1.

  • Field Details

    • keyHistogram

      protected float[] keyHistogram
    • weightHistogram

      protected float[] weightHistogram
    • scaleChange

      protected float scaleChange
  • Constructor Details

    • TrackerMeanShiftComaniciu2003

      public TrackerMeanShiftComaniciu2003(boolean updateHistogram, int maxIterations, float minimumChange, float gamma, float minimumSizeRatio, float scaleChange, LocalWeightedHistogramRotRect<T> calcHistogram)
      Configures tracker.
      Parameters:
      updateHistogram - If true the histogram will be updated using the most recent image. Try true.
      maxIterations - Maximum number of mean-shift iterations. Try 30
      minimumChange - Mean-shift will stop when the change is below this threshold. Try 1e-4f
      gamma - Scale weighting factor. Value from 0 to 1. Closer to 0 the more it will prefer the most recent estimate. Try 0.1
      minimumSizeRatio - Fraction of the original region that the track is allowed to shrink to. Try 0.25
      scaleChange - The scale can be changed by this much between frames. 0 to 1. 0 = no scale change. 0.1 is recommended value in paper. no scale change is more stable.
      calcHistogram - Calculates the histogram
  • Method Details

    • initialize

      public void initialize(T image, RectangleRotate_F32 initial)
      Specifies the initial image to learn the target description
      Parameters:
      image - Image
      initial - Initial image which contains the target
    • setTrackLocation

      public void setTrackLocation(RectangleRotate_F32 location)
      Used to set the location of the track without changing any appearance history.
      Parameters:
      location - new location
    • track

      public void track(T image)
      Searches for the target in the most recent image.
      Parameters:
      image - Most recent image in the sequence
    • updateLocation

      protected void updateLocation(T image, RectangleRotate_F32 region)
      Updates the region's location using the standard mean-shift algorithm
    • distanceHistogram

      protected double distanceHistogram(float[] histogramA, float[] histogramB)
      Computes the difference between two histograms using SAD. This is a change from the paper, which uses Bhattacharyya. Bhattacharyya could give poor performance even with perfect data since two errors can cancel each other out. For example, part of the histogram is too small and another part is too large.
    • getRegion

      public RectangleRotate_F32 getRegion()