Class CirculantTracker<T extends ImageGray<T>>
Tracker that uses the theory of Circulant matrices, Discrete Fourier Transform (DCF), and linear classifiers to track a target and learn its changes in appearance [1]. The target is assumed to be rectangular and has fixed size and location. A dense local search is performed around the most recent target location. The search is done quickly using the DCF.
Tracking is performed using texture information. Since only one description of the target is saved, tracks can drift over time. Tracking performance seems to improve if the object has distinctive edges.
CHANGES FROM PAPER:
- Input image is sampled into a square work region of constant size to improve runtime speed of FFT.
- Peak of response is found using mean-shift. Provides sub-pixel precision.
- Pixels outside the image are assigned random values to avoid the tracker from fitting to them. Ideally they wouldn't be processed, but that is complex to implement
[1] Henriques, Joao F., et al. "Exploiting the circulant structure of tracking-by-detection with kernels." Computer Vision–ECCV 2012. Springer Berlin Heidelberg, 2012. 702-715.
-
Field Summary
Modifier and TypeFieldDescriptionprotected GrayF64
protected GrayF64
protected InterleavedF64
protected float
protected float
protected RectangleLength2D_F32
protected RectangleLength2D_F32
protected GrayF64
protected GrayF64
-
Constructor Summary
ConstructorDescriptionCirculantTracker
(double output_sigma_factor, double sigma, double lambda, double interp_factor, double padding, int workRegionSize, double maxPixelValue, InterpolatePixelS<T> interp) Configure tracker -
Method Summary
Modifier and TypeMethodDescriptionstatic void
protected static void
computeAlphas
(InterleavedF64 yf, InterleavedF64 kf, double lambda, InterleavedF64 alphaf) new_alphaf = yf ./ (fft2(k) + lambda); %(Eq.protected static void
computeCosineWindow
(GrayF64 cosine) Computes the cosine windowprotected void
computeGaussianWeights
(int width) Computes the weights used in the gaussian kernel This isn't actually symmetric for even widths.void
dense_gauss_kernel
(double sigma, GrayF64 x, GrayF64 y, GrayF64 k) Gaussian Kernel with dense sampling.static void
elementMultConjB
(InterleavedF64 a, InterleavedF64 b, InterleavedF64 output) Element-wise multiplication of 'a' and the complex conjugate of 'b'protected static void
gaussianKernel
(double xx, double yy, GrayF64 xy, double sigma, GrayF64 output) Computes the output of the Gaussian kernel for each element in the target region k = exp(-1 / sigma^2 * max(0, (xx + yy - 2 * xy) / numel(x)));protected void
get_subwindow
(T image, GrayF64 output) Copies the target into the output image and applies the cosine window to it.The location of the target in the imageVisual appearance of the targetstatic double
Computes the dot product of the image with itselfvoid
initialize
(T image, int x0, int y0, int regionWidth, int regionHeight) Initializes tracking around the specified rectangle regionprotected void
initialLearning
(T image) Learn the target's appearance.void
performLearning
(T image) Update the alphas and the track's appearancevoid
performTracking
(T image) Search for the track in the image andprotected void
resizeImages
(int workRegionSize) void
setTrackLocation
(int x0, int y0, int regionWidth, int regionHeight) Used to change the track's location.protected void
subpixelPeak
(int peakX, int peakY) Refine the local-peak using a search algorithm for sub-pixel accuracy.protected void
updateTrackLocation
(T image) Find the target inside the current image by searching around its last known location
-
Field Details
-
templateNew
-
template
-
cosine
-
regionTrack
-
regionOut
-
gaussianWeight
-
gaussianWeightDFT
-
offX
protected float offX -
offY
protected float offY
-
-
Constructor Details
-
CirculantTracker
public CirculantTracker(double output_sigma_factor, double sigma, double lambda, double interp_factor, double padding, int workRegionSize, double maxPixelValue, InterpolatePixelS<T> interp) Configure tracker- Parameters:
output_sigma_factor
- spatial bandwidth (proportional to target) Try 1.0/16.0sigma
- Sigma for Gaussian kernel in linear classifier. Try 0.2lambda
- Try 1e-2interp_factor
- Try 0.075padding
- Padding added around the selected target. Try 1workRegionSize
- Size of work region. Best if power of 2. Try 64maxPixelValue
- Maximum pixel value. Typically 255
-
-
Method Details
-
initialize
Initializes tracking around the specified rectangle region- Parameters:
image
- Image to start tracking fromx0
- top-left corner of regiony0
- top-left corner of regionregionWidth
- region's widthregionHeight
- region's height
-
setTrackLocation
public void setTrackLocation(int x0, int y0, int regionWidth, int regionHeight) Used to change the track's location. If this method is used it is assumed that tracking is active and that the appearance of the target has not changed- Parameters:
x0
- top-left corner of regiony0
- top-left corner of regionregionWidth
- region's widthregionHeight
- region's height
-
initialLearning
Learn the target's appearance. -
computeCosineWindow
Computes the cosine window -
computeGaussianWeights
protected void computeGaussianWeights(int width) Computes the weights used in the gaussian kernel This isn't actually symmetric for even widths. These weights are used has label in the learning phase. Closer to one the more likely it is the true target. It should be a peak in the image center. If it is not then it will learn an incorrect model. -
resizeImages
protected void resizeImages(int workRegionSize) -
performTracking
Search for the track in the image and- Parameters:
image
- Next image in the sequence
-
updateTrackLocation
Find the target inside the current image by searching around its last known location -
subpixelPeak
protected void subpixelPeak(int peakX, int peakY) Refine the local-peak using a search algorithm for sub-pixel accuracy. -
performLearning
Update the alphas and the track's appearance -
dense_gauss_kernel
Gaussian Kernel with dense sampling. Evaluates a gaussian kernel with bandwidth SIGMA for all displacements between input images X and Y, which must both be MxN. They must also be periodic (ie., pre-processed with a cosine window). The result is an MxN map of responses.- Parameters:
sigma
- Gaussian kernel bandwidthx
- Input imagey
- Input imagek
- Output containing Gaussian kernel for each element in target region
-
circshift
-
imageDotProduct
Computes the dot product of the image with itself -
elementMultConjB
Element-wise multiplication of 'a' and the complex conjugate of 'b' -
computeAlphas
protected static void computeAlphas(InterleavedF64 yf, InterleavedF64 kf, double lambda, InterleavedF64 alphaf) new_alphaf = yf ./ (fft2(k) + lambda); %(Eq. 7) -
gaussianKernel
protected static void gaussianKernel(double xx, double yy, GrayF64 xy, double sigma, GrayF64 output) Computes the output of the Gaussian kernel for each element in the target region k = exp(-1 / sigma^2 * max(0, (xx + yy - 2 * xy) / numel(x)));- Parameters:
xx
- ||x||^2yy
- ||y||^2
-
get_subwindow
Copies the target into the output image and applies the cosine window to it. -
getTargetLocation
The location of the target in the image -
getTargetTemplate
Visual appearance of the target -
getResponse
-