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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
#ifndef CLS_VISION_H
#define CLS_VISION_H
 
#ifdef EXPORT_DLL_BASE_VISION
#define EXPORTED_VISION _declspec(dllexport)
#else
#define EXPORTED_VISION _declspec(dllimport)
#endif
 
class EXPORTED_VISION ClsVision
{
public:
    ClsVision();
    ~ClsVision();
 
public:
    //1. »ñÈ¡µ±Ç°µÄÈí¼þ°æ±¾
    static std::string GetVersion(void);
 
    //2. »ñÈ¡¸üÐÂÄÚÈÝ
    static std::string GetUpdate(void);
 
    //4. »ñÈ¡µ±Ç°µÄĿ¼
    static std::string GetAppPathA();
 
public:
    //1. ·ÂÉä±ä»»
    static ParaAffine2D VectorAngleToRigid(Point2D ptOrigine, double angleOrigine, Point2D ptTarget, double angleTarget);
 
    //2. µãµ½µãµÄ¾àÀë
    static double DistancePP(Point2D pt1, Point2D pt2);
 
    //3. µãµ½Ö±ÏߵľàÀë
    static double DistancePL(Point2D pt, Line2D line);
 
    //4. Ö±ÏߵĽ»µã
    static Point2D LineIntersection(Line2D line1, Line2D line2);
 
    //5. Ö±ÏߵĽǶÈ
    static double LineAngle(Line2D line);
 
    //6. Ö±ÏßÓëÖ±ÏߵļнÇ
    double AngleLL(Line2D line1, Line2D line2);
 
    //7. ×ø±êת»»
    static Point2D CoordinateTransform(Point2D pt, ParaAffine2D affine);
 
    //8. µãµ½Ö±ÏߵĴ¹×ã
    static Point2D ProjectionPL(Point2D pt, Line2D line);
 
    //9. ½Ç¶Èת»»Îª»¡¶È
    static double DegreeToRad(double angle);
 
    //10. »¡¶Èת»»Îª½Ç¶È
    static double RadToDegree(double rad);
 
    //11. CosÖµ
    static double GetCos(double rad);
 
    //12. SinÖµ
    static double GetSin(double rad);
 
    //13. ×îС¶þ³Ë·¨Ö±ÏßÄâºÏ
    static void FitLiner(Point2D *ptArray, int sz, double &ka, double &kb);
 
    //14. ÄâºÏÔ²
    static Circle2D FitCircle(Point2D *ptArray, int sz);
 
    //15. Ö±ÏߵĸÕÐԱ任
    static ParaAffine2D LineVectorToRigid(Line2D lineStandard, Line2D lineReal);
 
    //16. Èýµã³ÉÔ±
    static Circle2D ThreePointsToCircle(Point2D pt1, Point2D pt2, Point2D pt3);
 
    //17. Ö´Ðб궨£¬·ÂÉä±ä»¯
    static ParaAffine2D VectorToHomMat2d(std::vector<Point2D> vPtOrigine, std::vector<Point2D> vPtTarget);
 
    //18. ¸ÕÐԱ任
    static ParaAffine2D VectorToRigid(std::vector<Point2D> vPtOrigine, std::vector<Point2D> vPtTarget);
 
    //19. ·ÂÉä²ÎÊý
    static void HomMat2dToAffinePar(ParaAffine2D affine, double &xMmvsp, double &yMmvsp, double &angle, double &theta);
 
    //20. ·ÂÉä±ä»»
    static ParaAffine2D VectorToSimilarity(std::vector<Point2D> vPtOrigine, std::vector<Point2D> vPtTarget);
 
    //21. ´´½¨Ô²µÄÀëÉ¢µã
    static void GenCirclePoints(Point2I ptCenter, double radius, double stepLength, std::vector<Point2I> &vPtCircle);
 
    //22. Ö´Ðб궨
    static CalibrateResult CameraCalibrate(double *px, double *py, double *xmm, double *ymm, int sz);
 
    //23. ×ø±êת»»
    static Point2D CoordinateTransform(Point2D pt, CalibrateResult calibrate);
 
    //24. Ïà»ú±ê¶¨
    static void CalibrateCamera(Point2D *ptArrayCamera, Point2D *ptArrayWorld, int sz, ParaCalibrate &result);
 
    //25. ÐýתÖÐÐÄ
    static Point2D GetRotateCenter(Point2D ptOrigine, Point2D ptRotate, double angle);
 
