function evaluationData = rok_evaluation_full_update (evaluationData, detections, ground, distanceThreshold, identity)
    % evaluationData = ROK_EVALUATIONFULL_UPDATE (evaluationData, detections, ground, distanceThreshold, identity)
    %
    % Update the full detection/identification evaluation data.
    %
    % Input:
    %  - detections = array of structures describing detections. For each
    %     detection, it should contain at least fields 'x' and 'y', with
    %     detection's coordinates. Optionally, 'id' field can be contained
    %     as well
    %  - 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)
    %  - identity = whether to account for identities of detections and
    %     ground truth points (i.e. allow only assignments with same
    %     identities). This requires both detections and ground truth
    %     structures to contain field 'id'.
    %
    % Output:
    %  - evaluationData = modified evaluation data structure
    %
    % See also: ROK_EVALUATION_FULL_CREATE, ROK_EVALUATION_FULL_DISPLAY,
    % ROK_EVALUATION_FULL_LATEX_TABLE

    %% Assign
    [ detections, ground ] = rok_evaluation_assign_detections(detections, ground, distanceThreshold, identity);

    %% *** Evaluation ***
    % Go over detections and find false positives
    for d = 1:numel(detections),
        id = detections(d).id;

        if isempty(detections(d).assigned),
            evaluationData.counterFp(id) = evaluationData.counterFp(id) + 1; % Increase false positive counter
        end
        evaluationData.counterDetections(id) = evaluationData.counterDetections(id) + 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
            detId = detections( ground(g).assigned ).id;
                
            evaluationData.counterAssigned(id, detId) = evaluationData.counterAssigned(id, detId) + 1; % Increase assigned counter
            evaluationData.distances{id, detId} = [ evaluationData.distances{id, detId}; ground(g).distance ];
        end

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