summaryrefslogtreecommitdiff
path: root/mv_machine_learning/inference/include/MetadataType.h
blob: f5483b499437c6ef596e598e55e37e8f2e45db7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __MEDIA_VISION_OUTPUTMETADATA_TYPES_H__
#define __MEDIA_VISION_OUTPUTMETADATA_TYPES_H__

#include <inference_engine_type.h>
#include <mv_common.h>
#include <mv_inference_type.h>

/**
 * @file OutputMetadataTypes.h
 * @brief This file contains supported output metadata types.
 */

namespace mediavision
{
namespace inference
{
// Postprocess type
typedef enum {
	POSTPROCESS_DECODING_TYPE_NONE,
	POSTPROCESS_DECODING_TYPE_SCORE = 1 << 0,
	POSTPROCESS_DECODING_TYPE_BOX = 1 << 1,
	POSTPROCESS_DECODING_TYPE_LABEL = 1 << 2,
	POSTPROCESS_DECODING_TYPE_NUMBER = 1 << 3,
	POSTPROCESS_DECODING_TYPE_LANDMARK = 1 << 4,
	POSTPROCESS_DECODING_TYPE_DISPLACEMENT = 1 << 5,
	POSTPROCESS_DECODING_TYPE_OFFSETVEC = 1 << 6
} postprocess_decoding_type_e;

// 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;

typedef enum {
	INFERENCE_BOX_COORDINATE_TYPE_RATIO,
	INFERENCE_BOX_COORDINATE_TYPE_PIXEL
} inference_box_coordinate_type_e;

typedef enum {
	INFERENCE_BOX_DECODING_TYPE_BYPASS,
	INFERENCE_BOX_DECODING_TYPE_SSD_ANCHOR,
	INFERENCE_BOX_DECODING_TYPE_YOLO_ANCHOR,
	INFERENCE_BOX_DECODING_TYPE_SINGLE_3D
} inference_box_decoding_type_e;

typedef enum { INFERENCE_BOX_NMS_TYPE_NONE = -1, INFERENCE_BOX_NMS_TYPE_STANDARD } inference_box_nms_type_e;

// landmark
typedef enum {
	INFERENCE_LANDMARK_TYPE_2D_SINGLE,
	INFERENCE_LANDMARK_TYPE_2D_MULTI,
	INFERENCE_LANDMARK_TYPE_3D_SINGLE
} inference_landmark_type_e;

typedef enum {
	INFERENCE_LANDMARK_COORDINATE_TYPE_RATIO,
	INFERENCE_LANDMARK_COORDINATE_TYPE_PIXEL
} inference_landmark_coorindate_type_e;

typedef enum {
	INFERENCE_LANDMARK_DECODING_TYPE_BYPASS,
	INFERENCE_LANDMARK_DECODING_TYPE_BYPASS_MULTICHANNEL,
	INFERENCE_LANDMARK_DECODING_TYPE_HEATMAP,
	INFERENCE_LANDMARK_DECODING_TYPE_HEATMAP_REFINE
} inference_landmark_decoding_type_e;

typedef enum {
	INFERENCE_DISPLACEMENT_TYPE_FORWARD,
	INFERENCE_DISPLACEMENT_TYPE_BACKWARD
} inference_displacement_type_e;

struct LayerInfo {
	std::string name;
	std::vector<int> dims;
	mv_colorspace_e colorSpace {};
	mv_inference_data_type_e dataType {};
	inference_tensor_shape_type_e shapeType {}; // TODO: define mv_inference_shape_type_e
	// A output tensor can have one more decoding types.
	unsigned int decodingType {};

	int getWidth() const
	{
		if (shapeType == INFERENCE_TENSOR_SHAPE_NCHW)
			return dims[3];

		return dims[2];
	}

	int getHeight() const
	{
		if (shapeType == INFERENCE_TENSOR_SHAPE_NCHW)
			return dims[2];

		return dims[1];
	}

	int getChannel() const
	{
		if (shapeType == INFERENCE_TENSOR_SHAPE_NCHW)
			return dims[1];

		return dims[3];
	}
};

}
}

#endif /* __MEDIA_VISION_OUTPUTMETADATA_TYPES_H__ */