    //26. XYTheta±ê¶¨
    static void CalibrateXyTheta(std::vector<Point2D> vPtOrgine, std::vector<Point2D> vPtReal, double angle, ParaCalibrate &result);
 
public:
    //1. ¶ÔÏóÊÇ·ñ´æÔÚ
    static bool ObjectExist(HalconCpp::HObject &hObject);
 
    //2. ¿½±´Í¼Ïñ
    static void CopyImage(HalconCpp::HObject &hObject, HalconCpp::HObject &hTarget);
 
    //3. ²úÉú¿Õ¶ÔÏó
    static void GenEmptyObject(HalconCpp::HObject &hObject);
 
    //4. ¾ùÖµÂ˲¨
    static void ImageMean(HalconCpp::HObject &hObject, int maskWidth, int maskHeight, HalconCpp::HObject &hTarget);
 
    //5. »Ò¶È±ÕÔËËã
    static void GrayClosing(HalconCpp::HObject &hObject, int maskWidth, int maskHeight, HalconCpp::HObject &hTarget);
 
    //6. »Ò¶È¿ªÔËËã
    static void GrayOpening(HalconCpp::HObject &hObject, int maskWidth, int maskHeight, HalconCpp::HObject &hTarget);
 
    //7. Í¼Ïñ¾ùÖµ
    static void ImageIntensity(HalconCpp::HObject &hObject, HalconCpp::HObject &hRegion, double &avgResult, double &stdResult);
 
    //8. Í¼ÏñÖ±·½Í¼Í³¼Æ
    static void GetHistogram(HalconCpp::HObject &hObject, HalconCpp::HObject &hRegion, int sz, int *aryHist);
 
    //9. ¶ÔÏó×éºÏ
    static void ObjectConcat(HalconCpp::HObject &hObject1, HalconCpp::HObject &hObject2, HalconCpp::HObject &hTarget);
 
    //10. ½ØÈ¡ÇøÓò
    static void ReduceDomain(HalconCpp::HObject &hObject, HalconCpp::HObject &hRegion, HalconCpp::HObject &hTarget);
 
    //11. ½ØÈ¡Í¼Ïñ
    static void CropDomain(HalconCpp::HObject &hObject, HalconCpp::HObject &hTarget);
 
    //12. ÇøÓòת»»ÎªÍ¼Ïñ
    static void RegionToBin(HalconCpp::HObject &hRegion, int width, int height, HalconCpp::HObject &hTarget);
 
    //13. ´´½¨NCCÆ¥Åä¾ä±ú
    static int CreateNccModel(HalconCpp::HObject &hObject, double angleStart, double angleEnd, double angleStep, int limitTime);
 
    //14. ÊÍ·ÅÄ£°åID
    static void ClearNccModel(int id);
 
    //15. ²éÕÒÄ£°å
    static void FindNccModel(HalconCpp::HObject &hObject, int idModel, double minScore, int numMatches, std::vector<ParaMatch> &vResult);
 
    //16. Í¼ÏñÖÐÖµ
    static void ImageMedian(HalconCpp::HObject &hObject, double radius, HalconCpp::HObject &hTarget);
 
    //17. Í¼Ïñ²îÖµ
    static void ImageSub(HalconCpp::HObject &hObject1, HalconCpp::HObject &hObject2, double mul, int gray, HalconCpp::HObject &hTarget);
 
    //18. Í¼Ïñת»»
    static void AffineTransImage(HalconCpp::HObject &hImage, ParaAffine2D affine, HalconCpp::HObject &hTarget);
 
    //19. Í¶Ó°Ö±·½Í¼
    static void ProjectHistogram(HalconCpp::HObject &hImage, int pLeft, int pTop, int pRight, int pBottom, double *aryHor, double *aryVer);
 
    //20. Í¼ÏñµÄ³Ë·¨
    static void ImageMul(HalconCpp::HObject &hObject, double mul, HalconCpp::HObject &hTarget);
 
    //21. ¶ÔÏóÊýÁ¿
    static int ObjectNumber(HalconCpp::HObject &hObject);
 
    //22. »ñȡͼÏñ´óС
    static void GetImageSize(HalconCpp::HObject &hObject, int &width, int &height);
 
    //23. ¶ÁȡͼÏñ
    static void ReadImage(HalconCpp::HObject &hObject, std::string &fileName);
 
