SDC C-Project CF Review 프로그램
LYW
2021-10-14 26e2541b87ca76e16cf69399eb9a3cce62d2e864
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
#pragma once
 
#include <vector>
 
#define ALIGN_MARK_WIDTH    100
#define ALIGN_MARK_HEIGHT    100
 
struct SAlignFindParam
{
    SAlignFindParam() 
    {    
        Reset();
    }
 
    void Reset()
    {
        // match
        bMatchProcess            = TRUE;
        dMatchRate                = 0.8;
        dMatchingPixelStandard  = 0;
        dMatchingAlarmCondition = 0;
 
        // edge
        bEdgeProcess            = TRUE;
        nAlignWidth                = ALIGN_MARK_WIDTH;
        nAlignHeight            = ALIGN_MARK_HEIGHT;
        nEdgeThreshold            = 50;
        nMergeRange                = 5;
        dEdgeRate                = 0.8;
        nKernelSize                = 5;
 
        // corner
        nCorner_DirType            = 0;    // lefttop, leftbottom, righttop, rightbottom 
        nCorner_SobelKernelSize = 3;
        nCorner_EdgeKernelSize    = 5;
        nCorner_EdgeThreshold    = 80;
        nCorner_IgnorePixel        = 20;
 
        // thickness
        bMeasureThickness        = FALSE;
        nEDThicknessLR            = 25;
        nEDThicknessTB            = 25;
        nEDThicknessRange        = 10;
    }
 
    // match
    BOOL    bMatchProcess;
    double    dMatchRate;
    /*< LYW 20211014 - #3671 ADD Start >*/
    int        dMatchingPixelStandard;
    int        dMatchingAlarmCondition;
    /*< LYW 20211014 - #3671 ADD End >*/
 
    // edge 
    BOOL    bEdgeProcess;
    int        nAlignWidth;
    int        nAlignHeight;
    int        nEdgeThreshold;
    double    dEdgeRate;
    int        nMergeRange;
    int        nKernelSize;
 
    // corner
    int        nCorner_DirType; 
    int        nCorner_SobelKernelSize;
    int        nCorner_EdgeKernelSize;
    int        nCorner_EdgeThreshold;
    int        nCorner_IgnorePixel;
 
    // thickness
    BOOL    bMeasureThickness;
    int        nEDThicknessLR;
    int        nEDThicknessTB;
    int        nEDThicknessRange;
 
};
 
enum AlignProcess_Type    { AlignProcess_Match=0, AlignProcess_Edge };
enum AlignMatch_Result    { AlignMatch_None=0, AlignMatch_NoTemplate, AlignMatch_NotOneChannels, AlignMatch_MatchFail, AlignMatch_LowScore, AlignMatch_Success };
enum AlignEdge_Result    { AlignEdge_None=0, AlignEdge_EdgeFail, AlignEdge_BinaryFail, AlignEdge_BlobFail, AlignEdge_LowScore, AlignEdge_Success };
 
struct SThicknessResult
{
    SThicknessResult()
    {
        Reset();
    }
 
    void Reset()
    {
        rtSizeL.SetRect(-1,-1,-1,-1);
        rtSizeT.SetRect(-1,-1,-1,-1);
        rtSizeR.SetRect(-1,-1,-1,-1);
        rtSizeB.SetRect(-1,-1,-1,-1);
    }
 
    BOOL IsAllSuccess()
    {
        return rtSizeL.top != -1
            && rtSizeL.bottom != -1
            && rtSizeR.top != -1
            && rtSizeR.bottom != -1
            && rtSizeT.left != -1
            && rtSizeT.right != -1
            && rtSizeB.left != -1
            && rtSizeB.right != -1;
    }
 
    CRect rtSizeL, rtSizeT, rtSizeR, rtSizeB;
};
 
struct SAlignFindResult
{
    SAlignFindResult() 
    {    
        Reset();
    }
 
    void Reset()
    {
        nResultCode = 0;
        nResultProcess = 0;
        dMatchValue = 0;
        dPosX = 0;
        dPosY = 0;
 
        sThicknessResult.Reset();
    }
 
    int                    nResultCode;
    int                    nResultProcess;
    double                dMatchValue;
    double                dPosX;
    double                dPosY;
 
    SThicknessResult    sThicknessResult;
};
typedef std::vector<SAlignFindResult>                VectorAlignFindResult;
typedef std::vector<SAlignFindResult>::iterator        VectorAlignFindResultIt;
 
struct SPixelBlob
{
    SPixelBlob()    
    { 
        Reset(); 
    }
 
    SPixelBlob(int left, int top, int right, int bottom)
    {
        dMatchValue = 0.0;
        nLeft    = left;
        nTop    = top;
        nRight    = right;
        nBottom = bottom;
        vectorPoint.clear();
        sThicknessResult.Reset();
    }
 
    void Reset()
    {
        dMatchValue = 0.0;
        nLeft    = INT_MAX;
        nTop    = INT_MAX;
        nRight    = INT_MIN;
        nBottom = INT_MIN;
        vectorPoint.clear();
        sThicknessResult.Reset();
    }
 
    int        GetSquareSize()    const    { return (nRight-nLeft+1) * (nBottom-nTop+1); }
    int        GetWidth() const        { return (nRight-nLeft+1); }
    int        GetHeight() const        { return (nBottom-nTop+1); }
    int        GetCenterX() const        { return nLeft + (nRight - nLeft + 1) / 2; }
    int        GetCenterY() const        { return nTop + (nBottom - nTop + 1) / 2; }
    int        GetMaxSize() const        { return (GetWidth() < GetHeight()) ? GetHeight(): GetWidth(); }
    int        GetMinSize() const        { return (GetWidth() > GetHeight()) ? GetHeight(): GetWidth(); }
    size_t    GetPixelCount()    const    { return vectorPoint.size(); }
 
    double                dMatchValue;
    int                    nLeft;
    int                    nTop;
    int                    nRight;
    int                    nBottom;
    std::vector<CPoint> vectorPoint;
    SThicknessResult    sThicknessResult;
};
typedef std::vector<SPixelBlob>                VectorPixelBlob;
typedef std::vector<SPixelBlob>::iterator    VectorPixelBlobIt;