| 1032 | } |
| 1033 | |
| 1034 | float EvalDetection(const QString &predictedGallery, const QString &truthGallery, const QString &csv, bool normalize, int minSize, int maxSize) |
| 1035 | { |
| 1036 | qDebug("Evaluating detection of %s against %s", qPrintable(predictedGallery), qPrintable(truthGallery)); |
| 1037 | // Organized by file, QMap used to preserve order |
| 1038 | QMap<QString, Detections> allDetections = getDetections(predictedGallery, truthGallery); |
| 1039 | |
| 1040 | // Remove any bounding boxes with a side smaller than minSize |
| 1041 | if (minSize > 0) { |
| 1042 | qDebug("Removing boxes smaller than %d\n", minSize); |
| 1043 | QMap<QString, Detections> allFilteredDetections; |
| 1044 | foreach (QString key, allDetections.keys()) { |
| 1045 | Detections detections = allDetections[key]; |
| 1046 | Detections filteredDetections; |
| 1047 | for (int i = 0; i < detections.predicted.size(); i++) { |
| 1048 | QRectF box = detections.predicted[i].boundingBox; |
| 1049 | if (min(box.width(), box.height()) > sqrt(0.5 * pow(minSize, 2))) { |
| 1050 | filteredDetections.predicted.append(detections.predicted[i]); |
| 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | for (int i = 0; i < detections.truth.size(); i++) { |
| 1055 | QRectF box = detections.truth[i].boundingBox; |
| 1056 | if (min(box.width(), box.height()) > minSize) { |
| 1057 | filteredDetections.truth.append(detections.truth[i]); |
| 1058 | } |
| 1059 | } |
| 1060 | if (!filteredDetections.truth.empty()) allFilteredDetections[key] = filteredDetections; |
| 1061 | } |
| 1062 | allDetections = allFilteredDetections; |
| 1063 | } |
| 1064 | |
| 1065 | // Remove any bounding boxes with no side smaller than maxSize |
| 1066 | if (maxSize > 0) { |
| 1067 | qDebug("Removing boxes larger than %d\n", maxSize); |
| 1068 | QMap<QString, Detections> allFilteredDetections; |
| 1069 | foreach (QString key, allDetections.keys()) { |
| 1070 | Detections detections = allDetections[key]; |
| 1071 | Detections filteredDetections; |
| 1072 | for (int i = 0; i < detections.predicted.size(); i++) { |
| 1073 | QRectF box = detections.predicted[i].boundingBox; |
| 1074 | if (min(box.width(), box.height()) < sqrt(0.5 * pow(maxSize, 2))) { |
| 1075 | filteredDetections.predicted.append(detections.predicted[i]); |
| 1076 | } |
| 1077 | } |
| 1078 | |
| 1079 | for (int i = 0; i < detections.truth.size(); i++) { |
| 1080 | QRectF box = detections.truth[i].boundingBox; |
| 1081 | if (min(box.width(), box.height()) < maxSize) { |
| 1082 | filteredDetections.truth.append(detections.truth[i]); |
| 1083 | } |
| 1084 | } |
| 1085 | if (!filteredDetections.truth.empty()) allFilteredDetections[key] = filteredDetections; |
| 1086 | } |
| 1087 | allDetections = allFilteredDetections; |
| 1088 | } |
| 1089 | |
| 1090 | QList<ResolvedDetection> resolvedDetections, falseNegativeDetections; |
| 1091 | QRectF normalizations(0, 0, 0, 0); |
no test coverage detected