0001 function [tarBB, occBB, tarlist, id,occmask] = targetSearchDSKCF(bb,...
0002 trackerDSKCF_struct, DSKCFparameters,im,depth,depth16Bit,...
0003 scaleDSKCF_struct,confValue)
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 tarBB = [];
0041 occBB=[];
0042 id=[];
0043
0044 bbIn=bb;
0045 bb=enlargeBB(bb ,0.05,size(im));
0046
0047
0048 occmask=trackerDSKCF_struct.currentTarget.LabelRegions==trackerDSKCF_struct.currentTarget.regionIndex;
0049 centersEstimated=trackerDSKCF_struct.currentTarget.Centers;
0050 tarBBProp=regionprops(occmask,'BoundingBox','Area');
0051
0052
0053 if(length(tarBBProp)==1)
0054 occBB=tarBBProp.BoundingBox;
0055
0056 occBB=ceil([occBB(1), occBB(2),occBB(1)+occBB(3),occBB(2)+occBB(4)]);
0057
0058 occBB([1 3])=occBB([1 3])+bb(1);
0059 occBB([2 4])=occBB([2 4])+bb(2);
0060
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
0072 occBB=[];
0073 end
0074
0075 occBB=occBB';
0076
0077
0078 [tarBBList, areaList] = regionSegmentsFast( trackerDSKCF_struct.currentTarget.LabelRegions,bb);
0079
0080
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
0091 tarBBList(:,areaSmallIndex) = [];
0092 areaList(areaSmallIndex)= [];
0093 centersEstimated(areaSmallIndex)=[];
0094
0095
0096 tarlist = struct('bb',[],'Conf_color',[],'Conf_class',[]);
0097 num_tar = size(tarBBList,2);
0098 if isempty(tarBBList),
0099
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
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
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
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
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
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
0168 dist=abs((targetDepth-candidateDepth))/(3*targetSTD);
0169
0170 Q=1;
0171 ni=0.5;
0172 B=3.2;
0173 M=1.94;
0174
0175 smoothFactor=(1-sigmFunction(dist,0,1,Q,ni,B,M));
0176
0177 end