OpenCV
4.1.0
Open Source Computer Vision
|
In this tutorial you will learn how to
This document contains tutorial for the cv::TrackerKCF.
This part explains how to set custom parameters and use your own feature-extractor function for the CN tracker. If you need a more detailed information to use cv::Tracker, please refer to Introduction to OpenCV Tracker.
Set Custom Parameters
To set custom paramters, an object should be created. Each tracker algorithm has their own parameter format. So, in this case we should use parameter from cv::TrackerKCF since we are interested in modifying the parameter of this tracker algorithm.
There are several parameters that can be configured as explained in cv::TrackerKCF::Params. For this tutorial, we focussed on the feature extractor functions.
Several feature types can be used in cv::TrackerKCF. In this case, the grayscale value (1 dimension) and color-names features (10 dimension), will be merged as 11 dimension feature and then compressed into 2 dimension as specified in the code.
If you want to use another type of pre-defined feature-extractor function, you can check in cv::TrackerKCF::MODE. We will leave the non-compressed feature as 0 since we want to use a customized function.
Using a custom function
You can define your own feature-extractor function for the CN tracker. However, you need to take care about several things:
Since the size of the extracted feature should be in the same size with the given bounding box, we need to take care whenever the given bounding box is partially out of range. In this case, we can copy part of image contained in the bounding box as shown in the snippet below.
Whenever the copied image is smaller than the given bounding box, padding should be given to the sides where the bounding box is partially out of frame.
Defining the feature
In this tutorial, the extracted feature is reponse of the Sobel filter in x and y direction. Those Sobel filter responses are concatenated, resulting a feature with 2 channels.
Post processing
Make sure to convert the feature into cv::CV_64F data format and normalize its value with range -0.5 to 0.5