INITDSKCFSHAPE.m initializes the shape data structure for DS-KCF tracker presented in [1] INITDSKCFSHAPE function initializes the shape data structure of the DS-KCF tracker. In particular, some matrices are precomputed at the different scales and other flags are intialized INPUT: -slidingWinSize size of the sliding window used to accumulate silhouette masks as in [1] -current scaleFactor of the DSKCF, when zero the dskcfShapeStruct is initialized with empty vectors -pos initial target position of the tracked object OUTPUT -dskcfShapeStructOLD data structure that contains shape parameters to be updated. It contains + slidingWindowSize size of the sliding windows to accumulated segmented masks + lastSegmentedBB bounding box containing the segmented object + cumulativeMask mask obtained accumulating masks in the sliding window as in [1] +maskArray array containing the segmented masks +segmentW width of the segmented object +segmentH height of the segmented object +growingStatus flag to mark if the object is increasing its size while changing shape [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 [ dskcfShapeStruct ] = initDSKCFshape( slidingWinSize, scaleFactor,dskcfShapeStructOLD ) 0002 % INITDSKCFSHAPE.m initializes the shape data structure for DS-KCF tracker 0003 % presented in [1] 0004 % 0005 % INITDSKCFSHAPE function initializes the shape data structure of the 0006 % DS-KCF tracker. In particular, some matrices are precomputed at the 0007 % different scales and other flags are intialized 0008 % 0009 % INPUT: 0010 % -slidingWinSize size of the sliding window used to accumulate silhouette 0011 % masks as in [1] 0012 % -current scaleFactor of the DSKCF, when zero the dskcfShapeStruct is 0013 % initialized with empty vectors 0014 % -pos initial target position of the tracked object 0015 % OUTPUT 0016 % -dskcfShapeStructOLD data structure that contains shape parameters to be 0017 % updated. It contains 0018 % 0019 % + slidingWindowSize size of the sliding windows to accumulated segmented 0020 % masks 0021 % + lastSegmentedBB bounding box containing the segmented object 0022 % + cumulativeMask mask obtained accumulating masks in the sliding window 0023 % as in [1] 0024 % +maskArray array containing the segmented masks 0025 % +segmentW width of the segmented object 0026 % +segmentH height of the segmented object 0027 % +growingStatus flag to mark if the object is increasing its size while 0028 % changing shape 0029 % 0030 % [1] S. Hannuna, M. Camplani, J. Hall, M. Mirmehdi, D. Damen, T. 0031 % Burghardt, A.Paiement, L. Tao, DS-KCF: A real-time tracker for RGB-D 0032 % data, Journal of Real-Time Image Processing 0033 % 0034 % 0035 % University of Bristol 0036 % Massimo Camplani and Sion Hannuna 0037 % 0038 % massimo.camplani@bristol.ac.uk 0039 % hannuna@compsci.bristol.ac.uk 0040 0041 dskcfShapeStruct.slidingWindowSize=slidingWinSize; 0042 dskcfShapeStruct.lastSegmentedBB=[]; 0043 0044 if(scaleFactor>0) 0045 0046 dskcfShapeStruct.cumulativeBB=dskcfShapeStructOLD.cumulativeBB; 0047 dskcfShapeStruct.growingStatus=dskcfShapeStructOLD.growingStatus; 0048 0049 %zero pad previous segmentations 0050 newW=round(scaleFactor*dskcfShapeStructOLD.segmentW); 0051 newH=round(scaleFactor*dskcfShapeStructOLD.segmentH); 0052 0053 segmentHIncrement=round((newH-dskcfShapeStructOLD.segmentH)/2); 0054 segmentWIncrement=round((newW-dskcfShapeStructOLD.segmentW)/2); 0055 0056 dskcfShapeStruct.segmentH=newH; 0057 dskcfShapeStruct.segmentW=newW; 0058 0059 segmentHIncrement=segmentHIncrement*(segmentHIncrement>0); 0060 segmentWIncrement=segmentWIncrement*(segmentWIncrement>0); 0061 0062 0063 dskcfShapeStruct.cumulativeMask=padarray(dskcfShapeStructOLD.cumulativeMask,[segmentHIncrement segmentWIncrement]); 0064 %you need only from the second one... 0065 0066 for i=1:size(dskcfShapeStructOLD.maskArray,3) 0067 tmpMaskArray(:,:,i)=... 0068 padarray(dskcfShapeStructOLD.maskArray(:,:,i),[segmentHIncrement segmentWIncrement]); 0069 end 0070 dskcfShapeStruct.maskArray=tmpMaskArray; 0071 0072 else 0073 dskcfShapeStruct.cumulativeMask=[]; 0074 dskcfShapeStruct.maskArray=[]; 0075 dskcfShapeStruct.cumulativeBB=[]; 0076 dskcfShapeStruct.segmentW=0; 0077 dskcfShapeStruct.segmentH=0; 0078 dskcfShapeStruct.growingStatus=false; 0079 end 0080 0081 end 0082