in evaluation/UAV-benchmark-MOTD_v1.0/utils/costBlockMex.cpp [84:140]
void compute(double* tr1, double* tr2, const int* dim1, const int* dim2, double threshold, bool world, double& cost, double& fp, double& fn)
{
int numPoints1 = dim1[0];
int numPoints2 = dim2[0];
int numCols1 = dim1[1];
int numCols2 = dim2[1];
int tr1start, tr1end, tr2start, tr2end;
tr1start = tr1[index(1,1, numPoints1)];
tr1end = tr1[index(numPoints1,1, numPoints1)];
tr2start = tr2[index(1,1, numPoints2)];
tr2end = tr2[index(numPoints2,1, numPoints2)];
bool overlapTest = ((tr1start >= tr2start && tr1start <= tr2end) ||
(tr1end >= tr2start && tr1end <= tr2end) ||
(tr2start >= tr1start && tr2start <= tr1end) ||
(tr2end >= tr1start && tr2end <= tr1end));
if (!overlapTest)
{
fp = numPoints2;
fn = numPoints1;
cost = numPoints1 + numPoints2;
return;
}
int* positionGT = new int[numPoints1];
int* positionPred = new int[numPoints2];
for (int i = 0; i < numPoints1; i++) positionGT[i] = -1;
for (int i = 0; i < numPoints2; i++) positionPred[i] = -1;
double* distanceGT = new double[numPoints1];
double* distancePred = new double[numPoints2];
double* frames1 = &tr1[index(1, 1, numPoints1)];
double* frames2 = &tr2[index(1, 1, numPoints2)];
correspondingFrames(frames1, numPoints1, frames2, numPoints2, positionGT);
correspondingFrames(frames2, numPoints2, frames1, numPoints1, positionPred);
computeDistances(tr1, tr2, numPoints1, numPoints2, positionGT, world, distanceGT);
computeDistances(tr2, tr1, numPoints2, numPoints1, positionPred, world, distancePred);
fp = 0; fn = 0;
if (world) {
for (int i = 0; i < numPoints1; i++) if (distanceGT[i] > threshold) fn++;
for (int i = 0; i < numPoints2; i++) if (distancePred[i] > threshold) fp++;
}
else {
for (int i = 0; i < numPoints1; i++) if (distanceGT[i] < threshold) fn++;
for (int i = 0; i < numPoints2; i++) if (distancePred[i] < threshold) fp++;
}
cost = fp + fn;
delete[] positionGT;
delete[] positionPred;
delete[] distanceGT;
delete[] distancePred;
}