BESTRESPONSES.m select the maximum response of DSKCF tracker BESTRESPONSES is is a function used for selecting the maximum DSKCF response. The response of a pool of candidate positions is weighted considering the depth information of the target. 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: - depth16Bit depth image - response of the DSKCF tracker -cell_size HOG parameter -meanDepthObj mean depth value of the target object -stdDepthObj depth standard deviation of the target object -previousPos is the position of the tracked target in the previous frame It is in the format [y, x] (read also as [rowIndex, columIndex]) OUTPUT -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 MAXRESPONSEDEPTHWEIGHTDSKCF, wrapperDSKCF, initDSKCFparam, INITDSKCFPARAM, INITDSKCFTRACKER, MODELUPDATEDSKCF [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 University of Bristol Massimo Camplani and Sion Hannuna massimo.camplani@bristol.ac.uk hannuna@compsci.bristol.ac.uk
0001 function [maxResponse, maxPositionImagePlane]=bestResponses(depth16Bit,... 0002 response,poolSize,cell_size,previousPos,meanDepthObj,stdDepthObj) 0003 % BESTRESPONSES.m select the maximum response of DSKCF tracker 0004 % 0005 % 0006 % BESTRESPONSES is is a function used for selecting the maximum DSKCF 0007 % response. The response of a pool of candidate positions is weighted 0008 % considering the depth information of the target. For more information 0009 % about the DSKCF response see [1]. 0010 % Please note that this function was partially built extending the KCF 0011 % tracker code presented by Joao F. Henriques, in 0012 % http://www.isr.uc.pt/~henriques/. 0013 % 0014 % INPUT: 0015 % - depth16Bit depth image 0016 % - response of the DSKCF tracker 0017 % -cell_size HOG parameter 0018 % -meanDepthObj mean depth value of the target object 0019 % -stdDepthObj depth standard deviation of the target object 0020 % -previousPos is the position of the tracked target in the previous frame 0021 % It is in the format [y, x] (read also as [rowIndex, columIndex]) 0022 % 0023 % OUTPUT 0024 % -maxResponse maximum value of the DSKCF response 0025 % -maxPositionImagePlane vector containing the position in the image 0026 % plane of the target's centroid. It is in the format [y, x] (read also 0027 % as [rowIndex, columIndex]) 0028 % 0029 % See also MAXRESPONSEDEPTHWEIGHTDSKCF, wrapperDSKCF, initDSKCFparam, 0030 % INITDSKCFPARAM, INITDSKCFTRACKER, MODELUPDATEDSKCF 0031 % 0032 %[1] S. Hannuna, M. Camplani, J. Hall, M. Mirmehdi, D. Damen, T. Burghardt, 0033 % A.Paiement, L. Tao, DS-KCF: A ~real-time tracker for RGB-D data, Journal 0034 % of Real-Time Image Processing 0035 % 0036 % 0037 % University of Bristol 0038 % Massimo Camplani and Sion Hannuna 0039 % 0040 % massimo.camplani@bristol.ac.uk 0041 % hannuna@compsci.bristol.ac.uk 0042 0043 vert_deltaVect=[]; 0044 horiz_deltaVect=[]; 0045 maxPositionImagePlane=[]; 0046 %imagePlaneYVect=[]; 0047 responseVect=[]; 0048 depthVect=[]; 0049 smoothFactorD=[]; 0050 0051 nRows=size(depth16Bit,1); 0052 nCols=size(depth16Bit,2); 0053 0054 %analyze the firs #poolsize candidates 0055 for i=1:poolSize 0056 0057 [responseVect(i),tmpIndex]=max(response(:)); 0058 0059 [vert_deltaVect(i), horiz_deltaVect(i)] = find(response == responseVect(i), 1); 0060 %%clean for the next response.... 0061 response(tmpIndex)=nan; 0062 0063 %maxPosition=[vert_delta, horiz_delta]; 0064 0065 if vert_deltaVect(i) > size(response,1) / 2, %wrap around to negative half-space of vertical axis 0066 vert_deltaVect(i) = vert_deltaVect(i) - size(response,1); 0067 end 0068 if horiz_deltaVect(i) > size(response,2) / 2, %same for horizontal axis 0069 horiz_deltaVect(i) = horiz_deltaVect(i) - size(response,2); 0070 end 0071 0072 maxPositionImagePlaneVector(i,:) = previousPos + cell_size * [vert_deltaVect(i) - 1, horiz_deltaVect(i) - 1]; 0073 maxPositionImagePlaneVector(i,maxPositionImagePlaneVector(i,:)<1)=1; 0074 %maxPositionImagePlaneVector(i,maxPositionImagePlaneVector(i,1)>nRows)=nRows; 0075 if(maxPositionImagePlaneVector(i,1)>nRows) 0076 maxPositionImagePlaneVector(i,1)=nRows; 0077 end 0078 %maxPositionImagePlaneVector(i,maxPositionImagePlaneVector(i,2)>nCols)=nCols; 0079 if(maxPositionImagePlaneVector(i,2)>nCols) 0080 maxPositionImagePlaneVector(i,2)=nCols; 0081 end 0082 depthVect(i)=depth16Bit(maxPositionImagePlaneVector(i,1),maxPositionImagePlaneVector(i,2)); 0083 0084 % Now you have the position take the depth vector and calculate the weight 0085 smoothFactorD(i)=weightDistanceLogisticOnDepth(meanDepthObj,double(depthVect(i)),stdDepthObj); 0086 end 0087 0088 responseVect=responseVect.*smoothFactorD; 0089 [maxResponse, maxIndex]=max(responseVect); 0090 maxPositionImagePlane=maxPositionImagePlaneVector(maxIndex,:); 0091 0092 end 0093 0094 %%FUNCTION FOR ADD THE DEPTH WEIGHT... 0095 function smoothFactor=weightDistanceLogisticOnDepth(targetDepth,candidateDepth,targetSTD) 0096 0097 %smoothFactor=1; 0098 dist=abs((targetDepth-candidateDepth))/(3*targetSTD); 0099 0100 Q=1; 0101 ni=0.5; 0102 B=3.2; 0103 M=1.94; 0104 % sigmFunction(x,A,K,Q,ni,B,M) 0105 smoothFactor=(1-sigmFunction(dist,0,1,Q,ni,B,M)); 0106 0107 end 0108 0109 %SIGMOIDAL FUNCTION 0110 function res=sigmFunction(x,A,K,Q,ni,B,M) 0111 0112 res=A+(K-A)./((1+Q*exp(-B*(x-M))).^(1/ni)); 0113 0114 end