MAXRESPONSEDSKCF function for calculating the DSKCF response MAXRESPONSEDSKCF.m is a function used for calculating the DSKCF response For more information about the DSKCF response see [1]. 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 image patch of the color data -patch_depth image patch of the depth data - depth16Bit depth image -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 - 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) -prevPos is the position of the tracked target in the previous frame [y x] format (read as ([row column])) -nRows,nCols input image size OUTPUT - response response of DSKCF -maxResponse maximum value of the DSKCF response -maxPositionImagePlane vector containing the position in the image plane of the target's centroid. It is in the format [y, x] (read also as [rowIndex, columIndex]) See also GAUSSIAN_CORRELATION, GET_FEATURES_DEPTH, POLYNOMIAL_CORRELATION, LINEAR_CORRELATION, TARGETSEARCHDSKCF, 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
0001 0002 function [ response, maxResponse, maxPositionImagePlane] = maxResponseDSKCF... 0003 ( patch,patch_depth, features,kernel,prevPos,cell_size, cos_window,... 0004 model_xf,model_alphaf,model_xDf,model_alphaDf,nRows,nCols) 0005 %MAXRESPONSEDSKCF function for calculating the DSKCF response 0006 % 0007 %MAXRESPONSEDSKCF.m is a function used for calculating the DSKCF response 0008 %For more information about the DSKCF response see [1]. 0009 %Please note that this function was partially built extending the KCF 0010 %tracker code presented by Joao F. Henriques, in http://www.isr.uc.pt/~henriques/. 0011 % 0012 % 0013 % INPUT: 0014 % -patch image patch of the color data 0015 % -patch_depth image patch of the depth data 0016 % - depth16Bit depth image 0017 % -features struct containing feature info. 0018 % -cell_size HOG parameter 0019 % -cos_window cosine window to smooth data in the Fourier domain 0020 % -kernel struct containing kernel information 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 % -prevPos is the position of the tracked target in the previous frame [y 0024 % x] format (read as ([row column])) 0025 % -nRows,nCols input image size 0026 % 0027 % 0028 % OUTPUT 0029 % - response response of DSKCF 0030 % -maxResponse maximum value of the DSKCF response 0031 % -maxPositionImagePlane vector containing the position in the image 0032 % plane of the target's centroid. It is in the format [y, x] (read also as 0033 % [rowIndex, columIndex]) 0034 % 0035 % See also GAUSSIAN_CORRELATION, GET_FEATURES_DEPTH, 0036 % POLYNOMIAL_CORRELATION, LINEAR_CORRELATION, TARGETSEARCHDSKCF, 0037 % SINGLEFRAMEDSKCF_OCCLUDER 0038 % 0039 % 0040 % [1] S. Hannuna, M. Camplani, J. Hall, M. Mirmehdi, D. Damen, T. 0041 % Burghardt, A. Paiement, L. Tao, DS-KCF: A real-time tracker for RGB-D 0042 % data, Journal of Real-Time Image Processing 0043 % 0044 % [2] J. F. Henriques, R. Caseiro, P. Martins, and J. Batista. High-speed 0045 % tracking with kernelized correlation filters. Pattern Analysis and 0046 % Machine Intelligence, IEEE Transactions on, 2015. 0047 % 0048 % University of Bristol 0049 % Massimo Camplani and Sion Hannuna 0050 % 0051 % massimo.camplani@bristol.ac.uk 0052 % hannuna@compsci.bristol.ac.uk 0053 0054 if(features.hog_linear) 0055 0056 [zf zDf]=get_features_depth(patch,patch_depth, features, cell_size, cos_window); 0057 zf=fft2(zf); 0058 zDf=fft2(zDf); 0059 %calculate response of the classifier at all shifts 0060 switch kernel.type 0061 case 'gaussian', 0062 kzf = gaussian_correlation(zf, model_xf, kernel.sigma); 0063 kzDf = gaussian_correlation(zDf, model_xDf, kernel.sigma); 0064 0065 case 'polynomial', 0066 kzf = polynomial_correlation(zf, model_xf, kernel.poly_a, kernel.poly_b); 0067 kzDf = polynomial_correlation(zDf, model_xDf, kernel.poly_a, kernel.poly_b); 0068 case 'linear', 0069 kzf = linear_correlation(zf, model_xf); 0070 kzDf = linear_correlation(zDf, model_xDf); 0071 end 0072 response = real(ifft2(model_alphaf .* kzf)); %equation for fast detection 0073 responseD = real(ifft2(model_alphaDf .* kzDf)); 0074 0075 %COMBINATION OF RESPONSES LINEAR... 0076 response=response+responseD; 0077 response=response./2; 0078 0079 %Combination of Response....select maximmun 0080 %maxResponseRGB=max(response(:)); 0081 %[maxResponseD,index]=max(responseD(:)); 0082 %if(maxResponseD>maxResponseRGB) 0083 % response(index)=maxResponseD; 0084 %end 0085 else 0086 0087 [zf dummyValue]=get_features_depth(patch,patch_depth, features, cell_size, cos_window); 0088 zf=fft2(zf); 0089 0090 %calculate response of the classifier at all shifts 0091 switch kernel.type 0092 case 'gaussian', 0093 kzf = gaussian_correlation(zf, model_xf, kernel.sigma); 0094 case 'polynomial', 0095 kzf = polynomial_correlation(zf, model_xf, kernel.poly_a, kernel.poly_b); 0096 case 'linear', 0097 kzf = linear_correlation(zf, model_xf); 0098 end 0099 response = real(ifft2(model_alphaf .* kzf)); %equation for fast detection 0100 0101 end 0102 0103 maxResponse=max(response(:)); 0104 [vert_delta, horiz_delta] = find(response == maxResponse, 1); 0105 if vert_delta > size(response,1) / 2, %wrap around to negative half-space of vertical axis 0106 vert_delta = vert_delta - size(response,1); 0107 end 0108 if horiz_delta > size(response,2) / 2, %same for horizontal axis 0109 horiz_delta = horiz_delta - size(response,2); 0110 end 0111 maxPositionImagePlane = prevPos + cell_size * [vert_delta - 1, horiz_delta - 1]; 0112 0113 maxPositionImagePlane(maxPositionImagePlane<1)=1; 0114 if(maxPositionImagePlane(1)>nRows) 0115 maxPositionImagePlane(1)=nRows; 0116 end 0117 if(maxPositionImagePlane(2)>nCols) 0118 maxPositionImagePlane(2)=nCols; 0119 end 0120 0121 0122 0123