Fix Yolo {x,y}_scales parser 17/283917/3
authorKwanghoon Son <k.son@samsung.com>
Mon, 7 Nov 2022 07:37:21 +0000 (02:37 -0500)
committerKwanghoon Son <k.son@samsung.com>
Mon, 7 Nov 2022 08:57:05 +0000 (03:57 -0500)
[Issue type] bug fix

Previous yolo json use nested {x,y}_scales member in multiple names.
But this changed to multiple output layer with each names.

As-is
"name" : ["378", "398", ...],
"x_scales" :
[
    [1.25000, 2.00000, 4.12500],
    [1.87500, 3.87500, 3.68750],
    [3.62500, 4.87500, 11.65625]
],

To-be
[{ "name": "378",
...
"x_scales": [ 1.25000, 2.00000, 4.12500 ],},
{ "name": "398",
...
"x_scales": [1.87500, 3.87500, 3.68750],},
...
]

Change-Id: I3e8f4abd96edf101d7faabcf3b409b2b69b7019e
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
mv_machine_learning/inference/src/DecodeInfo.cpp

index f33f062..5e4a831 100644 (file)
@@ -83,27 +83,18 @@ int DecodeInfo::ParseAnchorParam(JsonObject *root)
                        return MEDIA_VISION_ERROR_INVALID_OPERATION;
                }
 
-               for (unsigned int elem2 = 0; elem2 < xElements2; ++elem2) {
-                       JsonArray *xArray = json_array_get_array_element(xScales, elem2);
-                       JsonArray *yArray = json_array_get_array_element(yScales, elem2);
-                       unsigned int xArrayElements2 = json_array_get_length(xArray);
-                       unsigned int yArrayElements2 = json_array_get_length(yArray);
-                       if (xArrayElements2 != yArrayElements2) {
-                               LOGE("Invalid x and y scales. They should be the same size");
-                               return MEDIA_VISION_ERROR_INVALID_OPERATION;
-                       }
-                       std::vector<double> xScale_;
-                       std::vector<double> yScale_;
-                       for (unsigned int arrayElem2 = 0; arrayElem2 < xArrayElements2; ++arrayElem2) {
-                               auto xScale = static_cast<double>(json_array_get_double_element(xArray, arrayElem2));
-                               auto yScale = static_cast<double>(json_array_get_double_element(yArray, arrayElem2));
-                               LOGI("xScale:%lf, yScale:%lf", xScale, yScale);
-                               xScale_.push_back(xScale);
-                               yScale_.push_back(yScale);
-                       }
-                       anchorParam.vxScales.push_back(xScale_);
-                       anchorParam.vyScales.push_back(yScale_);
+               std::vector<double> xScale_;
+               std::vector<double> yScale_;
+               for (unsigned int arrayElem2 = 0; arrayElem2 < xElements2; ++arrayElem2) {
+                       auto xScale = static_cast<double>(json_array_get_double_element(xScales, arrayElem2));
+                       auto yScale = static_cast<double>(json_array_get_double_element(yScales, arrayElem2));
+                       LOGI("xScale:%lf, yScale:%lf", xScale, yScale);
+                       xScale_.push_back(xScale);
+                       yScale_.push_back(yScale);
                }
+               anchorParam.vxScales.push_back(xScale_);
+               anchorParam.vyScales.push_back(yScale_);
+
        } else {
                LOGE("Invalid anchor mode [%d]", anchorParam.mode);
                return MEDIA_VISION_ERROR_INVALID_PARAMETER;