Skip to content

Commit

Permalink
remove duplicate proposals on the fly when loading
Browse files Browse the repository at this point in the history
  • Loading branch information
hosang committed Jul 27, 2015
1 parent 1421f4f commit bf59adc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions shared/deduplicate_proposals.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function [proposals, scores] = deduplicate_proposals(proposals, scores)
% Be sure to call this AFTER the proposals are in the right order.
% We cannot just order by score, because not all proposal methods are
% sorted by the same rule.

if isempty(proposals)
return;
end

rproposals = proposals;
rproposals(:,1:2) = round(rproposals(:,1:2));
rproposals(:,3:4) = ceil(rproposals(:,3:4));
[~, idxs] = unique(rproposals, 'rows', 'stable');
proposals = proposals(idxs,:);
if ~isempty(scores)
scores = scores(idxs);
end

end
4 changes: 4 additions & 0 deletions shared/get_candidates.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
scores = scores{idx};
end


if allow_filtering
if strcmp(method_config.order, 'none')
% nothing to do
Expand Down Expand Up @@ -57,6 +58,9 @@
candidates = candidates(argsort,:);
end

% remove duplicates on the fly
[candidates, scores] = deduplicate_proposals(candidates, scores);

num_candidates = min(num_candidates, size(candidates, 1));
candidates = candidates(1:num_candidates,:);
if numel(scores) > 0
Expand Down

0 comments on commit bf59adc

Please sign in to comment.