Commit 89311dd4 authored by Kurnianggoro's avatar Kurnianggoro

adding the resize feature

parent 43e71214
......@@ -1189,16 +1189,7 @@ class CV_EXPORTS_W TrackerTLD : public Tracker
BOILERPLATE_CODE("TLD",TrackerTLD);
};
/** @brief KCF is a novel tracking framework that explicitly decomposes the long-term tracking task into
tracking, learning and detection.
The tracker follows the object from frame to frame. The detector localizes all appearances that
have been observed so far and corrects the tracker if necessary. The learning estimates detector’s
errors and updates it to avoid these errors in the future. The implementation is based on @cite TLD .
The Median Flow algorithm (see cv::TrackerMedianFlow) was chosen as a tracking component in this
implementation, following authors. Tracker is supposed to be able to handle rapid motions, partial
occlusions, object absence etc.
/** @brief KCF is a novel tracking framework that utilize properties of circulant matrix to enhance the processing speed.
*/
class CV_EXPORTS_W TrackerKCF : public Tracker
{
......@@ -1213,6 +1204,8 @@ class CV_EXPORTS_W TrackerKCF : public Tracker
double lambda; // regularization
double interp_factor; // linear interpolation factor for adaptation
double output_sigma_factor; // spatial bandwidth (proportional to target)
bool resize; // activate the resize feature to improves the processing speed
};
/** @brief Constructor
......
......@@ -109,6 +109,8 @@ namespace cv{
Mat z, new_z;
Mat response; // detection result
bool resizeImage; // resize the image whenever needed and the patch size is large
int frame;
};
......@@ -122,6 +124,7 @@ namespace cv{
params( parameters )
{
isInit = false;
resizeImage = false;
}
void TrackerKCFImpl::read( const cv::FileNode& fn ){
......@@ -148,6 +151,15 @@ namespace cv{
output_sigma=sqrt(roi.width*roi.height)*params.output_sigma_factor;
output_sigma=-0.5/(output_sigma*output_sigma);
//resize the ROI whenever needed
if(params.resize && roi.width*roi.height>80*80){
resizeImage=true;
roi.x/=2.0;
roi.y/=2.0;
roi.width/=2.0;
roi.height/=2.0;
}
// add padding to the roi
roi.x-=roi.width/2;
roi.y-=roi.height/2+1;
......@@ -191,6 +203,9 @@ namespace cv{
cvtColor(image,img, CV_BGR2GRAY);
}else img=image;
// resize the image whenever needed
if(resizeImage)resize(img,img,Size(img.cols/2,img.rows/2));
// extract and pre-process the patch
getSubWindow(img,roi, x);
......@@ -202,8 +217,8 @@ namespace cv{
roi.x+=(maxLoc.x-roi.width/2+1);roi.y+=(maxLoc.y-roi.height/2+1);
// update the bounding box
boundingBox.x=roi.x+boundingBox.width/2;
boundingBox.y=roi.y+boundingBox.height/2;
boundingBox.x=(resizeImage?roi.x*2:roi.x)+boundingBox.width/2;
boundingBox.y=(resizeImage?roi.y*2:roi.y)+boundingBox.height/2;
}
// extract the patch for learning purpose
......@@ -459,6 +474,7 @@ namespace cv{
lambda=0.01;
interp_factor=0.075;
output_sigma_factor=1.0/16.0;
resize=true;
}
void TrackerKCF::Params::read( const cv::FileNode& fn ){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment