Add coordinate to Landmark outputmetadata 54/261254/1
authorTae-Young Chung <ty83.chung@samsung.com>
Wed, 14 Jul 2021 02:52:12 +0000 (11:52 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Wed, 14 Jul 2021 02:59:33 +0000 (11:59 +0900)
Coordinate outputmetadata of Landmark indicates that
an model's landmark coordinate is based on ratio between 0 ~ 1 or
pixel. According to it, internal processes are applied to get proper
landmark results.

Change-Id: I5e24b34cf6ca2c9e9404f082382fb7fc3d662e7f
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
meta-template/pld_cpm_192x192.json
meta-template/pld_mobilenet_v1_posenet_multi_257x257.json
mv_machine_learning/mv_inference/inference/include/OutputMetadata.h
mv_machine_learning/mv_inference/inference/src/Inference.cpp
mv_machine_learning/mv_inference/inference/src/OutputMetadata.cpp

index 6a81e50..e4f573b 100644 (file)
@@ -37,6 +37,7 @@
                 "name" : "Convolutional_Pose_Machine/stage_5_out",
                 "index" : [-1, 1, 1, 1],
                 "landmark_type" : 0,
+                "landmark_coordinate" : 1,
                 "decoding_type" : 1,
                 "decoding_info" :
                 {
index 93084ce..1d69c7a 100644 (file)
@@ -37,6 +37,7 @@
                 "name" : "MobilenetV1/heatmap_2/BiasAdd",
                 "index" : [-1, 1, 1, 1],
                 "landmark_type" : 1,
+                "landmark_coordinate" : 1,
                 "decoding_type" : 2,
                 "decoding_info" :
                 {
index 45c6311..8a6973e 100644 (file)
@@ -283,6 +283,7 @@ namespace inference
                DimInfo dimInfo;
                int type; /**< 0: 2d-single, 1: 2d-multi, 2: 3-single */
                int offset;
+               int coordinate; /**< 0: ratio, 1: pixel */
                int decodingType; /**< 0: decoding  unnecessary,
                                                        1: decoding heatmap,
                                                        2: decoding heatmap with additional refine data */
@@ -295,6 +296,7 @@ namespace inference
                DimInfo GetDimInfo() { return dimInfo; }
                int GetType();
                int GetOffset();
+               int GetCoordinate();
                int GetDecodingType();
                DecodeInfo& GetDecodingInfo();
 
index 94582b3..3a2d20f 100755 (executable)
@@ -1744,9 +1744,14 @@ namespace inference
                                return ret;
                        }
 
-                       float inputW = static_cast<float>(mMetadata.GetInputMeta().layer.begin()->second.GetWidth());
-                       float inputH = static_cast<float>(mMetadata.GetInputMeta().layer.begin()->second.GetHeight());
+                       float inputW = 1.f;
+                       float inputH = 1.f;
                        float thresRadius = landmarkInfo.GetType() == 0 ? 0.0 : outputMeta.GetLandmark().GetDecodingInfo().heatMap.nmsRadius;
+                       if (landmarkInfo.GetCoordinate() == 1) {
+                               inputW = static_cast<float>(mMetadata.GetInputMeta().layer.begin()->second.GetWidth());
+                               inputH = static_cast<float>(mMetadata.GetInputMeta().layer.begin()->second.GetHeight());
+                       }
+
                        poseDecoder.decode(inputW, inputH, thresRadius);
 
                        int part = 0;
index 6c396f5..aab8b50 100755 (executable)
@@ -691,6 +691,9 @@ namespace inference
                        offset = static_cast<int>(json_object_get_int_member(pObject, "landmark_offset"));
                        LOGI("landmark offset: %d", offset);
 
+                       coordinate = static_cast<int>(json_object_get_int_member(pObject, "landmark_coordinate"));
+                       LOGI("landmark coordinate: %d", coordinate);
+
                        decodingType = static_cast<int>(json_object_get_int_member(pObject, "decoding_type"));
                        LOGI("landmark decodeing type: %d", decodingType);
                }
@@ -709,6 +712,11 @@ namespace inference
                return offset;
        }
 
+       int Landmark::GetCoordinate()
+       {
+               return coordinate;
+       }
+
        int Landmark::GetDecodingType()
        {
                return decodingType;