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
#ifndef ISOFT_VISION_APP_H
#define ISOFT_VISION_APP_H
 
#include <functional>
#include <iostream>
 
enum DefectNgType {
    DefectNg_OK = 0,    //OK
    DefectNg_Chip,      //Chip
    DefectNg_Broken,    //ÆÆËð
    DefectNg_Grind,     //ÑÐÄ¥
    DefectNg_Dist_Cut,  //Çи¶È
    DefectNg_Corner_Dist,    //½Ç¾«¶È
    DefectNg_Unknown          //Ö¸´íÎó
};
 
#define NG_INF_TOTAL          1000
typedef struct _NgInfo
{
    int eDir;                //¼ì²âÃæ
    int id;                  //¼ì²âID
    CString strName;        //Ãû³Æ
    int xPosPxl;            //XλÖÃ
    int yPosPxl;            //YλÖÃ
    double result;          //½á¹û   Measure
    double xResult;          //½á¹û  Chip
    double yResult;         //½á¹û   Chip
    double minValue;        //ÏÂÏÞ
    double maxValue;        //ÏÞÖÆ
    int ngType;             //ȱÏÝÀàÐÍ
    bool isRes;             //¼ì²â½á¹û
    int x1;                 //ȱÏݵÄ×îС¾ØÐÎ
    int y1;                 //ȱÏݵÄ×îС¾ØÐÎ
    int x2;                 //ȱÏݵÄ×îС¾ØÐÎ
    int y2;                 //ȱÏݵÄ×îС¾ØÐÎ
    int eVision;            //ÊÓ¾õËã·¨
}NgInfo;
 
 
//typedef std::function<void(int msgEvent, int x, int y, double rate, int pixel)> ImageVisionEvent;
//typedef std::function<void(int code, int eDir)> ImageVisionEvent;
 
class IVisionEvent
{
public:
    //1. ½ÓÊÕµ½Êý¾Ýʼþ
    using MsgReceivedEvent = void(*)(int code, int eDir);
 
    //2. ÈÕÖ¾ÐÅÏ¢
    using MsgLogEvent = void(*)(int level, std::string strText);
 
 
public:
    IVisionEvent(MsgReceivedEvent msgRcvCb = nullptr, MsgLogEvent msgLogEvent = nullptr) {
        /* code */
        m_msgRcvCb = msgRcvCb;
        m_msgLogCb = msgLogEvent;
    };
 
    void clear() {
        /* code */
        m_msgRcvCb = NULL;
        m_msgLogCb = NULL;
    }
public:
    MsgReceivedEvent m_msgRcvCb = NULL;
    MsgLogEvent m_msgLogCb = NULL;
};
 
class ISoftVisionApp
{
public:
    virtual ~ISoftVisionApp() {};
 
public:
    //1. ´ò¿ªÊÓ¾õ´°Ìå
    virtual int OpenVisionWindow(void) = 0;
    virtual CDialogEx* CreateVisionWindow(void) = 0;
    virtual int ReleaseWindow(CDialogEx *pDlg) = 0;
    virtual void ChangeDimension(CDialogEx *pDlg, int nDir) = 0;
    virtual void SetVisionOpen(BOOL isOpen) = 0;
 
    //2. ÉèÖÃÆÁ±Î
    virtual void OpenKeySetWindow(void) = 0;
 
    //3. ×ø±êת»»
    virtual Point2I getPose(int eDir, int xPoxPxl, int yPosPxl) = 0;
 
    //4. Ö´ÐÐÊÓ¾õ´¦Àí
    virtual int Execute(int eDir, NgInfo *ngArray) = 0;
 
    //5. ÉèÖûص÷ʱ¼ä
    virtual void setImageEventSignal(IVisionEvent *pEvent) = 0;
 
    //6. ×ø±êת»»£¬Í³Ò»×ø±êϵͳ
    virtual bool transformToStandard(int eDir, Point2I point, Point2I &result,  Point2I &topResult, Point2I &botResult) = 0;
 
    //7. ¼ì²âCutÏß
    virtual bool findCutLine(int eDir, int toTopY, int toLineDist, int nEndThres, Point2I &result) = 0;
    virtual double DistancePL(Point2D pose, Line2D line) = 0;
 
    //8. ¼ì²âNorchȱÏÝ    
    virtual int findNorchDefect(int eDir, std::vector<Point2D> vPoints, CRect roiRect, int nThres, int nOffset, int nBinThres,
        int szType, int xFzSize, int yFzSize, CRect* aryResult) = 0;
};
 
#endif