    //24. »ñÈ¡ÏñËØ
    static bool GetImagePixel(HalconCpp::HObject &hObject, Point2D pt, int &bResult, int &gResult, int &rResult);
 
    //25. Í¼ÏñÇøÓò·Ö¸î
    static void ImageThreshold(HalconCpp::HObject &hObject, HalconCpp::HObject &hRegion, int minThreshold, int maxThreshold);
 
    //26. ucharת»»ÎªÍ¼Ïñ
    static void DataToObject(uchar *data, int width, int height, HalconCpp::HObject &hObject);
 
    //27. Í¼Ïñ·Å´ó
    static void ZoomImageFactor(HalconCpp::HObject &hObject, HalconCpp::HObject &hTarget, double xRate, double yRate);
 
    //28. Í¼Ïñ·Å´ó
    static void ZoomImageSize(HalconCpp::HObject &hObject, HalconCpp::HObject &hTarget, int width, int hegiht);
 
    //29. ´´½¨ShapeÄ£°å
    static int CreateShapeModel(HalconCpp::HObject &hObject, double angleStart, double angleEnd, double angleStep, int minContrast, int minCostTime);
 
    //30. ÊÍ·ÅShape
    static void ClearShapeModel(int id);
 
    //31. ²éÕÒShapeÄ£°å
    static void FindShapeModel(HalconCpp::HObject &hObject, int idModel, double minScore, int numMatches, std::vector<ParaMatch> &vResult);
 
    //32. ÇåÀíËùÓÐNCCÄ£°å
    static void ClearAllNccModel();
 
    //33. ÇåÀíËùÓеÄShapeÄ£°å
    static void ClearAllShapeModel();
 
    //34. »ñÈ¡ÇøÓò
    static void GetDomain(HalconCpp::HObject &hObject, HalconCpp::HObject &hTarget);
 
    //35. Shape¶¨Î»ÂÖÀª
    static void GetShapeContour(HalconCpp::HObject &hContour, int id);
 
    //36. ÂÖÀª×ª»¯
    static void AffineTransContour(HalconCpp::HObject &hObject, HalconCpp::HObject &hTarget, ParaAffine2D affine);
 
    //37. Í¼Ïñ»Ò¶È»¯
    static void ImageToGray(HalconCpp::HObject &hObject, int iGray, HalconCpp::HObject &hTarget);
 
    //38. ¾Ö²¿ÔöÇ¿
    static void ImageEmphasize(HalconCpp::HObject &hObject, int maskWidth, int maskHeight, double rate, HalconCpp::HObject &hTarget);
 
    //39. ´´½¨Í¼Ïñ
    static void GenImageConst(HalconCpp::HObject &hImage, int width, int height, int gray);
 
    //40. ´óÂÉ·¨
    static int Otsu(int *aryData, int sz);
 
    //41. ½ØÈ¡ROIÇøÓòµÄͼÏñ²¢¾ÀÕý
    static void GetAndAdjustRectImage(HalconCpp::HObject &hObject, HalconCpp::HObject &hRegion, int modeAngle, HalconCpp::HObject &hTarget);
 
    //42. ½ØÈ¡ROIÇøÓòµÄͼÏñ²¢¾ÀÕý
    static void GetAndAdjustRectImage(HalconCpp::HObject &hObject, double cx, double cy, double angle, int width, int height, HalconCpp::HObject &hTarget);
 
    //43. ´´½¨Í¼Ïñ
    static void GenImage(const unsigned char* data, HalconCpp::HObject &hImage, int imgType, int width, int height);
 
    //44. ´´½¨ÍÖÔ²ÇøÓò
    static void GenEllipse(HalconCpp::HObject &hRegion, double x, double y, double angle, double length1, double length2);
 
    //45. Í¼ÏñÑ¡Ôñ
    static void ImageRotate(HalconCpp::HObject &hObject, int angle, HalconCpp::HObject &hTarget);
 
    //46. ½ØÍ¼Í¼Ïñ 
    static void ImageDraw(HalconCpp::HObject &hObject, HalconCpp::HObject &hTarget, int left, int top, int width, int height);
 
    //47. ½ØÍ¼´ø½Ç¶ÈͼÏñ
    static void GetAngleImage(HalconCpp::HObject &hObject, HalconCpp::HObject &hTarget, Point2D center, double angle, int width, int height);
 
public:
    //1. ÇøÓòÊÇ·ñ´æÔÚ
    static bool RegionExist(HalconCpp::HObject &hRegion);
 
