void Objectness::evaluatePerImgRecall(const vector<vector<Vec4i> > &boxesTests, CStr &saveName, const int NUM_WIN) { vecD recalls(NUM_WIN); vecD avgScore(NUM_WIN); const int TEST_NUM = _voc.testSet.size(); for (int i = 0; i < TEST_NUM; i++) { const vector<Vec4i> &boxesGT = _voc.gtTestBoxes[i]; const vector<Vec4i> &boxes = boxesTests[i]; const int gtNumCrnt = boxesGT.size(); vecI detected(gtNumCrnt); vecD score(gtNumCrnt); double sumDetected = 0, abo = 0; for (int j = 0; j < NUM_WIN; j++) { if (j >= (int)boxes.size()) { recalls[j] += sumDetected/gtNumCrnt; avgScore[j] += abo/gtNumCrnt; continue; } for (int k = 0; k < gtNumCrnt; k++) { double s = DataSetVOC::interUnio(boxes[j], boxesGT[k]); score[k] = max(score[k], s); detected[k] = score[k] >= 0.5 ? 1 : 0; } sumDetected = 0, abo = 0; for (int k = 0; k < gtNumCrnt; k++) sumDetected += detected[k], abo += score[k]; recalls[j] += sumDetected/gtNumCrnt; avgScore[j] += abo/gtNumCrnt; } } for (int i = 0; i < NUM_WIN; i++) { recalls[i] /= TEST_NUM; avgScore[i] /= TEST_NUM; } int idx[8] = {1, 10, 100, 1000, 2000, 3000, 4000, 5000}; for (int i = 0; i < 8; i++) { if (idx[i] > NUM_WIN) continue; printf("%d:%.3g,%.3g\t", idx[i], recalls[idx[i] - 1], avgScore[idx[i] - 1]); } printf("\n"); FILE* f = fopen(_S(_voc.resDir + saveName), "w"); CV_Assert(f != NULL); fprintf(f, "figure(1);\n\n"); PrintVector(f, recalls, "DR"); PrintVector(f, avgScore, "MABO"); fprintf(f, "semilogx(1:%d, DR(1:%d));\nhold on;\nsemilogx(1:%d, DR(1:%d));\naxis([1, 5000, 0, 1]);\nhold off;\n", NUM_WIN, NUM_WIN, NUM_WIN, NUM_WIN); fclose(f); }
double Illustrate::evaluatePerImgRecall(const vector<vector<Vec4i>> &boxesTests, const int NUM_WIN) { cout << __FUNCTION__ << " called:(" << __LINE__ << ")" << endl; vecD recalls(NUM_WIN), avgScore(NUM_WIN); const int TEST_NUM = _voc.testSet.size(); for (int i = 0; i < TEST_NUM; i++) { const vector<Vec4i> &boxesGT = _voc.gtTestBoxes[i]; const vector<Vec4i> &boxes = boxesTests[i]; const int gtNumCrnt = boxesGT.size(); vecI detected(gtNumCrnt); vecD score(gtNumCrnt); double sumDetected = 0, abo = 0; for (int j = 0; j < NUM_WIN; j++) { if (j < (int)boxes.size()) { for (int k = 0; k < gtNumCrnt; k++) { double s = Common::interUnio(boxes[j], boxesGT[k]); score[k] = max(score[k], s); detected[k] = score[k] >= 0.5 ? 1 : 0; } sumDetected = 0, abo = 0; for (int k = 0; k < gtNumCrnt; k++) { sumDetected += detected[k]; abo += score[k]; } } recalls[j] += sumDetected / gtNumCrnt / TEST_NUM; avgScore[j] += abo / gtNumCrnt / TEST_NUM; } } __PrintVector(recalls, _resDir + "RECALLS.csv"); __PrintVector(avgScore, _resDir + "aveScore.csv"); cout << "---RESULT----------------------------------------------------------------------" << endl; int idx[18] = { 1, 10, 100, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 15000, 20000, 30000, 40000, NUM_WIN }; for (int i = 0; i < 18; i++) { if (idx[i] > NUM_WIN) continue; printf("PROPOSAL:%5d ", idx[i]); printf("RECALLS :%6.5f ", recalls[idx[i] - 1]); printf("AVESCORE:%6.5f\n", avgScore[idx[i] - 1]); } cout << "-------------------------------------------------------------------------------" << endl; return recalls[NUM_WIN - 1]; }