Change InputMetadata class to struct
[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 struct InputMetadata
59 {
60         /**
61          * @brief   Creates an InputMetadata class instance.
62          *
63          * @since_tizen 6.5
64          */
65         InputMetadata();
66
67         /**
68          * @brief   Destroys an InputMetadata class instance including
69          *          its all resources.
70          *
71          * @since_tizen 6.5
72          */
73         ~InputMetadata() = default;
74
75         /**
76          * @brief Parses an InputMetadata
77          *
78          * @since_tizen 6.5
79          */
80         int Parse(JsonObject *root, std::string key_name);
81         bool IsParsed(void)
82         {
83                 return parsed;
84         }
85         std::map<std::string, LayerInfo> &GetLayer()
86         {
87                 return layer;
88         }
89         std::map<std::string, Options> &GetOption()
90         {
91                 return option;
92         }
93
94         bool parsed;
95         std::map<std::string, inference_tensor_shape_type_e> mSupportedShapeType;
96         std::map<std::string, mv_inference_data_type_e> mSupportedDataType;
97         std::map<std::string, mv_colorspace_e> mSupportedColorSpace;
98         std::map<std::string, LayerInfo> layer;
99         std::map<std::string, Options> option;
100
101         int GetTensorInfo(JsonObject *root, std::string key_name);
102         int GetPreProcess(JsonObject *root);
103 };
104
105 } /* Inference */
106 } /* MediaVision */
107
108 #endif /* __MEDIA_VISION_INPUTMETADATA_H__ */