DaoAI World C# SDK INDUSTRIAL 2024.8.0
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1#pragma once
2#include "managed_object.h"
3#include "../daoai_dl_sdk/include/export/model.h"
4
5using namespace System;
6namespace DaoAI
7{
8 namespace DeepLearningCLI
9 {
10 public ref class Point : public ManagedObject<DaoAI::DeepLearning::Point>
11 {
12 public:
13 Point(float x, float y, float confidence, String^ label);
14 Point(float x, float y, String^ label);
15 Point(float x, float y);
16 Point();
17
18 static Point^ operator+(Point^ lhs, Point^ rhs);
19 static Point^ operator-(Point^ lhs, Point^ rhs);
20 Point(const DaoAI::DeepLearning::Point& point) : ManagedObject(new DaoAI::DeepLearning::Point(point)) {}
21 property float X
22 {
23 float get() {
24 return m_Instance->x;
25 }
26 void set(float value) {
27 m_Instance->x = value;
28 }
29 }
30 property float Y
31 {
32 float get() {
33 return m_Instance->y;
34 }
35 void set(float value){
36 m_Instance->y = value;
37 }
38 }
39
40 };
41
42 public ref class Polygon : public ManagedObject<DaoAI::DeepLearning::Polygon>
43 {
44 public:
45 Polygon(cli::array<Point^>^ points);
46 Polygon();
47 // Copy constructor from native object
48 Polygon(const DaoAI::DeepLearning::Polygon& polygon);
49
50 property cli::array<Point^>^ Points
51 {
52 cli::array<Point^>^ get() {
53 cli::array<Point^>^ points = gcnew cli::array<Point^>(m_Instance->points.size());
54 for (int i = 0; i < m_Instance->points.size(); i++) {
55 points[i] = gcnew Point(m_Instance->points[i].x, m_Instance->points[i].y);
56 }
57 return points;
58 }
59 void set(cli::array<Point^>^ value) {
60 m_Instance->points.clear();
61 for (int i = 0; i < value->Length; i++) {
62 m_Instance->points.push_back(DaoAI::DeepLearning::Point(value[i]->X, value[i]->Y));
63 }
64 }
65 }
66
67 };
68
69 public ref class Box : public ManagedObject<DaoAI::DeepLearning::Box>
70 {
71 public:
72 enum class Type { XYXY, XYWH };
78 Box(Point^ p1, Point^ p2, float angle);
79
87 Box(float a1, float a2, float a3, float a4, float angle, Type type);
88 // Copy constructor from native object
89 Box(const DaoAI::DeepLearning::Box& box);
90
95
99 String^ toString();
100
104 float h();
105
109 float w();
110
114 float x1();
115
116
120 float y1();
121
125 float x2();
126
130 float y2();
131
135 float angle();
136
141 Box^ toType(Type type);
142
143 property cli::array<float>^ data
144 {
145 cli::array<float>^ get() {
146 cli::array<float>^ data = gcnew cli::array<float>(m_Instance->data.size());
147 for (int i = 0; i < m_Instance->data.size(); i++) {
148 data[i] = m_Instance->data[i];
149 }
150 return data;
151 }
152 void set(cli::array<float>^ value) {
153 m_Instance->data.clear();
154 for (int i = 0; i < value->Length; i++) {
155 float v = value[i];
156 m_Instance->data.push_back(v);
157 }
158 }
159 }
160 property Type type
161 {
162 Type get() {
163 return (Type)m_Instance->type;
164 }
165 void set(Type value) {
166 m_Instance->type = (DaoAI::DeepLearning::Box::Type)value;
167 }
168 }
169
170 };
171
172 public ref class Image : public ManagedObject<DaoAI::DeepLearning::Image>
173 {
174 public:
175 enum class Type
176 {
178 };
179
180 // create an image object from headers with a new deep copy of data buffer
181 Image(int image_height, int image_width, Image::Type type, cli::array<uint8_t>^ data);
182 Image(const DaoAI::DeepLearning::Image& image);
183 Image(String^ image);
184 // create a deep copy of the Image object
185 Image^ clone();
186
187 void save(String^ file_path);
188
189 property int height
190 {
191 int get() {
192 return m_Instance->height;
193 }
194 void set(int value) {
195 m_Instance->height = value;
196 }
197 }
198 property int width
199 {
200 int get() {
201 return m_Instance->width;
202 }
203 void set(int value) {
204 m_Instance->width = value;
205 }
206 }
207
208 property Type type
209 {
210 Type get() {
211 return (Type)m_Instance->type;
212 }
213 void set(Type value) {
214 m_Instance->type = (DaoAI::DeepLearning::Image::Type)value;
215 }
216 }
217
218 property cli::array<uint8_t>^ data
219 {
220 cli::array<uint8_t>^ get() {
221 int channels = (type == Type::GRAYSCALE) ? 1 : 3;
222 cli::array<uint8_t>^ data = gcnew cli::array<uint8_t>(m_Instance->width * m_Instance->height * channels);
223 for (int i = 0; i < m_Instance->width * m_Instance->height * channels; i++) {
224 data[i] = m_Instance->getData()[i];
225 }
226 return data;
227 }
228 }
229 };
230
231 public ref class Mask : public ManagedObject<DaoAI::DeepLearning::Mask>
232 {
233 public:
234 Mask(Image^ image);
235 Mask(DaoAI::DeepLearning::Mask mask);
236
237 Mask^ merge(Mask^ mask);
238
239 cli::array<Polygon^>^ toPolygons();
240
241 Image^ toImage();
242
243 property int width
244 {
245 int get() {
246
247 return m_Instance->width;
248 }
249 }
250 property int height
251 {
252 int get() {
253 return m_Instance->height;
254 }
255 }
256 internal:
257
258 };
259 }
260}
Definition common.h:70
float x2()
: The x coordinate of bottom-right corner
Definition common.cpp:83
float w()
: Bounding box width
Definition common.cpp:74
Polygon toPolygon()
: Convert to polygon type considering box angle
Definition common.cpp:58
String toString()
: Convert to polygon to human readable format
Definition common.cpp:64
Box toType(Type type)
: Convert to different box type
Definition common.cpp:99
float y2()
: The y coordinate of bottom-right corner
Definition common.cpp:91
Type
Definition common.h:72
float h()
: Bounding box height
Definition common.cpp:69
float x1()
: The x coordinate of top-left corner
Definition common.cpp:79
Box(Point^ p1, Point^ p2, float angle)
: Construct a box given the top-left and right-bottom points
Definition common.cpp:40
float angle()
: The rotate angle of he bounding box
Definition common.cpp:95
float y1()
: The y coordinate of top-left corner
Definition common.cpp:87
Definition common.h:173
Image(int image_height, int image_width, Image::Type type, cli::array< uint8_t >^ data)
Definition common.cpp:105
Type
Definition common.h:176
Image clone()
Definition common.cpp:126
void save(String^ file_path)
Definition common.cpp:121
Definition managed_object.h:18
DaoAI::DeepLearning::Point * m_Instance
Definition managed_object.h:20
Definition common.h:232
Mask merge(Mask^ mask)
Definition common.cpp:138
Image toImage()
Definition common.cpp:158
Mask(Image^ image)
Definition common.cpp:132
cli::array< Polygon^> toPolygons()
Definition common.cpp:147
Definition common.h:11
Point(const DaoAI::DeepLearning::Point &point)
Definition common.h:20
static Point operator-(Point^ lhs, Point^ rhs)
Definition common.cpp:19
static Point operator+(Point^ lhs, Point^ rhs)
Definition common.cpp:15
Point()
Definition common.cpp:13
Definition common.h:43
Polygon()
Definition common.cpp:23
Definition common.cpp:6