public class TrackerMeanShiftComaniciu2003<T extends boofcv.struct.image.ImageBase<T>>
extends java.lang.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.
| Modifier and Type | Field and Description |
|---|---|
protected float[] |
keyHistogram |
protected float |
scaleChange |
protected float[] |
weightHistogram |
| Constructor and Description |
|---|
TrackerMeanShiftComaniciu2003(boolean updateHistogram,
int maxIterations,
float minimumChange,
float gamma,
float minimumSizeRatio,
float scaleChange,
LocalWeightedHistogramRotRect<T> calcHistogram)
Configures tracker.
|
| Modifier and Type | Method and Description |
|---|---|
protected double |
distanceHistogram(float[] histogramA,
float[] histogramB)
Computes the difference between two histograms using SAD.
|
boofcv.struct.RectangleRotate_F32 |
getRegion() |
void |
initialize(T image,
boofcv.struct.RectangleRotate_F32 initial)
Specifies the initial image to learn the target description
|
void |
setTrackLocation(boofcv.struct.RectangleRotate_F32 location)
Used to set the location of the track without changing any appearance history.
|
void |
track(T image)
Searches for the target in the most recent image.
|
protected void |
updateLocation(T image,
boofcv.struct.RectangleRotate_F32 region)
Updates the region's location using the standard mean-shift algorithm
|
protected float[] keyHistogram
protected float[] weightHistogram
protected float scaleChange
public TrackerMeanShiftComaniciu2003(boolean updateHistogram,
int maxIterations,
float minimumChange,
float gamma,
float minimumSizeRatio,
float scaleChange,
LocalWeightedHistogramRotRect<T> calcHistogram)
updateHistogram - If true the histogram will be updated using the most recent image. Try true.maxIterations - Maximum number of mean-shift iterations. Try 30minimumChange - Mean-shift will stop when the change is below this threshold. Try 1e-4fgamma - Scale weighting factor. Value from 0 to 1. Closer to 0 the more it will prefer
the most recent estimate. Try 0.1minimumSizeRatio - Fraction of the original region that the track is allowed to shrink to. Try 0.25scaleChange - 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 histogrampublic void initialize(T image, boofcv.struct.RectangleRotate_F32 initial)
image - Imageinitial - Initial image which contains the targetpublic void setTrackLocation(boofcv.struct.RectangleRotate_F32 location)
location - new locationpublic void track(T image)
image - Most recent image in the sequenceprotected void updateLocation(T image, boofcv.struct.RectangleRotate_F32 region)
protected double distanceHistogram(float[] histogramA,
float[] histogramB)
public boofcv.struct.RectangleRotate_F32 getRegion()