Skip to content

Instantly share code, notes, and snippets.

@vbalnt
Created January 29, 2014 15:58
Show Gist options
  • Save vbalnt/8691010 to your computer and use it in GitHub Desktop.
Save vbalnt/8691010 to your computer and use it in GitHub Desktop.
Prunes boxes function matlab
function [resbbox,resconf]=prunebboxes(bbox,conf,ovthresh)
% Function that prunes multiples detection boxes.
% Taken from http://www.di.ens.fr/willow/events/cvml2012/materials/practical-detection/
[vs,is]=sort(-conf);
bbox=bbox(is,:);
conf=conf(is);
resbbox=[];
resconf=[];
rescount=0;
freeflags=ones(size(conf));
while sum(freeflags)>0
indfree=find(freeflags);
[vm,im]=max(conf(indfree));
indmax=indfree(im);
ov=bboxoverlapval(bbox(indmax,:),bbox(indfree,:));
indsel=indfree(find(ov>=ovthresh));
resbbox(rescount+1,:)=mean(bbox(indsel,:),1);
resconf(rescount+1,:)=conf(indmax);
rescount=rescount+1;
freeflags(indsel)=0;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment