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
#ifndef VISION_BUFFER_PRO
#define VISION_BUFFER_PRO
 
#include "VisionRecipe.h"
 
typedef struct _LineMetrologyPara
{
    int direction;
    int getMode;
    int getDirection;
    double stepLength;
    double stepDist;
    int threshold;
    int numSample;
    double minScore;
}LineMetrologyPara;
 
class CVisionBufferPro
{
public:
    CVisionBufferPro();
    ~CVisionBufferPro();
 
public:
    //1. Í¼Ïñת»»
    static bool bufferToObject(DimensionDir eDir, int height, HalconCpp::HObject &hImage);
 
    //2. ½ØÍ¼Í¼Ïñ
    static bool getImageROI(DimensionDir eDir, HalconCpp::HObject &hImage, int x1, int y1, int x2, int y2);
    static bool getIndexImage(DimensionDir eDir, HalconCpp::HObject *hImage, int index);
 
    //3. »ñÈ¡¾àÀëµÄ¼ì²â½á¹û
    static bool getDistResult(DimensionDir eDir, CDistDotProcess *dot, double &result, int &xPosPxl, int &yPosPxl);
 
    //4. ²éÕÒµã
    static bool GetMeasurePos(HalconCpp::HObject &hObject, Line2D line, int threshold, int modeTrans, int step, Point2D &ptStart, Point2D &ptEnd);
    static bool GetMeasurePosKeyLimit(HalconCpp::HObject &hObject, Line2D line, int nTypePoint, int threshold, int modeTrans, int step, int distLimit, Point2D &ptStart, Point2D &ptEnd);
    static bool GetMeasureRCutPos(HalconCpp::HObject &hObject, Line2D line, int threshold, int modeTrans, int chamberSize, double proDist, Point2D &ptStart, Point2D &ptEnd);
    static bool GetMeasureNearPos(HalconCpp::HObject& hObject, Line2D line, int threshold, int modeTrans, int step, Point2D& ptStart, Point2D& ptEnd);
 
    //5. »ñÈ¡¾àÀëµÄ¼ì²â½á¹û
    static int getDistResult(DimensionDir eDir, CDistDotProcess *dot, double &distResult);
 
    //6. ×ø±êת»»
    static bool TransformToReal(DimensionDir eDir, Point2I point, int nType, Point2I &result);
 
    //7. »ñÈ¡×ø±ê  ×øÉϵã×ø±ê¡¢ÓÒÉϵã×ø±ê£¬ÓÒϵã×ø±ê£¬×óϵã×ø±ê
    static void getRect2Point(Point2D rect2CenterPoint, double rect2Phi, double rect2Length1, double rect2Length2, Point2D *rect2Points);
 
    //8. »ñÈ¡¾ØÐεÄбֱÏß
    static Line2D getRect2Line(Point2D rect2CenterPoint, double rect2Phi, int rect2Length2);
 
    //9. ²éÕÒÖ±Ïß
    static bool LineMeasureByRuler(HalconCpp::HObject &hObject, Line2D line,
        LineMetrologyPara shapeMetrologyPara, Line2D &lineResult);
 
    //10. »ñÈ¡ÏßɨµÄͼÏñÖ¡µÄ¿í¶ÈºÍ¸ß¶È
    static void getLineFrameSize(DimensionDir eDir, int &nFrameWidth, int &nFrameHeight);
 
    //11. ²éÕÒÇиî
    static bool findCutLine(DimensionDir eDir, Point2I keyPoint, int keyRange, int keyThres, Point2I &result);
 
    //12. ²éÕÒNorchȱÏÝ
    static int findNorchDefect(DimensionDir eDir, std::vector<Point2D> vPoints, CRect roiRect, int nThres, int nOffset, int nBinThres, 
        int szType, int xFzSize, int yFzSize,  CRect *aryResult);
 
private:
 
};
 
#endif