diff --git a/modules/dnn/src/layers/detection_output_layer.cpp b/modules/dnn/src/layers/detection_output_layer.cpp index 55ef36f95c..2dd6f5fb73 100644 --- a/modules/dnn/src/layers/detection_output_layer.cpp +++ b/modules/dnn/src/layers/detection_output_layer.cpp @@ -852,16 +852,16 @@ public: for (int i = 0; i < num; ++i, locData += numPredsPerClass * numLocClasses * 4) { LabelBBox& labelBBox = locPreds[i]; + int start = shareLocation ? -1 : 0; + for (int c = 0; c < numLocClasses; ++c) { + labelBBox[start++].resize(numPredsPerClass); + } for (int p = 0; p < numPredsPerClass; ++p) { int startIdx = p * numLocClasses * 4; for (int c = 0; c < numLocClasses; ++c) { int label = shareLocation ? -1 : c; - if (labelBBox.find(label) == labelBBox.end()) - { - labelBBox[label].resize(numPredsPerClass); - } util::NormalizedBBox& bbox = labelBBox[label][p]; if (locPredTransposed) {