Commit b085d2aafa9ff2582cae841d094849a2728dee80
1 parent
c48c08d1
score interpolation bug fix
Showing
1 changed file
with
10 additions
and
7 deletions
openbr/core/eval.cpp
| @@ -75,18 +75,22 @@ static OperatingPoint getOperatingPoint(const QList<OperatingPoint> &operatingPo | @@ -75,18 +75,22 @@ static OperatingPoint getOperatingPoint(const QList<OperatingPoint> &operatingPo | ||
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | - const float FAR1 = (index == 0 ? 0 : operatingPoints[index-1].FAR); | ||
| 79 | - const float TAR1 = (index == 0 ? 0 : operatingPoints[index-1].TAR); | ||
| 80 | - const float score1 = (index == 0 ? operatingPoints[index].score : operatingPoints[index-1].score); | 78 | + const int index2 = (key == "Score" ? std::min(index+1, operatingPoints.size()-1) : index-1); |
| 79 | + const float FAR1 = (index == 0 ? 0 : operatingPoints[index2].FAR); | ||
| 80 | + const float TAR1 = (index == 0 ? 0 : operatingPoints[index2].TAR); | ||
| 81 | + const float score1 = (index == 0 ? operatingPoints[index].score : operatingPoints[index2].score); | ||
| 81 | const float FAR2 = operatingPoints[index].FAR; | 82 | const float FAR2 = operatingPoints[index].FAR; |
| 82 | const float TAR2 = operatingPoints[index].TAR; | 83 | const float TAR2 = operatingPoints[index].TAR; |
| 83 | const float score2 = operatingPoints[index].score; | 84 | const float score2 = operatingPoints[index].score; |
| 84 | 85 | ||
| 85 | - const float mFAR = (FAR2 - FAR1) / (score2 - score1); | 86 | + const float denFAR = (FAR1 == FAR2 ? std::numeric_limits<float>::max() : (FAR2 - FAR1)); |
| 87 | + const float denScore = (score1 == score2 ? std::numeric_limits<float>::max() : (score2 - score1)); | ||
| 88 | + | ||
| 89 | + const float mFAR = (FAR2 - FAR1) / denScore; | ||
| 86 | const float bFAR = FAR1 - mFAR*score1; | 90 | const float bFAR = FAR1 - mFAR*score1; |
| 87 | - const float mTAR = (TAR2 - TAR1) / (key == "Score" ? (score2 - score1) : (FAR2 - FAR1)); | 91 | + const float mTAR = (TAR2 - TAR1) / (key == "Score" ? denScore : denFAR); |
| 88 | const float bTAR = TAR1 - mTAR*(key == "Score" ? score1 : FAR1); | 92 | const float bTAR = TAR1 - mTAR*(key == "Score" ? score1 : FAR1); |
| 89 | - const float mScore = (score2 - score1) / (FAR2 - FAR1); | 93 | + const float mScore = (score2 - score1) / denFAR; |
| 90 | const float bScore = score1 - mScore*FAR1; | 94 | const float bScore = score1 - mScore*FAR1; |
| 91 | 95 | ||
| 92 | if (key == "Score") | 96 | if (key == "Score") |
| @@ -352,7 +356,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const File &csv, const QStrin | @@ -352,7 +356,6 @@ float Evaluate(const Mat &simmat, const Mat &mask, const File &csv, const QStrin | ||
| 352 | float FRRstep = expFRR / (float)(Max_Points - 1); | 356 | float FRRstep = expFRR / (float)(Max_Points - 1); |
| 353 | float FPIRstep = expFPIR / (float)(Max_Points - 1); | 357 | float FPIRstep = expFPIR / (float)(Max_Points - 1); |
| 354 | 358 | ||
| 355 | - getOperatingPoint(operatingPoints, "Score", 0.5); | ||
| 356 | for (int i=0; i<Max_Points; i++) { | 359 | for (int i=0; i<Max_Points; i++) { |
| 357 | float FAR = pow(10, -expFAR + i*FARstep); | 360 | float FAR = pow(10, -expFAR + i*FARstep); |
| 358 | float FRR = pow(10, -expFRR + i*FRRstep); | 361 | float FRR = pow(10, -expFRR + i*FRRstep); |