Change BoxInfo's box_type in outputmetadata to string 14/262814/4
authorTae-Young Chung <ty83.chung@samsung.com>
Fri, 20 Aug 2021 05:43:35 +0000 (14:43 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Fri, 20 Aug 2021 07:13:12 +0000 (07:13 +0000)
box_type in BoxInfo outputmetadata was integer value.
It is changed to string, ORIGIN_LEFTTOP and ORIGIN_CENTER.
A user can use the string while understading purpose of box_type metadata.
The string values are parsed and converted to enumeration
INFERENCE_BOX_TYPE_ORIGIN_LEFTTOP or INFERENCE_BOX_TYPE_ORIGIN_CENTER.

Change-Id: Icab71b26ca3c96652c23a584eb8a3ec5c6d7d44b
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
meta-template/fd_blazeface_front_128x128.json
meta-template/fd_mobilenet_v1_ssd_postop_300x300.json
meta-template/od_mobilenet_v1_ssd_postop_300x300.json
meta-template/od_mobilenet_v2_ssd_320x320.json
mv_machine_learning/mv_inference/inference/include/OutputMetadata.h
mv_machine_learning/mv_inference/inference/include/OutputMetadataTypes.h
mv_machine_learning/mv_inference/inference/src/ObjectDecoder.cpp
mv_machine_learning/mv_inference/inference/src/OutputMetadata.cpp
packaging/capi-media-vision.spec

index 7a10054..2cf11b7 100644 (file)
@@ -36,7 +36,7 @@
             {
                 "name" : "regressors",
                 "index" : [-1, -1, 1],
-                "box_type" : 1,
+                "box_type" : "ORIGIN_CENTER",
                 "box_order" : [1, 0, 3, 2],
                 "box_coordinate" : 1,
                 "decoding_type" : 1,
index 74353c1..734f5af 100644 (file)
@@ -36,7 +36,7 @@
             {
                "name" : "TFLite_Detection_PostProcess",
                "index" : [-1, -1, 1],
-               "box_type" : 0,
+               "box_type" : "ORIGIN_LEFTTOP",
                "box_order" : [1, 0, 3, 2],
                "box_coordinate" : 0,
                "decoding_type": 0
index 74353c1..734f5af 100644 (file)
@@ -36,7 +36,7 @@
             {
                "name" : "TFLite_Detection_PostProcess",
                "index" : [-1, -1, 1],
-               "box_type" : 0,
+               "box_type" : "ORIGIN_LEFTTOP",
                "box_order" : [1, 0, 3, 2],
                "box_coordinate" : 0,
                "decoding_type": 0
index 739fae5..0429a46 100644 (file)
@@ -36,7 +36,7 @@
             {
                 "name" : "raw_outputs/box_encodings",
                 "index" : [-1, -1, 1],
-                "box_type" : 1,
+                "box_type" : "ORIGIN_CENTER",
                 "box_order" : [1, 0, 3, 2],
                 "box_coordinate" : 0,
                 "decoding_type" : 1,
index 2df1310..1931425 100644 (file)
@@ -215,19 +215,21 @@ namespace inference
        private:
                std::string name;
                DimInfo dimInfo;
-               int type; // 0:LTRB, 1: CxCyWH
+               inference_box_type_e type; // 0:L-T-R-B, 1: Cx-Cy-W-H
                std::vector<int> order; // Order based on box type
                int coordinate; // 0: ratio, 1: pixel
                int decodingType; // 0: post-op, 1: achorbox(ssd), 2:yolo(?)
                DecodeInfo decodingInfo;
 
+               std::map<std::string, inference_box_type_e> supportedBoxTypes;
+
        public:
-               BoxInfo() = default;
+               BoxInfo();
                ~BoxInfo() = default;
 
                std::string GetName() { return name; }
                DimInfo GetDimInfo() { return dimInfo; }
-               int GetType() { return type; }
+               inference_box_type_e GetType() { return type; }
                int GetDecodingType() { return decodingType; }
                std::vector<int> GetOrder() { return order; }
                int GetCoordinate() { return coordinate; }
index 085a77e..f82dbbc 100644 (file)
@@ -26,10 +26,17 @@ namespace mediavision
 {
 namespace inference
 {
+       // score
     typedef enum {
                INFERENCE_SCORE_TYPE_NORMAL,
                INFERENCE_SCORE_TYPE_SIGMOID
        } inference_score_type_e;
+
+       // box
+       typedef enum {
+               INFERENCE_BOX_TYPE_ORIGIN_LEFTTOP,
+               INFERENCE_BOX_TYPE_ORIGIN_CENTER
+       } inference_box_type_e;
 }
 }
 
index 971529f..fff8325 100755 (executable)
@@ -82,8 +82,8 @@ namespace inference
                float cHeight = mTensorBuffer.getValue<float>(mBoxInfo.GetName(),
                                                                        idx * mBoxOffset + mBoxInfo.GetOrder()[3]);
 
-               // when GetType() == 0 (l,t,r,b), then convert it to (cx,cy,w,h)
-               if (mBoxInfo.GetType() == 0) {
+               // convert type to ORIGIN_CENTER if ORIGIN_LEFTTOP
+               if (mBoxInfo.GetType() == INFERENCE_BOX_TYPE_ORIGIN_LEFTTOP) {
                        float tmpCx = cx;
                        float tmpCy = cy;
                        cx = (cx + cWidth) * 0.5f; // (left + right)/2
index 1f57650..77f841d 100755 (executable)
@@ -119,6 +119,20 @@ namespace inference
                return MEDIA_VISION_ERROR_NONE;
        }
 
+       BoxInfo::BoxInfo() :
+                       name(),
+                       dimInfo(),
+                       type(INFERENCE_BOX_TYPE_ORIGIN_LEFTTOP),
+                       order(),
+                       coordinate(0),
+                       decodingType(0),
+                       decodingInfo()
+
+       {
+               supportedBoxTypes.insert({"ORIGIN_LEFTTOP", INFERENCE_BOX_TYPE_ORIGIN_LEFTTOP});
+               supportedBoxTypes.insert({"ORIGIN_CENTER", INFERENCE_BOX_TYPE_ORIGIN_CENTER});
+       }
+
        int BoxInfo::ParseBox(JsonObject *root)
        {
                LOGI("ENTER");
@@ -141,8 +155,11 @@ namespace inference
                                        dimInfo.SetValidIndex(elem2);
                        }
 
-                       type = static_cast<int>(json_object_get_int_member(pObject, "box_type"));
-                       LOGI("box type: %d", type);
+                       try {
+                               type = OutputMetadata::GetSupportedType(pObject, "box_type", supportedBoxTypes);
+                       } catch (const std::exception& e) {
+                               LOGE("Invalid %s", e.what());
+                       }
 
                        array = json_object_get_array_member(pObject, "box_order");
                        elements2 = json_array_get_length(array);
index 60d724c..d39a64d 100644 (file)
@@ -1,7 +1,7 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
-Version:     0.8.8
-Release:     1
+Version:     0.8.9
+Release:     0
 Group:       Multimedia/Framework
 License:     Apache-2.0 and BSD-3-Clause
 Source0:     %{name}-%{version}.tar.gz