Skip to content
This repository has been archived by the owner on Feb 25, 2019. It is now read-only.

Commit

Permalink
Added Verbose Output
Browse files Browse the repository at this point in the history
  • Loading branch information
PhoenixIllusion committed May 6, 2011
1 parent caeb93e commit 05fe9e5
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 13 deletions.
12 changes: 9 additions & 3 deletions tld/tldDetection.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@

fern(4,img,tld.control.maxbbox,tld.var,tld.tmp.conf,tld.tmp.patt); % evaluates Ensemble Classifier: saves sum of posteriors to 'tld.tmp.conf', saves measured codes to 'tld.tmp.patt', does not considers patches with variance < tmd.var
idx_dt = find(tld.tmp.conf > tld.model.num_trees*tld.model.thr_fern); % get indexes of bounding boxes that passed throu the Ensemble Classifier

printf("Detector [Frame %d]: %d Bounding Boxes Found\n",I,length(idx_dt));
if length(idx_dt) > 100 % speedup: if there are more than 100 detections, pict 100 of the most confident only
[dummy8,sIdx] = sort(tld.tmp.conf(idx_dt),'descend');
idx_dt = idx_dt(sIdx(1:100));
end

num_dt = length(idx_dt); % get the number detected bounding boxes so-far
if num_dt == 0, tld.dt{I} = dt; return; end % if nothing detected, return
if num_dt == 0
tld.dt{I} = dt;
printf("Detector [Frame %d]: No Bounding Boxes\n",I);
return;
end % if nothing detected, return

% initialize detection structure
dt.bb = tld.grid(1:4,idx_dt); % bounding boxes
Expand All @@ -55,7 +59,8 @@
dt.conf2(i) = conf2;
dt.isin(:,i) = isin;
dt.patch(:,i) = ex;

printf("Detector [Frame %d]: Testing Feature %d/%d - %f Conf1 cmp %f\n",
I,i,num_dt,conf1,tld.model.thr_nn);
end

idx = dt.conf1 > tld.model.thr_nn; % get all indexes that made it through the nearest neighbour
Expand All @@ -66,3 +71,4 @@
tld.dt{I} = dt; % save the whole detection structure



9 changes: 8 additions & 1 deletion tld/tldInit.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,16 @@
% disp(['# P patterns: ' num2str(size(pX,2))]);
% disp(['# P patches : ' num2str(size(pEx,2))]);

printf("Original Bounding Box: (%f,%f) (%f,%f)\n",
tld.source.bb(1),tld.source.bb(2),tld.source.bb(3),tld.source.bb(4));
% Correct initial bbox
tld.bb(:,1) = bbP(1:4,:);
printf("New Bounding Box: (%f,%f) (%f,%f)\n",
bbP(1),bbP(2),bbP(3),bbP(4));

% Variance threshold
tld.var = var(pEx(:,1))/2;
% disp(['Variance : ' num2str(tld.var)]);
disp(['Variance : ' num2str(tld.var)]);

% Generate Negative Examples
[nX,nEx] = tldGenerateNegativeData(tld,overlap,tld.img{1});
Expand Down Expand Up @@ -133,8 +137,11 @@
% Fern
conf_fern = fern(3,nX2);
tld.model.thr_fern = max(max(conf_fern)/tld.model.num_trees,tld.model.thr_fern);
printf("Fern Threshold: %f\n",tld.model.thr_fern);

% Nearest neighbor
conf_nn = tldNN(nEx2,tld);
tld.model.thr_nn = max(tld.model.thr_nn,max(conf_nn));
tld.model.thr_nn_valid = max(tld.model.thr_nn_valid,tld.model.thr_nn);

printf("Nearest Neighbor Threshold: %f\n",tld.model.thr_nn);
12 changes: 7 additions & 5 deletions tld/tldProcessFrame.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@
tld.conf(I) = tConf;
tld.size(I) = 1;
tld.valid(I) = tValid;

