targetSearchDSKCF

PURPOSE ^

TARGETSEARCHDSKCF function for segmenting the occluding object

SYNOPSIS ^

function [tarBB, occBB, tarlist, id,occmask] = targetSearchDSKCF(bb,trackerDSKCF_struct, DSKCFparameters,im,depth,depth16Bit,scaleDSKCF_struct,confValue)

DESCRIPTION ^

TARGETSEARCHDSKCF function for segmenting the occluding object

TARGETSEARCHDSKCF.m this function segments the occluding area and find
meaningful target candidates. For more information about how DSKCF handles
occlusions see [1]. Please note that  this function was partially built
extending the RGBD tracker code presented in [2] and available under under
Open Source MIT License at
 http://tracking.cs.princeton.edu/code.html


  INPUT:
  - depthIm   current depth image (16BIT)
  - trackerDSKCF_struct  DS-KCF tracker data structure (see INITDSKCFTRACKER)


  OUTPUT
  - occBB Bounding box of the occluding object in the format [topLeftX,
  topLeftY, bottomRightX, bottomRightY] read as [columnIndexTopLeft,
   rowIndexTopLeft, columnIndexBottomRight, rowIndexBottomRight]

 See also ENLARGEBB, REGIONSEGMENTSFAST, GET_SUBWINDOW, MAXRESPONSEDSKCF,
 SINGLEFRAMEDSKCF


  [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] Shuran Song and Jianxiong Xiao. Tracking Revisited using RGBD
  Camera: Baseline and Benchmark. 2013.

  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:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [tarBB, occBB, tarlist, id,occmask] = targetSearchDSKCF(bb,...
0002     trackerDSKCF_struct, DSKCFparameters,im,depth,depth16Bit,...
0003     scaleDSKCF_struct,confValue)
0004 %TARGETSEARCHDSKCF function for segmenting the occluding object
0005 %
0006 %TARGETSEARCHDSKCF.m this function segments the occluding area and find
0007 %meaningful target candidates. For more information about how DSKCF handles
0008 %occlusions see [1]. Please note that  this function was partially built
0009 %extending the RGBD tracker code presented in [2] and available under under
0010 %Open Source MIT License at
0011 % http://tracking.cs.princeton.edu/code.html
0012 %
0013 %
0014 %  INPUT:
0015 %  - depthIm   current depth image (16BIT)
0016 %  - trackerDSKCF_struct  DS-KCF tracker data structure (see INITDSKCFTRACKER)
0017 %
0018 %
0019 %  OUTPUT
0020 %  - occBB Bounding box of the occluding object in the format [topLeftX,
0021 %  topLeftY, bottomRightX, bottomRightY] read as [columnIndexTopLeft,
0022 %   rowIndexTopLeft, columnIndexBottomRight, rowIndexBottomRight]
0023 %
0024 % See also ENLARGEBB, REGIONSEGMENTSFAST, GET_SUBWINDOW, MAXRESPONSEDSKCF,
0025 % SINGLEFRAMEDSKCF
0026 %
0027 %
0028 %  [1] S. Hannuna, M. Camplani, J. Hall, M. Mirmehdi, D. Damen, T.
0029 %  Burghardt, A. Paiement, L. Tao, DS-KCF: A real-time tracker for RGB-D
0030 %  data, Journal of Real-Time Image Processing
0031 %
0032 %  [2] Shuran Song and Jianxiong Xiao. Tracking Revisited using RGBD
0033 %  Camera: Baseline and Benchmark. 2013.
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 tarBB = [];
0041 occBB=[];
0042 id=[];
0043 
0044 bbIn=bb;
0045 bb=enlargeBB(bb ,0.05,size(im));
0046 
0047 %%take Bounding box and mask from the previous segmentation!!!!!
0048 occmask=trackerDSKCF_struct.currentTarget.LabelRegions==trackerDSKCF_struct.currentTarget.regionIndex;
0049 centersEstimated=trackerDSKCF_struct.currentTarget.Centers;
0050 tarBBProp=regionprops(occmask,'BoundingBox','Area');
0051 
0052 %one single big region....just take the bounding box
0053 if(length(tarBBProp)==1)
0054     occBB=tarBBProp.BoundingBox;
0055     %use extrema points.....
0056     occBB=ceil([occBB(1), occBB(2),occBB(1)+occBB(3),occBB(2)+occBB(4)]);
0057     %and recenter to the entire image coordinate
0058     occBB([1 3])=occBB([1 3])+bb(1);
0059     occBB([2 4])=occBB([2 4])+bb(2);
0060     %else select the biggest one
0061 elseif(length(tarBBProp)>1)
0062     areas= cat(1, tarBBProp.Area);
0063     [maxV,maxIndex]=max(areas);
0064     occBB=tarBBProp(maxIndex).BoundingBox;
0065     occBB=ceil([occBB(1), occBB(2),occBB(1)+occBB(3),occBB(2)+occBB(4)]);
0066     
0067     occBB([1 3])=occBB([1 3])+bb(1);
0068     occBB([2 4])=occBB([2 4])+bb(2);
0069     
0070 else
0071     %EMPTY AREA....
0072     occBB=[];
0073 end
0074 
0075 occBB=occBB';
0076 
0077 %retrieve the list of possible candidates according to the segmentation
0078 [tarBBList, areaList] = regionSegmentsFast( trackerDSKCF_struct.currentTarget.LabelRegions,bb);
0079 
0080 %exclude the occluding index!!!!!!!!
0081 if(trackerDSKCF_struct.currentTarget.regionIndex~=6666666)
0082     tarBBList(:,trackerDSKCF_struct.currentTarget.regionIndex) = [];
0083     areaList(trackerDSKCF_struct.currentTarget.regionIndex)= [];
0084     centersEstimated(trackerDSKCF_struct.currentTarget.regionIndex) =[];
0085 end
0086 
0087 minArea=trackerDSKCF_struct.currentTarget.w*...
0088     trackerDSKCF_struct.currentTarget.h*0.05;
0089 areaSmallIndex=areaList<minArea;
0090 %exclude the small area index!!!!!!!!
0091 tarBBList(:,areaSmallIndex) = [];
0092 areaList(areaSmallIndex)= [];
0093 centersEstimated(areaSmallIndex)=[];
0094 
0095 %for each target bb caculate confidience
0096 tarlist = struct('bb',[],'Conf_color',[],'Conf_class',[]);
0097 num_tar = size(tarBBList,2);
0098 if isempty(tarBBList),
0099     %disp('total occ');
0100 else
0101     tarlist.bb=nan(4,num_tar);
0102     tarlist.Conf_class=nan(1,num_tar);
0103     tarlist.Area=nan(1,num_tar);
0104     
0105     smoothFactorD_vector=[];
0106     for j=1:size(tarBBList,2),
0107         %conf  = hogGetConf(tarBBList(:,j), featurePym, svm);
0108         tmpBB=tarBBList(:,j);
0109         tmpWidthTarget=tmpBB(3)-tmpBB(1)+1;
0110         tmpHeightTarget=tmpBB(4)-tmpBB(2)+1;
0111         tmpCenter=ceil([tmpBB(1)+tmpWidthTarget/2 tmpBB(2)+tmpHeightTarget/2]);
0112         
0113         %take image patch....
0114         patch = get_subwindow(im, tmpCenter(2:-1:1), scaleDSKCF_struct.windows_sizes(scaleDSKCF_struct.i).window_sz);
0115         patch_depth = get_subwindow(depth, tmpCenter(2:-1:1), scaleDSKCF_struct.windows_sizes(scaleDSKCF_struct.i).window_sz);
0116         
0117         [ response, maxResponse, maxPositionImagePlane] = maxResponseDSKCF...
0118             ( patch,patch_depth, DSKCFparameters.features,DSKCFparameters.kernel,...
0119             tmpCenter(2:-1:1),DSKCFparameters.cell_size, ...
0120             scaleDSKCF_struct.cos_windows(scaleDSKCF_struct.i).cos_window,...
0121             trackerDSKCF_struct.model_xf,trackerDSKCF_struct.model_alphaf,...
0122             trackerDSKCF_struct.model_xDf,trackerDSKCF_struct.model_alphaDf,...
0123             size(im,1),size(im,2));
0124         
0125         %now maxPositionImagePlane has row index and column index so.....
0126         smoothFactorD=weightDistanceLogisticOnDepth(trackerDSKCF_struct.currentTarget.meanDepthObj,...
0127             double(depth16Bit(maxPositionImagePlane(1),maxPositionImagePlane(2))),...
0128             trackerDSKCF_struct.currentTarget.stdDepthObj);
0129         smoothFactorD_vector=[smoothFactorD_vector,smoothFactorD];
0130         
0131         conf=maxResponse*smoothFactorD;
0132         
0133         reEstimatedBB(1:2)=maxPositionImagePlane(2:-1:1) - [tmpWidthTarget,tmpHeightTarget]/2;
0134         reEstimatedBB(3:4)=maxPositionImagePlane(2:-1:1) + [tmpWidthTarget,tmpHeightTarget]/2;
0135         
0136         tarlist.bb(:,j)=reEstimatedBB;
0137         tarlist.Conf_class(j)= conf;
0138         
0139     end
0140     %output the most possible target BB
0141     idx =  tarlist.Conf_class>-999;
0142     tarlist.bb=tarlist.bb(:,idx);
0143     tarlist.Conf_class=tarlist.Conf_class(idx);
0144     
0145     if sum(idx(:))>0,
0146         [conf,id]=max(tarlist.Conf_class);
0147         if(smoothFactorD_vector(id)~=0)
0148             conf=conf/smoothFactorD_vector(id);
0149         end
0150         tarlist.Conf_class=tarlist.Conf_class./smoothFactorD_vector;
0151         tarlist.Conf_class(isnan(tarlist.Conf_class))=0;
0152         %if ~isempty(id)&&conf>0.3*svm.thr, tarBB=tarlist.bb(:,id);end
0153         if ~isempty(id)&&conf>confValue, tarBB=tarlist.bb(:,id);end
0154     end
0155 end
0156 
0157 end
0158 
0159 function res=sigmFunction(x,A,K,Q,ni,B,M)
0160 
0161 res=A+(K-A)./((1+Q*exp(-B*(x-M))).^(1/ni));
0162 
0163 end
0164 
0165 function smoothFactor=weightDistanceLogisticOnDepth(targetDepth,candidateDepth,targetSTD)
0166 
0167 %smoothFactor=1;
0168 dist=abs((targetDepth-candidateDepth))/(3*targetSTD);
0169 
0170 Q=1;
0171 ni=0.5;
0172 B=3.2;
0173 M=1.94;
0174 %              sigmFunction(x,A,K,Q,ni,B,M)
0175 smoothFactor=(1-sigmFunction(dist,0,1,Q,ni,B,M));
0176 
0177 end

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