    //2. ÇøÓòºÏ²¢
    static void RegionUnion2(HalconCpp::HObject &hRegion1, HalconCpp::HObject &hRegion2, HalconCpp::HObject &hTarget);
 
    //3. ÇøÓò²îÖµ
    static void RegionDiffer(HalconCpp::HObject &hRegion1, HalconCpp::HObject &hRegion2, HalconCpp::HObject &hTarget);
 
    //4. ÇøÓò½»¼¯
    static void RegionIntersection(HalconCpp::HObject &hRegion1, HalconCpp::HObject &hRegion2, HalconCpp::HObject &hTarget);
 
    //5. ÇøÓòÁ¬Í¨
    static void RegionConnect(HalconCpp::HObject &hRegion, HalconCpp::HObject &hTarget);
 
    //6. ÇøÓò±ÕÔËËã
    static void RegionClosing(HalconCpp::HObject &hRegion, double radius, HalconCpp::HObject &hTarget);
 
    //7. ÇøÓò¿ªÔËËã
    static void RegionOpening(HalconCpp::HObject &hRegion, double radius, HalconCpp::HObject &hTarget);
 
    //8. ÇøÓò¸¯Ê´
    static void RegionErosion(HalconCpp::HObject &hRegion, double radius, HalconCpp::HObject &hTarget);
 
    //9. ÇøÓòÅòÕÍ
    static void RegionDilation(HalconCpp::HObject &hRegion, double radius, HalconCpp::HObject &hTarget);
 
    //10. ÇøÓòºÏ²¢
    static void RegionUnion(HalconCpp::HObject &hRegion, HalconCpp::HObject &hTarget);
 
    //11. ÇøÓòת»»
    static void AffineTransRegion(HalconCpp::HObject &hRegion, ParaAffine2D affine, HalconCpp::HObject &hTarget);
 
    //12. ÅжϵãÔÚÇøÓòÀïÃæ
    static bool JudgeInRegion(Point2D pt, HalconCpp::HObject &hRegion);
 
    //13. ÇøÓòÖÐÐÄ
    static void AreaCenter(HalconCpp::HObject &hRegion, int &area, double &x, double &y);
 
    //14. Ãæ»ýÈüÑ¡
    static void SelectShape(HalconCpp::HObject &hRegion, std::string strMode, double minValue, double maxValue, HalconCpp::HObject &hTarget);
 
    //15. ×î´óÇøÓò
    static void MaxRegion(HalconCpp::HObject &hRegion, HalconCpp::HObject &hTarget);
 
    //16. ×îСÍâ½ÓÔ²
    static void SmallestCircle(HalconCpp::HObject &hRegion, double &x, double &y, double &radius);
 
    //17. ×îСÍâ½Ó¾ØÐÎ
    static void SmallestRectangle(HalconCpp::HObject &hRegion, double &x1, double &y1, double &x2, double &y2);
 
    //18. ÇøÓò×îСÍâ½ç¾ØÐΠ
    static void SmallestRectangle2(HalconCpp::HObject &hRegion, double &x, double &y, double &angle, double &xa, double &xb);
 
    //19. ´´½¨¾ØÐÎ2
    static void GenRectangle2(HalconCpp::HObject &hTarget, double x, double y, double angle, double xa, double xb);
 
    //20. ´´½¨Ô²
    static void GenCircle(HalconCpp::HObject &hObject, double x, double y, double radius);
 
    //21. ´´½¨Ö±ÏßÇøÓò
    static void GenRegionLine(HalconCpp::HObject &hRegion, double x1, double y1, double x2, double y2);
 
    //22. ²úÉú¾ØÐÎ
    static void GenRectangle1(HalconCpp::HObject &hTarget, double x1, double y1, double x2, double y2);
 
    //23.²úÉú¶à±ßÐÐÇøÓò
    static void GenRegionPolygonFilled(HalconCpp::HObject &hTarget, Point2D *ptArray, int sz);
 
    //24. ²úÉúÊ®×Ö
    static void GenCrossObject(HalconCpp::HObject &hObject, Point2D pt, double sz, double angle);
 
    //25. ²úÉúÇøÓòÂÖÀª
    static void GenContourRegion(HalconCpp::HObject &hRegion, std::string strMode, HalconCpp::HObject &hTarget);
 
