Class TldTracker<T extends ImageGray<T>,D extends ImageGray<D>>
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 Summary
ConstructorDescriptionTldTracker
(ConfigTld config, InterpolatePixelS<T> interpolate, ImageGradient<T, D> gradient, Class<T> imageType, Class<D> derivType) Configures the TLD tracker -
Method Summary
Modifier and TypeMethodDescriptionReturns the estimated location of the target in the current imageprotected boolean
hypothesisFusion
(boolean trackingWorked, boolean detectionWorked) Combines hypotheses from tracking and detection.void
initialize
(T image, int x0, int y0, int x1, int y1) Starts tracking the rectangular region.boolean
static int[]
selectPyramidScale
(int imageWidth, int imageHeight, int minSize) Selects the scale for the image pyramid based on image size and feature sizevoid
setPerformLearning
(boolean performLearning) void
setTrackerLocation
(int x0, int y0, int x1, int y1) Used to set the location of the track without changing any appearance history.boolean
Updates track region.
-
Constructor Details
-
TldTracker
public TldTracker(ConfigTld config, InterpolatePixelS<T> interpolate, ImageGradient<T, D> gradient, Class<T> imageType, Class<D> derivType) Configures the TLD tracker- Parameters:
config
- Configuration class which specifies the tracker's behavior
-
-
Method Details
-
initialize
Starts tracking the rectangular region.- Parameters:
image
- First image in the sequence.x0
- Top-left corner of rectangle. x-axisy0
- Top-left corner of rectangle. y-axisx1
- Bottom-right corner of rectangle. x-axisy1
- 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
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
-
getTargetRegion
Returns the estimated location of the target in the current image- Returns:
- Location of the target
-
getTrackerRegion
-
getConfig
-
getDetection
-