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