function [fp,tp] = getROCCurve(rows1,cols1,rows2,cols2,nearest_idx,nearest_dist,H)
%GETROCCURVE
% [rows1,cols1] = locations of first set of descriptors
% [rows2,cols2] = locations of second set of descriptors
% [nearest_idx,nearest_dist] = output of matching function
%
% returns pairs of false positive rate and true positive rate, call
% plot(fp,tp) to plot ROC curve
    numPoints = length(rows1);
    fprintf('Total number of points = %d (Should be large enough (>300) to get a robust estimate)\n',numPoints);
    transformedCoords = H * [cols1'-1;rows1'-1;ones(1,numPoints)]; % H is for 0-based coordinate system
    transformedCoords = transformedCoords./repmat(transformedCoords(3,:),3,1);
    diff = transformedCoords(1:2,:) - [cols2(nearest_idx)'-1;rows2(nearest_idx)'-1];
    dist = sqrt(sum(diff.^2))';
    % sort the ssd distance
    [sorted_ssd,sorted_inds] = sort(nearest_dist);
    dist = dist(sorted_inds);
    totalPositive = length(find(dist<4));
    totalNegative = length(dist) - totalPositive;
    fprintf('Total number of positives = %d (Should be large (>25) for any non-crappy descriptor)\n',totalPositive);
    positives = (dist<4);
    negatives = 1 - positives;
    positives = cumsum(positives);
    negatives = cumsum(negatives);
    fp = negatives/totalNegative;
    tp = positives/totalPositive;
end