function centers = bboxcenterpos(boxes)

% bboxcenterpos(boxes)
% Gets the center positions of the bounding boxes

centers=[];

if ~isempty(boxes)
  numfilters = floor(size(boxes, 2)/4);
  
  % draw the boxes with the detection window on top (reverse order)
  for i = 1:numfilters
    x1 = boxes(:,1+(i-1)*4);
    y1 = boxes(:,2+(i-1)*4);
    x2 = boxes(:,3+(i-1)*4);
    y2 = boxes(:,4+(i-1)*4);
    
%     keyboard
    % remove unused filters
    del = find(((x1 == 0) .* (x2 == 0) .* (y1 == 0) .* (y2 == 0)) == 1);
    x1(del) = [];
    x2(del) = [];
    y1(del) = [];
    y2(del) = [];
    
    if ~isempty(x1)
        centers(end+1,:) = [(x1+x2)/2; (y1+y2)/2];
    end
  end
end