printf("Status [%d]: Tracking is occuring\n",I);
if DT % if detections are also defined

printf("Status [%d]: Detection is occuring\n",I);
[cBB,cConf,cSize] = bb_cluster_confidence(dBB,dConf); % cluster detections
id = bb_overlap(tld.bb(:,I),cBB) < 0.5 & cConf > tld.conf(I); % get indexes of all clusters that are far from tracker and are more confident then the tracker

if sum(id) == 1 % if there is ONE such a cluster, re-initialize the tracker

printf("Status [%d]: Re-Init BB\n",I);
tld.bb(:,I) = cBB(:,id);
tld.conf(I) = cConf(:,id);
tld.size(I) = cSize(:,id);
tld.valid(I) = 0;

else % othervide adjust the tracker's trajectory

printf("Status [%d]: Average BB\n",I);
idTr = bb_overlap(tBB,tld.dt{I}.bb) > 0.7; % get indexes of close detections
tld.bb(:,I) = mean([repmat(tBB,1,10) tld.dt{I}.bb(:,idTr)],2); % weighted average trackers trajectory with the close detections

Expand All @@ -63,10 +63,11 @@

else % if tracker is not defined
if DT % and detector is defined

printf("Status [%d]: Detection is occuring\n",I);
[cBB,cConf,cSize] = bb_cluster_confidence(dBB,dConf); % cluster detections

if length(cConf) == 1 % and if there is just a single cluster, re-initalize the tracker
printf("Status [%d]: Re-Init BB\n",I);
tld.bb(:,I) = cBB;
tld.conf(I) = cConf;
tld.size(I) = cSize;
Expand All @@ -83,6 +84,7 @@

% display drawing: get center of bounding box and save it to a drawn line
if ~isnan(tld.bb(1,I))
printf("Status [%d]:Learning is Occuring\n",I);
tld.draw(:,end+1) = bb_center(tld.bb(:,I));
if tld.plot.draw == 0, tld.draw(:,end) = nan; end
else
Expand Down
2 changes: 1 addition & 1 deletion tld/tldTrack.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
Valid = tld.valid(I);
if ~bb_isin(BB,tld.imgsize)
Valid = 0;
end
end
25 changes: 22 additions & 3 deletions tld/tldTracking.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
Conf = []; % confidence of prediction
Valid = 0; % is the predicted bounding box valid? if yes, learning will take place ...

if isempty(BB1) || ~bb_isdef(BB1), return; end % exit function if BB1 is not defined
if isempty(BB1) || ~bb_isdef(BB1)
printf("Detector [%d]: FAIL - No initial Bounding Box\n",I);
return;
end % exit function if BB1 is not defined

% estimate BB2
xFI = bb_points(BB1,10,10,5); % generate 10x10 grid of points within BB1 with margin 5 px
Expand All @@ -36,8 +39,24 @@
tld.xFJ = xFJ(:,idxF); % save selected points (only for display purposes)

% detect failures
if ~bb_isdef(BB2) || bb_isout(BB2,tld.imgsize), BB2 = []; return; end % bounding box out of image
if tld.control.maxbbox > 0 && medFB > 10, BB2 = []; return; end % too unstable predictions
if ~bb_isdef(BB2)
printf("Detector [%d]: FAIL - No Prediction Bounding Box\n",I);
BB2 = [];
return;
end % bounding box out of image

if bb_isout(BB2,tld.imgsize)
printf("Detector [%d]: FAIL - Bounding Box out of bounds\n",I);
BB2 = [];
return;
end % bounding box out of image


if tld.control.maxbbox > 0 && medFB > 10
printf("Detector [%d]: FAIL - Forward Backward Error %f>10\n",I,medFB);
BB2 = [];
return;
end % too unstable predictions

% estimate confidence and validity
patchJ = tldGetPattern(tld.img{J},BB2,tld.model.patchsize); % sample patch in current image
Expand Down

0 comments on commit 05fe9e5

Please sign in to comment.