    //26. Ñ¡Ôñ¶ÔÏó
    static void SelectObject(HalconCpp::HObject &hObject, HalconCpp::HObject &hSelected, int idx);
 
    //27. ÇøÓòÌî³ä
    static void FillUp(HalconCpp::HObject &hRegion, HalconCpp::HObject &hTarget);
 
    //28. ´´½¨¾ØÐÎ1
    static void GenRectangle1(HalconCpp::HObject &hTarget, std::vector<double> vX1, std::vector<double> vY1, std::vector<double> vX2, std::vector<double> vY2);
 
    //29. ´´½¨¾ØÐÎ2
    static void GenRectangle2(HalconCpp::HObject &hTarget, std::vector<double> vX, std::vector<double> vY, std::vector<double> vAngle, std::vector<double> vLength1, std::vector<double> vLength2);
 
    //30. ´´½¨Ô²
    static void GenCircle(HalconCpp::HObject &hTarget, std::vector<double> vX, std::vector<double> vY, std::vector<double> vRadius);
 
    //31. »ñȡֱ·½Í¼ÇøÓò
    static void GenDispZft(HalconCpp::HObject &hImage, int dispWidth, int dispHeight, HalconCpp::HObject &hZftObject);
 
    //32. ÇøÓòÅòÕÍ
    static void RegionDilationRectangle(HalconCpp::HObject &hRegion, HalconCpp::HObject &hTarget, int width, int height);
 
    //33. ²úÉúÇøÓò
    static void GenRegionPoints(HalconCpp::HObject &hRegion, std::vector<Point2I> vPoints);
 
public:
    //1. ÏÔʾģʽ
    static void SetDraw(int id, std::string strMode);
 
    //2. ÏÔʾλÖÃ
    static void SetTposition(int id, int left, int top);
 
    //3. ÏÔʾÑÕÉ«
    static void SetColor(int id, std::string strColor);
 
    //4. Ð´ÎÄ×Ö
    static void WriteString(int id, std::string str);
 
    //5. ÉèÖÃ×ÖÌå
    static void SetFont(int id, int sz);
 
    //6. ÏÔʾ×Ö·û
    static void DispMessage(int id, std::string str, int xPos, int yPos, std::string strColor, std::string strBox);
 
    //7. ÑÕɫת»»
    static std::string ToColor(int iColor);
 
    //8. ÉèÖÃÑÕÉ«
    static void SetRgb(int id, int red, int green, int blue);
 
    //29. rgbת»»ÎªÑÕÉ«
    static std::string Rgb2Color(int r, int g, int b);
 
public:
    //1. ¼ì²âÅжÏ
    static bool JudgeResult(double value, double fzMin, double fzMax);
 
    //2. ÅÅÐò
    static void SortArray(double *data, int sz, int iType);
 
    //4. »ñÈ¡2¸öµãµÄÖеã
    static Point2D GetPointCenter(Point2D pt1, Point2D pt2);
 
    //7. ¸ñʽת»»
    static Point2I PointToInt(Point2D pt);
 
    //8. ¸ñʽת»»
    static Point2D PointToDouble(Point2I pt);
 
    //9. Êý¾ÝºÏ²¢, ¹«Ê½ = 10000 * int1 + int2, int1, int2, ²»ÔËÊ䳬¹ý10000 
    static int IntegerUnion(int int1, int int2);
 
    //10. Êý¾Ý·Ö½â
    static void IntegerDivide(int intInput, int &int1, int &int2);
 
    //11. µã×ø±êºÏ²¢£¬ÓÃÓÚ²éÕÒ
    static int PointToInteger(Point2I pt);
 
    //12. ÕûÊýת»»Îª×ø±ê
    static Point2I IntegerToPoint(int intIntput);
 
    //13. ×Ö·û´®·Ö¸î
    static int SplitString(std::string strInput, std::string strSeparator, std::vector<std::string> &vOutString);
 
    //14. ÅжÏdoubleÊý¾ÝÊÇ·ñÎÞЧ
    static bool IsNaN(double value);
 
    //15 ¸ñʽ»¯×Ö·û´®
    static std::string FormatString(const char *lpcszFormat, ...);
 
    //16. ×Ö·û·Ö¸î
    static int StringSplit(const std::string& strScr, const std::string& delim, std::vector<std::string>& strings);
    static void StringTrim(std::string& s);
 
};
 
#endif