function evaluationData = rok_evaluation_anonymous_update (evaluationData, detections, ground, distanceThreshold)
    % evaluationData = ROK_EVALUATION_ANONYMOUS_UPDATE (evaluationData, detections, ground, distanceThreshold)
    %
    % Update the anonymous detection evaluation data.
    %
    % Input:
    %  - evaluationData = evaluation data structure, obtained by
    %     ROK_EVALUATION_ANONYMOUS_INITIALIZE
    %  - detections = array of structures describing detections. For each
    %     detection, it should contain at least fields 'x' and 'y', with
    %     detection's coordinates.
    %  - ground = array of structures describing ground truth points.
    %     Structure is same as for detections.
    %  - distanceThreshold = threshold that determines whether assignment 
    %     is valid or not (default: Inf)
    %
    % Output:
    %  - evaluationData = modified evaluation data structure
    %
    % See also: ROK_EVALUATION_ANONYMOUS_CREATE, 
    % ROK_EVALUATION_ANONYMOUS_DISPLAY
    %
    % Cpyright (C) 2012, Rok Mandeljc <rok.mandeljc@fe.uni-lj.si>
    
    %% Assign
    [ detections, ground ] = rok_evaluation_assign_detections(detections, ground, distanceThreshold);

    %% *** Evaluation ***
    % Go over detections and find false positives
    for d = 1:numel(detections),
        if isempty(detections(d).assigned),
            evaluationData.counterFp = evaluationData.counterFp + 1; % Increase false positive counter
        end
        evaluationData.counterDetections = evaluationData.counterDetections + 1;
    end

    % Go over ground truth points; find false negatives and assignments
    % (since assignments can be taken from either detections or ground
    % truth points)
    for g = 1:numel(ground),
        id = ground(g).id;

        if isempty(ground(g).assigned),
            evaluationData.counterFn(id) = evaluationData.counterFn(id) + 1; % Increase false negative counter
        else
            evaluationData.counterAssigned(id) = evaluationData.counterAssigned(id) + 1; % Increase assigned counter
            evaluationData.distances{id} = [ evaluationData.distances{id}; ground(g).distance ];
        end

        evaluationData.counterGround(id) = evaluationData.counterGround(id) + 1;
    end
end