Mean Shift Tracking

Mean shift tracking is one of the basic object tracking algorithms. Mean-shift tracking tries to find the area of a video frame that is locally most similar to a previously initialized model. The object to be tracked is represented by a histogram. In object tracking algorithms target representation is mainly rectangular or elliptical region. It contain target model and target candidate. Color histogram is used to characterize the object. Target model is generally represented by its probability density function (pdf). Weighted RGB histogram is used to give more importance to object pixels.

Mean-shift algorithm is an iterative technique for locating the maxima of a density function. For object tracking, the density function used is the weight image formed using color histograms of the object to be tracked and the frame to be tested. By using the weighted histogram we are taking spatial position into consideration unlike the normal histogram calculation. This function will take input image pointer, top left and bottom right coordinates of the rectangular object, frame number and tracking status as inputs and returns the centroid using recursive mean shift approach.

API Syntax

template  void xFMeanShift(xF::Mat &_in_mat, uint16_t* x1, uint16_t* y1, uint16_t* obj_height, uint16_t* obj_width, uint16_t* dx, uint16_t* dy, uint16_t* status, uint8_t frame_status, uint8_t no_objects, uint8_t no_iters );

Template Parameter Descriptions

The following table describes the template parameters.

Table 1.xFMeanShift Template Parameters
PARAMETERS DESCRIPTION
ROWS Maximum height of the image
COLS Maximum width of the image
OBJ_ROWS Maximum Height of the object to be tracked
OBJ_COLS Maximum width of the object to be tracked
MAXOBJ Maximum number of objects to be tracked
MAXITERS Maximum iterations for convergence
SRC_T Type of the input xf::Mat, must be XF_8UC4, 8-bit data with 4 channels
NPC Number of pixels to be processed per cycle; this function supports only XF_NPPC1 or 1 pixel per cycle operations.

Function Parameter Description

The following table describes the function parameters.

Table 2.xFMeanShift Function Parameters
PARAMETERS DESCRIPTION
_in_mat Input xF Mat
x1 Top Left corner x-coordinate ( row number ) of all the objects
y1 Top Left corner y-coordinate ( col number ) of all the objects
obj_height Height of all the objects (must be odd)
obj_width Width of all the objects ( must be odd)
dx Centers x-coordinate of all the objects returned by the kernel function
dy Centers y-coordinate of all the objects returned by the kernel function
status Track the object only if the status of the object is true (i.e.) if the object goes out of the frame, status is made zero
frame_status Set as zero for the first frame and one for other frames
no_objects Number of objects we want to track
no_iters Number of iterations for convergence

Resource Utilization and Performance Estimate

The following table summarizes the resource utilization of xFMeanShift() for normal (1 pixel) configuration as generated inVivado HLS 2017.1release tool for the part xczu9eg-ffvb1156-i-es1 at 300 MHz to process a RGB image of resolution,1920x1080, and for 10 objects of size of 250x250 and 4 iterations.

Table 3.xFMeanShift Function Resource Utilization and Performance Estimate Summary
Configuration Max. Latency BRAMs DSPs FFs LUTs
1 pixel 19.28 76 14 13198 10064

Limitations

The maximum number of objects that can be tracked is 10.