Merge pull request #19529 from WeiChungChang:3.4
authorWeiChungChang <r97922153@gmail.com>
Tue, 23 Feb 2021 21:09:55 +0000 (16:09 -0500)
committerGitHub <noreply@github.com>
Tue, 23 Feb 2021 21:09:55 +0000 (21:09 +0000)
* improve map allocation check

* fix accoring to CR

modules/dnn/src/layers/detection_output_layer.cpp

index 55ef36f95cba6aced082952698851b094c25ec8e..2dd6f5fb73bc32db0ba67d87a13b5c4fb60d30a5 100644 (file)
@@ -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)
                     {