366be75e1da5486b5977b1227d0cbf34761ba45c
[platform/core/api/mediavision.git] / mv_machine_learning / inference / include / InputMetadata.h
1 /**
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __MEDIA_VISION_INPUTMETADATA_H__
18 #define __MEDIA_VISION_INPUTMETADATA_H__
19
20 #include <string>
21 #include <vector>
22 #include <map>
23
24 #include "MetadataType.h"
25 #include <inference_engine_type.h>
26 #include <json-glib/json-glib.h>
27
28 /**
29  * @file InputMetadata.h
30  * @brief This file contains the metadata class definition which
31  *        provides metadata of a model.
32  */
33
34 namespace mediavision
35 {
36 namespace inference
37 {
38 struct Normalization
39 {
40         bool use { false };
41         std::vector<double> mean;
42         std::vector<double> std;
43 };
44
45 struct Quantization
46 {
47         bool use { false };
48         std::vector<double> scale;
49         std::vector<double> zeropoint;
50 };
51
52 struct Options
53 {
54         Normalization normalization;
55         Quantization quantization;
56 };
57
58 class InputMetadata
59 {
60 public:
61         /**
62                  * @brief   Creates an InputMetadata class instance.
63                  *
64                  * @since_tizen 6.5
65                  */
66         InputMetadata();
67
68         /**
69                  * @brief   Destroys an InputMetadata class instance including
70                  *          its all resources.
71                  *
72                  * @since_tizen 6.5
73                  */
74         ~InputMetadata() = default;
75
76         /**
77                  * @brief Parses an InputMetadata
78                  *
79                  * @since_tizen 6.5
80                  */
81         int Parse(JsonObject *root, std::string key_name);
82         bool IsParsed(void)
83         {
84                 return parsed;
85         }
86         std::map<std::string, LayerInfo> &GetLayer()
87         {
88                 return layer;
89         }
90         std::map<std::string, Options> &GetOption()
91         {
92                 return option;
93         }
94
95 private:
96         bool parsed;
97         std::map<std::string, inference_tensor_shape_type_e> mSupportedShapeType;
98         std::map<std::string, mv_inference_data_type_e> mSupportedDataType;
99         std::map<std::string, mv_colorspace_e> mSupportedColorSpace;
100         std::map<std::string, LayerInfo> layer;
101         std::map<std::string, Options> option;
102
103         int GetTensorInfo(JsonObject *root, std::string key_name);
104         int GetPreProcess(JsonObject *root);
105 };
106
107 } /* Inference */
108 } /* MediaVision */
109
110 #endif /* __MEDIA_VISION_INPUTMETADATA_H__ */