modelUpdateDSKCF

PURPOSE ^

MODELUPDATEDSKCF function for updating the DSKCF model %

SYNOPSIS ^

function [model_alphaf, model_alphaDf, model_xf, model_xDf]=modelUpdateDSKCF(firstFrame,patch,patch_depth,features,cell_size,cos_window,kernel,yf,lambda,model_alphaf, model_alphaDf, model_xf, model_xDf,scaleUpdate,interp_factor)

DESCRIPTION ^

MODELUPDATEDSKCF function for updating the DSKCF model %

MODELUPDATEDSKCF.m is a function used for updating the DSKCF model according
to the feature used. For more information about the model update see [1,2].
Please note that  this function was partially built extending the KCF
tracker code presented by Joao F. Henriques, in http://www.isr.uc.pt/~henriques/.


  INPUT:
  -patch patch of the color data
  -patch_depth patch of the depth data
  -features struct containing feature info.
  -cell_size HOG parameter
  -cos_window cosine window to smooth data in the Fourier domain
  -kernel struct containing kernel information
  -yf training labels
  -lambda
  - model_alphaf, model_alphaDf, model_xf, model_xDf are the models to be
  updated (for depth and color if the two features are used indipendently)
  -scaleUpdate flag set to one when the models templates need rescaling
  -interp_factor interpolation factor for the model update

  OUTPUT
  - model_alphaf, model_alphaDf, model_xf, model_xDf are the updated
  models (for depth and color if the two features are used indipendently)

 See also GAUSSIAN_CORRELATION, GET_FEATURES_DEPTH, UPDOWNSAMPLE_FOURIER
 POLYNOMIAL_CORRELATION, LINEAR_CORRELATION, SINGLEFRAMEDSKCF,
 SINGLEFRAMEDSKCF_OCCLUDER

  [1] S. Hannuna, M. Camplani, J. Hall, M. Mirmehdi, D. Damen, T.
  Burghardt, A. Paiement, L. Tao, DS-KCF: A real-time tracker for RGB-D
  data, Journal of Real-Time Image Processing

  [2] J. F. Henriques, R. Caseiro, P. Martins, and J. Batista. High-speed
  tracking with kernelized correlation filters. Pattern Analysis and
  Machine Intelligence, IEEE Transactions on, 2015.

  University of Bristol
  Massimo Camplani and Sion Hannuna

  massimo.camplani@bristol.ac.uk
  hannuna@compsci.bristol.ac.uk

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [model_alphaf, model_alphaDf, model_xf, model_xDf]=modelUpdateDSKCF(...
0002     firstFrame,patch,patch_depth,features,cell_size,cos_window,kernel,yf,...
0003     lambda,model_alphaf, model_alphaDf, model_xf, model_xDf,scaleUpdate,interp_factor)
0004 %MODELUPDATEDSKCF function for updating the DSKCF model %
0005 %
0006 %MODELUPDATEDSKCF.m is a function used for updating the DSKCF model according
0007 %to the feature used. For more information about the model update see [1,2].
0008 %Please note that  this function was partially built extending the KCF
0009 %tracker code presented by Joao F. Henriques, in http://www.isr.uc.pt/~henriques/.
0010 %
0011 %
0012 %  INPUT:
0013 %  -patch patch of the color data
0014 %  -patch_depth patch of the depth data
0015 %  -features struct containing feature info.
0016 %  -cell_size HOG parameter
0017 %  -cos_window cosine window to smooth data in the Fourier domain
0018 %  -kernel struct containing kernel information
0019 %  -yf training labels
0020 %  -lambda
0021 %  - model_alphaf, model_alphaDf, model_xf, model_xDf are the models to be
0022 %  updated (for depth and color if the two features are used indipendently)
0023 %  -scaleUpdate flag set to one when the models templates need rescaling
0024 %  -interp_factor interpolation factor for the model update
0025 %
0026 %  OUTPUT
0027 %  - model_alphaf, model_alphaDf, model_xf, model_xDf are the updated
0028 %  models (for depth and color if the two features are used indipendently)
0029 %
0030 % See also GAUSSIAN_CORRELATION, GET_FEATURES_DEPTH, UPDOWNSAMPLE_FOURIER
0031 % POLYNOMIAL_CORRELATION, LINEAR_CORRELATION, SINGLEFRAMEDSKCF,
0032 % SINGLEFRAMEDSKCF_OCCLUDER
0033 %
0034 %  [1] S. Hannuna, M. Camplani, J. Hall, M. Mirmehdi, D. Damen, T.
0035 %  Burghardt, A. Paiement, L. Tao, DS-KCF: A real-time tracker for RGB-D
0036 %  data, Journal of Real-Time Image Processing
0037 %
0038 %  [2] J. F. Henriques, R. Caseiro, P. Martins, and J. Batista. High-speed
0039 %  tracking with kernelized correlation filters. Pattern Analysis and
0040 %  Machine Intelligence, IEEE Transactions on, 2015.
0041 %
0042 %  University of Bristol
0043 %  Massimo Camplani and Sion Hannuna
0044 %
0045 %  massimo.camplani@bristol.ac.uk
0046 %  hannuna@compsci.bristol.ac.uk
0047 
0048 %feature selection
0049 if(features.hog_linear)
0050     
0051     %extract the features
0052     [xf xDf]=get_features_depth(patch,patch_depth, features, cell_size, cos_window);
0053     xf=fft2(xf);
0054     xDf=fft2(xDf);
0055     
0056     switch kernel.type
0057         case 'gaussian',
0058             kf = gaussian_correlation(xf, xf, kernel.sigma);
0059             kDf = gaussian_correlation(xDf, xDf, kernel.sigma);
0060         case 'polynomial',
0061             kf = polynomial_correlation(xf, xf, kernel.poly_a, kernel.poly_b);
0062             kDf = polynomial_correlation(xDf, xDf, kernel.poly_a, kernel.poly_b);
0063         case 'linear',
0064             kf = linear_correlation(xf, xf);
0065             kDf = linear_correlation(xDf, xDf);
0066     end
0067     
0068     alphaf = yf ./ (kf + lambda);
0069     alphaDf = yf ./ (kDf + lambda); %equation for fast training
0070     
0071     if (firstFrame),  %first frame, train with a single image
0072         model_alphaf = alphaf;
0073         model_alphaDf = alphaDf;
0074         model_xf = xf;
0075         model_xDf = xDf;
0076     else
0077         %subsequent frames, scale and interpolate model
0078         if(scaleUpdate)
0079             model_alphaf = updownsample_fourier( model_alphaf,size(alphaf,2),size(alphaf ,1));
0080             model_alphaDf = updownsample_fourier( model_alphaDf,size(alphaf,2),size(alphaf ,1));
0081             model_xf_ = xf;
0082             model_xDf_ = xDf;
0083             for i = 1:size(xf,3)
0084                 model_xf_(:,:,i) = updownsample_fourier( model_xf(:,:,i),size(xf,2),size(xf ,1));
0085                 model_xDf_(:,:,i) = updownsample_fourier( model_xDf(:,:,i),size(xDf,2),size(xDf ,1));
0086             end
0087             model_xf =  model_xf_;
0088             model_xDf =  model_xDf_;
0089             
0090             model_alphaf = (1 - interp_factor) * model_alphaf + interp_factor * alphaf;
0091             model_xf = (1 - interp_factor) * model_xf + interp_factor * xf;
0092             
0093             model_alphaDf = (1 - interp_factor) * model_alphaDf + interp_factor * alphaDf;
0094             model_xDf = (1 - interp_factor) * model_xDf + interp_factor * xDf;
0095         else
0096             %subsequent frames, interpolate model
0097             model_alphaf = (1 - interp_factor) * model_alphaf + interp_factor * alphaf;
0098             model_xf = (1 - interp_factor) * model_xf + interp_factor * xf;
0099             
0100             model_alphaDf = (1 - interp_factor) * model_alphaDf + interp_factor * alphaDf;
0101             model_xDf = (1 - interp_factor) * model_xDf + interp_factor * xDf;
0102         end
0103     end
0104     
0105 else
0106     
0107     [xf ~]=get_features_depth(patch,patch_depth, features, cell_size, cos_window);
0108     xf=fft2(xf);
0109     %Kernel Ridge Regression, calculate alphas (in Fourier domain)
0110     switch kernel.type
0111         case 'gaussian',
0112             kf = gaussian_correlation(xf, xf, kernel.sigma);
0113         case 'polynomial',
0114             kf = polynomial_correlation(xf, xf, kernel.poly_a, kernel.poly_b);
0115         case 'linear',
0116             kf = linear_correlation(xf, xf);
0117     end
0118     alphaf = yf ./ (kf + lambda);   %equation for fast training
0119     
0120     if (firstFrame),  %first frame, train with a single image
0121         model_alphaf = alphaf;
0122         model_xf = xf;
0123     else
0124         
0125         %subsequent frames, interpolate model
0126         if(scaleUpdate)
0127             
0128             bigger_flag = 0;
0129             noChangeFlag= 0;
0130             if size(alphaf ,1) > size(model_alphaf, 1)
0131                 %'bigger'
0132                 bigger_flag = 0;
0133             elseif size(alphaf ,1) == size(model_alphaf, 1)
0134                 %'should not be here'
0135                 noChangeFlag=1;
0136             else
0137                 %'smaller'
0138             end
0139             
0140             if bigger_flag%this is always zero in the final version....
0141                 model_alphaf = updownsample_fourier_leave_gain( model_alphaf,size(alphaf,2),size(alphaf ,1), alphaf);
0142                 model_xf_ = xf;
0143                 for i = 1:size(xf,3)
0144                     model_xf_(:,:,i) = updownsample_fourier_leave_gain( model_xf(:,:,i),size(xf,2),size(xf ,1), xf(:,:,i));
0145                 end
0146                 model_xf =  model_xf_;
0147                 
0148             elseif(noChangeFlag)
0149                 aaaaa=0;
0150             else
0151                 model_alphaf = updownsample_fourier( model_alphaf,size(alphaf,2),size(alphaf ,1));
0152                 model_xf_ = xf;
0153                 for i = 1:size(xf,3)
0154                     model_xf_(:,:,i) = updownsample_fourier( model_xf(:,:,i),size(xf,2),size(xf ,1));
0155                 end
0156                 model_xf =  model_xf_;
0157             end
0158             
0159             if bigger_flag
0160                 % Don't do anything - already mixed
0161             else
0162                 model_alphaf = (1 - interp_factor) * model_alphaf + interp_factor * alphaf;
0163                 model_xf = (1 - interp_factor) * model_xf + interp_factor * xf;
0164             end
0165             
0166         else
0167             model_alphaf = (1 - interp_factor) * model_alphaf + interp_factor * alphaf;
0168             model_xf = (1 - interp_factor) * model_xf + interp_factor * xf;
0169         end
0170     end
0171     model_alphaDf=[];
0172     model_xDf=[];
0173 end
0174 
0175 end

Generated on Thu 24-Nov-2016 18:03:21 by m2html © 2005