Class TldTracker<T extends ImageGray<T>,D extends ImageGray<D>>

java.lang.Object
boofcv.alg.tracker.tld.TldTracker<T,D>

public class TldTracker<T extends ImageGray<T>,D extends ImageGray<D>> extends Object

Main class for Tracking-Learning-Detection (TLD) [1] (a.k.a Predator) object tracker for video sequences. TLD tracks an object which is specified by a user using a rectangle. The description of the object is dynamically updated using P and N constraints.

To start tracking initialize(ImageGray, int, int, int, int) must first be called to specify the region being tracked. Then each time a new image in the sequences arrives track(ImageGray) is called. Be sure to check its return value to see if tracking was successful or not. If tracking fails one frame it can recover. This is often the case where an object becomes obscured and then visible again.

NOTE: This implementation is based the description found in [1]. The spirit of the original algorithm is replicated, but there are a several algorithmic changes. The most significant modifications are as follow; 1) The KLT tracker used to update the rectangle does not use NCC features to validate a track or the median based outlier removal. Instead a robust model matching algorithm finds the best fit motion. 2) The non-maximum suppression algorithm has been changed so that it computes a more accurate local maximum and only uses local rectangles to compute the average response. 3) Fern selection is done by selecting the N best using a likelihood ratio conditional on the current image. 4) Learning only happens when a track is considered strong. See code for more details. Note, this is not a port of the OpenTLD project.

[1] Zdenek Kalal, "Tracking-Learning-Detection" University of Surrey, April 2011 Phd Thesis.

  • Constructor Details

  • Method Details

    • initialize

      public void initialize(T image, int x0, int y0, int x1, int y1)
      Starts tracking the rectangular region.
      Parameters:
      image - First image in the sequence.
      x0 - Top-left corner of rectangle. x-axis
      y0 - Top-left corner of rectangle. y-axis
      x1 - Bottom-right corner of rectangle. x-axis
      y1 - Bottom-right corner of rectangle. y-axis
    • setTrackerLocation

      public void setTrackerLocation(int x0, int y0, int x1, int y1)
      Used to set the location of the track without changing any appearance history. Move the track region but keep the same aspect ratio as it had before So scale the region and re-center it
    • track

      public boolean track(T image)
      Updates track region.
      Parameters:
      image - Next image in the sequence.
      Returns:
      true if the object could be found and false if not
    • hypothesisFusion

      protected boolean hypothesisFusion(boolean trackingWorked, boolean detectionWorked)
      Combines hypotheses from tracking and detection.
      Parameters:
      trackingWorked - If the sequential tracker updated the track region successfully or not
      Returns:
      true a hypothesis was found, false if it failed to find a hypothesis
    • selectPyramidScale

      public static int[] selectPyramidScale(int imageWidth, int imageHeight, int minSize)
      Selects the scale for the image pyramid based on image size and feature size
      Returns:
      scales for image pyramid
    • isPerformLearning

      public boolean isPerformLearning()
    • setPerformLearning

      public void setPerformLearning(boolean performLearning)
    • getTemplateMatching

      public TldTemplateMatching<T> getTemplateMatching()
    • getTargetRegion

      public Rectangle2D_F64 getTargetRegion()
      Returns the estimated location of the target in the current image
      Returns:
      Location of the target
    • getTrackerRegion

      public Rectangle2D_F64 getTrackerRegion()
    • getConfig

      public ConfigTld getConfig()
    • getDetection

      public TldDetection<T> getDetection()