Mech-DLK SDK (C#) 3.0.0
Mech-DLK SDK (C#) Reference Documentation
 
Loading...
Searching...
No Matches
DataStructures.h
Go to the documentation of this file.
1#pragma once
2
3#include "Enums.h"
4#include <vector>
5
6using namespace System;
7using namespace System::Collections::Generic;
8
9namespace Mmind {
10namespace Dl {
11
15 public value struct MPoint
16 {
17 int x;
18 int y;
19
20 MPoint(int x, int y) : x(x), y(y) {}
21
23 {
24 return MPoint(p1.x + p2.x, p1.y + p2.y);
25 }
26 };
27
31 public value struct MPointF
32 {
33 float x;
34 float y;
35
36 MPointF(float x, float y) : x(x), y(y) {}
37
39 {
40 return MPointF(p1.x + p2.x, p1.y + p2.y);
41 }
42 };
43
47 public value struct MBlobValue
48 {
49 double area;
51 double width;
52 double height;
54 double angle;
56 double centerX;
57 double centerY;
62 double centroidX;
63 double centroidY;
64 double topLeftX;
65 double topLeftY;
70 };
71
75 public value struct MBbox
76 {
77 float startX;
78 float startY;
79 float endX;
80 float endY;
81
82 value struct ExtraInfo
83 {
86 String^ labelName;
87 };
88
90
91 MBbox(float startX, float startY, float endX, float endY, float confidence, int labelIndex, String^ labelName)
92 {
93 this->startX = startX;
94 this->startY = startY;
95 this->endX = endX;
96 this->endY = endY;
97 this->extraInfo.confidence = confidence;
98 this->extraInfo.labelIndex = labelIndex;
99 this->extraInfo.labelName = labelName;
100 }
101
102 property float Width { float get() { return endX - startX; } }
103 property float Height { float get() { return endY - startY; } }
104 property float Area { float get() { return Width * Height; } }
105
106 MPointF get()
107 {
108 return MPointF((endX + startX) / 2, (endY + startY) / 2);
109 }
110 };
111
115 public value struct MRotatedBbox
116 {
118 float width;
119 float height;
120 float angle;
121
122 value struct ExtraInfo
123 {
126 String^ labelName;
127 };
128
130
131 MRotatedBbox(MPointF center, float width, float height, float angle, float confidence, int labelIndex, String^ labelName)
132 {
133 this->center = center;
134 this->width = width;
135 this->height = height;
136 this->angle = angle;
137 this->extraInfo.confidence = confidence;
138 this->extraInfo.labelIndex = labelIndex;
139 this->extraInfo.labelName = labelName;
140 }
141
142 List<MPointF>^ ToBboxPoints()
143 {
144 auto points = gcnew List<MPointF>();
145 float cos = (float)Math::Cos(angle);
146 float sin = (float)Math::Sin(angle);
147 float halfWidth = width / 2;
148 float halfHeight = height / 2;
149
150 // Calculate four corners
151 points->Add(MPointF(center.x + halfWidth * cos - halfHeight * sin, center.y + halfWidth * sin + halfHeight * cos));
152 points->Add(MPointF(center.x - halfWidth * cos - halfHeight * sin, center.y - halfWidth * sin + halfHeight * cos));
153 points->Add(MPointF(center.x - halfWidth * cos + halfHeight * sin, center.y - halfWidth * sin - halfHeight * cos));
154 points->Add(MPointF(center.x + halfWidth * cos + halfHeight * sin, center.y + halfWidth * sin - halfHeight * cos));
155
156 return points;
157 }
158
160 {
161 auto points = ToBboxPoints();
162 float minX = Single::MaxValue, minY = Single::MaxValue;
163 float maxX = Single::MinValue, maxY = Single::MinValue;
164
165 for each (auto point in points)
166 {
167 minX = Math::Min(minX, point.x);
168 minY = Math::Min(minY, point.y);
169 maxX = Math::Max(maxX, point.x);
170 maxY = Math::Max(maxY, point.y);
171 }
172
173 return MBbox(minX, minY, maxX, maxY, extraInfo.confidence, extraInfo.labelIndex, extraInfo.labelName);
174 }
175 };
176
180 public value struct MContour
181 {
182 array<MPoint>^ outerContourPoints;
183 array<array<MPoint>^>^ innerContourPoints;
187
188 value struct ExtraInfo
189 {
192 String^ labelName;
193 };
194
196 };
197
201 public value struct ModelEfficiencyParam
202 {
205
207 {
208 this->batchSize = batchSize;
209 this->precisionType = precisionType;
210 }
211
213 {
214 return left.batchSize == right.batchSize && left.precisionType == right.precisionType;
215 }
216
218 {
219 return !(left == right);
220 }
221 };
222
226 public ref class MMindResult
227 {
228 public:
229 List<MRotatedBbox>^ bboxes;
230 List<MContour>^ contours;
231
233 {
234 bboxes = gcnew List<MRotatedBbox>();
235 contours = gcnew List<MContour>();
236 }
237 };
238
239}} // namespace Mmind::Dl
List< MContour > contours
List< MRotatedBbox > bboxes
PrecisionType
Float precision types.
Definition Enums.h:98
Bounding box structure.
MBbox(float startX, float startY, float endX, float endY, float confidence, int labelIndex, String^ labelName)
Blob measurement values computed from a contour.
Contour structure.
array< array< MPoint >^> innerContourPoints
array< MPoint > outerContourPoints
Point with float coordinates.
static MPointF operator+(MPointF p1, MPointF p2)
MPointF(float x, float y)
static MPoint operator+(MPoint p1, MPoint p2)
MPoint(int x, int y)
List< MPointF > ToBboxPoints()
MRotatedBbox(MPointF center, float width, float height, float angle, float confidence, int labelIndex, String^ labelName)
ModelEfficiencyParam(int batchSize, PrecisionType precisionType)
static bool operator!=(ModelEfficiencyParam left, ModelEfficiencyParam right)
static bool operator==(ModelEfficiencyParam left, ModelEfficiencyParam right)