-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAlgorithm.h
More file actions
306 lines (222 loc) · 5.25 KB
/
Algorithm.h
File metadata and controls
306 lines (222 loc) · 5.25 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
#pragma once
/*
#include <msclr/marshal_cppstd.h>
#include <_algorithm.h>
#include "managed_shared_ptr.h"
using namespace System;
using namespace System::Collections;
using namespace System::Collections::Generic;
using namespace System::Runtime::InteropServices;
using namespace System;
namespace HV {
namespace V1 {
namespace ALGORITHM {
public ref class MeasurementLine {
private:
double _centerX;
double _centerY;
double _angle;
double _range;
double _distance;
bool _direction;
int _type;
double _threshold;
public:
MeasurementLine() {
_centerX = 0;
_centerY = 0;
_angle = 0;
_range = 0;
_distance = 0;
_direction = 0;
_type = 0;
_threshold = 0;
}
~MeasurementLine() { this->!MeasurementLine(); }
!MeasurementLine() { }
property double CenterX {
double get() {
return this->_centerX;
}
void set(double value) {
this->_centerX = value;
}
}
property double CenterY {
double get() {
return this->_centerY;
}
void set(double value) {
this->_centerY = value;
}
}
property double Angle {
double get() {
return this->_angle;
}
void set(double value) {
this->_angle = value;
}
}
property double Range {
double get() {
return this->_range;
}
void set(double value) {
this->_range = value;
}
}
property double Distance {
double get() {
return this->_distance;
}
void set(double value) {
this->_distance = value;
}
}
property bool Direction {
bool get() {
return this->_direction;
}
void set(bool value) {
this->_direction = value;
}
}
property int Type {
int get() {
return this->_type;
}
void set(int value) {
this->_type = value;
}
}
property double Threadhold {
double get() {
return this->_threshold;
}
void set(double value) {
this->_threshold = value;
}
}
};
public ref class Line {
private:
double _mx;
double _my;
double _cx;
double _cy;
double _dTheta;
public:
Line() {
_mx = 0;
_my = 0;
_cx = 0;
_cy = 0;
_dTheta = 0;
}
~Line() { this->!Line(); }
!Line(){ }
property double MX {
double get() {
return this->_mx;
}
void set(double value) {
this->_mx = value;
}
}
property double MY {
double get() {
return this->_my;
}
void set(double value) {
this->_my = value;
}
}
property double CX {
double get() {
return this->_cx;
}
void set(double value) {
this->_cx = value;
}
}
property double CY {
double get() {
return this->_cy;
}
void set(double value) {
this->_cy = value;
}
}
property double Theta {
double get() {
return this->_dTheta;
}
void set(double value) {
this->_dTheta = value;
}
}
};
public ref class Algorithm
{
internal:
HV::V1::mananged_shared_ptr<hv::v1::algorithm::algorithm> _instance;
public:
Algorithm() : _instance(new hv::v1::algorithm::algorithm()) {
}
~Algorithm() {
this->!Algorithm();
}
!Algorithm() {
this->_instance.~mananged_shared_ptr();
}
bool GetCrossPointFromTwoLine(Line^ _inLine1, Line^ _inLine2, [Out]double% pointX, [Out]double% pointY) {
LINE _line_1;
LINE _line_2;
_line_1.cx = _inLine1->CX;
_line_1.cy = _inLine1->CY;
_line_1.dTheta = _inLine1->Theta;
_line_1.mx = _inLine1->MX;
_line_1.my = _inLine1->MY;
_line_2.cx = _inLine2->CX;
_line_2.cy = _inLine2->CY;
_line_2.dTheta = _inLine2->Theta;
_line_2.mx = _inLine2->MX;
_line_2.my = _inLine2->MY;
PT32 point;
auto returnValue = this->_instance->getCrossPointFromTwoLine(_line_1, _line_2, &point);
pointX = point.x;
pointY = point.y;
return returnValue;
}
double GetAlignmentDegreeFromDegree(double inAngle, double baseAngle) {
return this->_instance->getAlignmentDegreeFromDegree(inAngle, baseAngle);
}
//[Out]int% value
bool FindLine(IntPtr buffer, int image_width, int image_height, MeasurementLine^ inLineParam, [Out]Line^% outLine) {
auto input_pointer = static_cast<unsigned char*>(buffer.ToPointer());
LINE outline;
MEASUREMENT_LINE inLine;
inLine.center.x = inLineParam->CenterX;
inLine.center.y = inLineParam->CenterY;
inLine.angle = inLineParam->Angle;
inLine.distance = inLineParam->Distance;
inLine.direction = inLineParam->Direction;
inLine.range = inLineParam->Range;
inLine.threshold = inLineParam->Threadhold;
inLine.type = inLineParam->Type;
bool returnValue = this->_instance->findLine(input_pointer, image_width, image_height, inLine, &outline);
Line^ outLineSharp = gcnew Line();
outLineSharp->CX = outline.cx;
outLineSharp->CY = outline.cy;
outLineSharp->MX = outline.mx;
outLineSharp->MY = outline.my;
outLineSharp->Theta = outline.dTheta;
outLine = outLineSharp;
return returnValue;
}
};
}
}
}
*/