SDC C-Project CF Review 프로그램
LYW
2021-07-08 9cbd9e554f9956b3b945b51602f1d4a3fa0353e1
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
#pragma once
 
#include "Pad.h"
#include "AssemDefect.h"
 
 
enum ConvMode        { ConvMode_Float = 0, ConvMode_Pixel, ConvMode_Binalize, ConvMode_CompAvg };
enum ConvDir        { ConvDir_Hori= 0, ConvDir_Vert= 1, ConvDir_Double= 2};
 
#define        MAX_DEAD_ZONE_COUNT        10
 
class AFX_EXT_CLASS CConvParam
{
public:
    virtual ~CConvParam() {}
 
public:
    // 1.1. °Ë»ç ¹æ¹ý °ü·Ã
    ConvMode    m_ConvMode;        // 0 = ConvFloat(2*2), 1 = ConvPixel(1*1)
    int            m_ConvDir;        // 0 = Horizontal, 1= Vertical, 2, Hori and Vert
    int            m_ReinspectCount;        // Frame Overflow½Ã Àç°Ë»ç È¸¼ö
    BOOL        m_bZone2B2;                // Zone 2 By 2 °Ë»ç
    BOOL        m_bIntrinsic;
    BOOL        m_bSkipBlock;            // ÀÌÇü¼¿.
 
    // 1.2. °Ë»ç À̹ÌÁö Á¤º¸
    LPBYTE        s_lpBuffer;                // * °Ë»çÇÒ ¹öÆÛ
    int            s_nFrameWidth;            // * °Ë»ç À̹ÌÁö ³ÐÀÌ
    int            s_nFrameHeight;            // * °Ë»ç À̹ÌÁö ³ôÀÌ.
 
    // 1.3. °Ë»ç ¿µ¿ª Á¤º¸.
    CTrapezium    m_Trapezium;            // »ç´Ù¸®²Ã °Ë»ç ¿µ¿ª
    CRect        s_RectConv;                // * ¹öÆÛ¿¡¼­ ¿¬»êÇÒ »ç°¢Çü
    CRect        s_RectFilter;            // * ¹öÆÛ¿¡¼­ ÇÊÅ͸µ¿¡ ¾²ÀÏ ¼ö Àִ »ç°¢Çü(¿ø·¡ ¼¿Å©±â µî °¡´É)
    CRect        s_RectDeadZone[MAX_DEAD_ZONE_COUNT];
    CPoint*        m_pptFreeForm;            // ´Ù°¢Çü °Ë»ç ¿µ¿ª Æ÷ÀÎÆ® Á¤º¸
    int            m_nFFPointCount;        // ´Ù°¢Çü °Ë»ç ¿µ¿ª Æ÷ÀÎÆ® °³¼ö
 
    // 1.5. Convolution Á¤º¸.
    int            s_nConvWidth;            // * °Ë»ç ´ÜÀ§ ³ÐÀÌ
    int            s_nConvHeight;            // * °Ë»ç ´ÜÀ§ ³ôÀÌ
 
    double        s_dPitchConvReal;        // * °Ë»ç ÇÇÄ¡
    int            s_nPitchCycleConv;        // ÇÑ ¼¿ÀÇ ÇÇÄ¡
    double        s_dPitchScanReal;        // * °Ë»ç ÇÇÄ¡
    int            s_nPitchCycleScan;        // ÇÑ ¼¿ÀÇ ÇÇÄ¡
 
    float        m_fTilt;                // tilt °ª.
 
    // 1.6. ¹®Åΰª Á¤º¸.
    int            s_nThreshold;            // * ¸ÞÀΠ¹®Åΰª
    int            s_nDThSlide;        // Dynamic Threshold ±â¿ï±â
    int            s_nThresholdSupress;    // Suppress ¹®Åΰª.
    int            s_nSideThreshold;        // ÁÂ/¿ì/Unpair °Ë»ç ¹®Åΰª
    int            s_nBWB_Main;        // Black °áÇÔ ¾î¼À¿¡¼­ÀÇ ÇÊÅ͸µ DTh(ConvPixel VertSBW, VTDSBW¸¸ ±¸Çö), 0À̸頾Ⱦ¸.
    int            s_nBWB_Slide;        // Black °áÇÔ ¾î¼À¿¡¼­ÀÇ ÇÊÅ͸µ DTh(ConvPixel VertSBW, VTDSBW¸¸ ±¸Çö)
 
    // 1.7. °Ë»ç Process Á¤º¸.
    BOOL        m_bEchoConvolution;    // ¿¬»ê ¼Óµµ ºÎÁ·À¸·Î ¾î¼À ³»ºÎ¿¡¼­ Thread ºÐÇÒ °Ë»ç ¿©ºÎ.
    BOOL        m_bVertSpeedup;        // Pixel°ú Zone ¼Óµµ ºÎÁ·À¸·Î °Ë»ç ·çƾÀÇ ¸Þ¸ð¸® ÀçÇØ¼® ¿©ºÎ
    BOOL        m_bSelectiveDir;    // ¿¬»ê ¹æÇâ¿¡¼­ 3ÇÇÄ¡ ºÎÁ·½Ã ¿¬»ê¹æÇâÀ» cross ¹æÇâÀ¸·Î º¯°æÈÄ °Ë»ç ÇÒÁö ¿©ºÎ.
    BOOL        m_bUseUnpair;            // Left¿Í RightÀÇ Unpair °áÇÔÀ» AssemÀÇ Pairing ´Ü°è¿¡¼­ »Ì¾Æ ³¿(TRUE) or ¹ö¸²(FALSE). ±âº» TRUE;
    BOOL        s_bReverseFilter;        // ReverseFilter »ç¿ë ¿©ºÎ
    int            m_EdgeFilterTh;            // ¼¿ Edge ¿µ¿ª¿¡¼­ ´ÜÁÖ±â ÇÊÅÍ Àû¿ëÇÒ ¼ö ¾ø´Â ±¸°£À» À§ÇÑ Ãß°¡ Th
 
    // 1.8. Dynamic Pitch Á¤º¸
    int            *m_pPitch16;    // pitch¸¦ 16¹è Çؼ­ subpixel±îÁö Ç¥Çö, TrapeziumÀÌ¿ÜÀÇ Rect¿¡¼­´Â Vertical ¹æÇâÀÌ´Ù.
    short        *m_pPitch;        // Dynamic Pitch. Horizontal ¹æÇâÀ̰í
    short        *m_pfSPR;        // Dynamic Pitch. Horizontal ¹æÇâÀ̰í, Sub Pixel
    short        *m_psSPR;        // Dynamic Pitch. Horizontal ¹æÇâÀ̰í, Sub Pixel
    BOOL        m_bUseDPC;
 
    // 1.9. Zone Threshold °Ë»ç Á¤º¸
    BOOL        m_bZoneMulti;            // Zone Multi Threshold °Ë»ç Àû¿ë ¼±ÅÃ.
    short*        s_psZoneTable;                // Zoneº° ThresholdingÀ» À§ÇÑ Index Table
    short*        s_psZoneThTable;            // Zoneº° ThresholdingÀ» À§ÇÑ Threshold Table
    short*        s_psZoneAddTable;            // Zoneº° ThresholdingÀ» À§ÇÑ DynamicThreshold Table
    short*        s_psZoneMThTable;        // 2Áß ZoneThresholdÀÇ µÎ¹øÂ° Base Threshold
    short*        s_psZoneMAddTable;        // 2Áß ZoneThresholdÀÇ µÎ¹øÂ° Threshold Slope
    short*        s_psZoneMMinTable;            // 2Áß ZoneThresholdÀÇ 2¹øÂ° Á÷¼±À» À§ÇÑ ÀÓ°èÄ¡(Çȼ¿ ¹à±â), 2Áß ZoneThresholdÀû¿ë ¿©ºÎÀÇ ±¸ºÐÀÚ ¿ªÇÒµµ °âÇÔ.
    int            s_nThresTableWidth;        // Threshold Table ³ÐÀÌ
    int            s_nThresTableHeight;    // Threshold Table ³ôÀÌ
    int            s_nThresTableStartX;    // XÃà ½ÃÀÛ Offset
    int            s_nThresTableStartY;    // YÃà ½ÃÀÛ Offset
    void*        m_pGammaTable;            // Zone Threshold µÎ¹øÂ° ¹öÀüÀ¸·Î ¸ÅĪ Å×À̺í Á¤º¸ º¸°ü.
    int            m_nGammaXCount;            // Gamma TableÀÇ X, Y ¹è¿­ÀÇ XÃà ¸ÅĪÆ÷ÀÌÆ® Ä«¿îÆ®(°³¼ö)
    int            s_nZoneCycleConv;        // Zone Reference À̹ÌÁöÀÇ ±âº»Áֱ⠹è¼ö
    int            s_nZoneCycleScan;        // Zone Reference À̹ÌÁöÀÇ ±âº»Áֱ⠹è¼ö
    int*        m_pFilterThBlack;
    int*        m_pFilterThBlack2;
    int*        m_pFilterThWhite;
    int*        m_pFilterThWhite2;
    int*        m_pSpeedZoneTh;
    int*        m_pSpeedZoneThSlide;
 
    // 2.0 CompareAverage Filter Size
    int            m_nBFilterSize;
    int            m_nDFilterSize;
 
 
    int            GetFilterThreshold(int iZone, int pixel, DefectType Type)
    {
        if(Type == DEFTYPE_WHITE)
            return ((m_pFilterThWhite2[iZone]*pixel)>>8)+ m_pFilterThWhite[iZone];
 
        return ((m_pFilterThBlack2[iZone]*pixel)>>8)+ m_pFilterThBlack[iZone];
    }
 
 
    //==================================
    // Assem ÀÌ ³¡³­ ÈÄ󸮿͠°ü·ÃµÈ Á¤º¸.
 
    // 2.1.  °áÇÔ °ü¸® Á¤º¸.
    int            s_nFrameDefPixLimit;    // ÇÑ Frame¿¡¼­ÀÇ ÃÖ´ë °áÇÔ Çȼ¿ ¼ö
    int            s_nFrameDefBlobLimit;    // ÇÑ Frame¿¡¼­ÀÇ ÃÖ´ë °áÇÔ ¼ö
 
    // 2.2. Çȼ¿ ´Ü°è ÇÊÅ͸µ Á¤º¸.
    BOOL        m_bUsePixelFilter;        // Pixel´Ü°è¿¡¼­ ÇÊÅ͸µÀ» ÇÒ °ÍÀΰ¡ ¸» °ÍÀΰ¡?
    BOOL        m_bUseMarginFilter;        //
    BOOL        m_bOnlyJumpFilter;        // °Ë»ç ÃàÀÇ Cross ¹æÇâÀ¸·Î ÇÊÅ͸µ ¾øÀÌ JumpFiltering¸¸ ÇÒ °ÍÀΰ¡ .or. CrossFilter¸¦ ÇÒ °ÍÀΰ¡.
    BOOL        m_bPairFilter;            // Pair °áÇÔ¿¡µµ Cross&Jump ÇÊÅÍ Àû¿ë.
 
    // 2.2 Zone Measure Filter // Æ¯Á¤ Á¸¿¡ ´ëÇØ ¹Ì¼¼ ¿µ¿ª Àç ¸ÅĪÈÄ ´Ù½Ã °Ë»ç ÇÊÅÍ Àû¿ë.
    BOOL        m_bTiltFilter;
 
    // 2.3. ÈÄ󸮠Á¤º¸.
    int            m_nDefectMergePixel;    // µðÆå ¸ÓÁö »çÀÌÁî
 
    // 2.4. Zone Sorting, Thresholding
    BYTE*        s_pZoneData;            // Zone Sort Table
    BYTE*        s_pZoneThreshold;        // Zone Threshold Table
    int            s_nZoneDataWidth;        // Zone Sort Table ³ÐÀÌ
    int            s_nZoneBufferWidth;        // Zone Data ¹öÆÛÀÇ À̹ÌÁö ¹öÆÛ Å©±â.
    int            s_nZoneDataHeight;        // Zone Sort Table ³ôÀÌ
 
    // 2.5. °áÇÔ Á¤º¸ °¡°ø Á¤º¸.
    double        s_dScanResolution;        // Scan Resolution
    double        s_dConvResolution;        // Conv Resolution
 
 
 
    //======================================
    // 99. ¾È ¾²Áö¸¸ °³³ä»ó Áö¿ìÁö ¾ÊÀ» °Íµé.
    short        s_sSkipSave;            // °Ë»ç ÈÄ À̹ÌÁö ÀúÀå ¿©ºÎ
    UINT        s_uiProcessing;            // * °Ë»ç ¹æ¹ý
    int            s_nRegionType;            // ¿µ¿ª - ¼³Á¤µÈ °ªÀ» °áÇÔ¿¡ ¾²±â À§ÇÔ
 
    // ¼¼ÄÁ°Ë»ç Param
    BOOL        s_bUse2ndInspection;
    int            s_n2ndThres;
    int            s_n2ndThresSlide;
    double        s_d2ndPitch;
 
 
    // Add by PJH
    int            s_nASGDynamicHi;
    int            s_nASGDynamicLow;
 
    // 99. ±âŸ Àâ´Ù±¸¸®
    // 200090612 size choigudal
    BOOL        s_bUseTrimmer;
    int            s_nTrimmerWidth;
    int            s_nTrimmerHeight;
 
 
    // 20150811 °Å´ë CS
    int            m_nCSThres[MAX_ZONE_NUM];
    int            m_nOriThres[MAX_ZONE_NUM];
 
    //Á¸°Ë»ç °ËÁõ ÅÂÇö[2018/6/5]
    double        m_nZoneVeriPitch[MAX_ZONE_NUM];
    double        m_nZoneVeriPitchVert[MAX_ZONE_NUM];
    int            m_nZoneVeriConvDir[MAX_ZONE_NUM];//0: Off , 1:hori, 2:vert, 3: both
 
    CConvParam()
    {
        Reset();
    }
 
    double    GetRealConvPitch(){return s_dPitchConvReal*s_nPitchCycleConv;}
    double    GetRealScanPitch(){return s_dPitchScanReal*s_nPitchCycleScan;}
    double    GetZoneConvPitch(){return s_dPitchConvReal*s_nZoneCycleConv;}
    double    GetZoneScanPitch(){return s_dPitchScanReal*s_nZoneCycleScan;}
 
    void Reset()
    {
        // 1.1. °Ë»ç ¹æ¹ý °ü·Ã
        m_ConvMode                    = ConvMode_Float;
        m_ConvDir                    = 0;
        m_ReinspectCount            = 3;
        m_bZone2B2                    = FALSE;
        m_bIntrinsic                = FALSE;
        m_bSkipBlock                = FALSE;
 
        // 1.2. °Ë»ç À̹ÌÁö Á¤º¸
        s_lpBuffer                    = NULL;
        s_nFrameWidth                = 0;
        s_nFrameHeight                = 0;
 
        // 1.3. °Ë»ç ¿µ¿ª Á¤º¸.
        s_RectConv.SetRect(0, 0, 0, 0);
        s_RectFilter= s_RectConv;
        for(int i = 0 ; i < MAX_DEAD_ZONE_COUNT; i++)
            s_RectDeadZone[i].SetRectEmpty();
        m_pptFreeForm                = NULL;
        m_nFFPointCount                = 0;
 
        // 1.5. Convolution Á¤º¸.
        s_nConvWidth                = 0;
        s_nConvHeight                = 0;
 
        s_dPitchConvReal            = 0.0;
        s_nPitchCycleConv            = 0;
        s_dPitchScanReal            = 0.0;
        s_nPitchCycleScan            = 0;
 
        m_fTilt                        = 0.0;
 
        // 1.6. ¹®Åΰª Á¤º¸.
        s_nThreshold                = 10;
        s_nDThSlide                    = 20;
        s_nThresholdSupress            = 255;
        s_nSideThreshold            = 0;
        s_nBWB_Main                    = 0;
        s_nBWB_Slide                = 0;
 
        // 1.7. °Ë»ç Process Á¤º¸.
        m_bEchoConvolution            = TRUE;
        m_bVertSpeedup                = TRUE;
        m_bSelectiveDir                = FALSE;
        m_bUseUnpair                = TRUE;
        s_bReverseFilter            = FALSE;
        m_EdgeFilterTh                = 0;
 
        // 1.8. Dynamic Pitch Á¤º¸
        m_pPitch16                    = NULL;
        m_pPitch                    = NULL;
        m_pfSPR                        = NULL;
        m_psSPR                        = NULL;
        m_bUseDPC                    = TRUE;
 
 
        // 1.9. Zone Threshold °Ë»ç Á¤º¸
        m_bZoneMulti                = FALSE;
        s_psZoneTable                = NULL;    //0617 Ãß°¡
        s_psZoneThTable                = NULL;
        s_psZoneAddTable            = NULL;
        s_psZoneMThTable            = NULL;
        s_psZoneMAddTable            = NULL;
        s_psZoneMMinTable            = NULL;
        s_nThresTableWidth            = 12000;
        s_nThresTableHeight            = 1024;
        s_nThresTableStartX            = 0;
        s_nThresTableStartY            = 0;
        m_pGammaTable                = NULL;
        m_nGammaXCount                = 300;
        s_nZoneCycleConv            = 1;
        s_nZoneCycleScan            = 1;
        m_pFilterThBlack            = NULL;
        m_pFilterThBlack2            = NULL;
        m_pFilterThWhite            = NULL;
        m_pFilterThWhite2            = NULL;
        m_pSpeedZoneTh                = NULL;
        m_pSpeedZoneThSlide            = NULL;
 
        m_nBFilterSize                = 45;
        m_nDFilterSize                = 9;
 
        //==================================
        // Assem ÀÌ ³¡³­ ÈÄ󸮿͠°ü·ÃµÈ Á¤º¸.
 
        // 2.1.  °áÇÔ °ü¸® Á¤º¸.
        s_nFrameDefPixLimit            = 10000;//MAX_DEFECTPIX_NUM;
        s_nFrameDefBlobLimit        = 10000;//MAX_DEFECTBLOB_NUM;
 
        // 2.2. ÇÊÅ͸µ Á¤º¸.
        m_bUsePixelFilter            = TRUE;
        m_bOnlyJumpFilter            = FALSE;
        m_bPairFilter                = FALSE;
        m_bUseMarginFilter            = TRUE;
 
        // 2.2. Zone Measure Filter // Æ¯Á¤ Á¸¿¡ ´ëÇØ ¹Ì¼¼ ¿µ¿ª Àç ¸ÅĪÈÄ ´Ù½Ã °Ë»ç ÇÊÅÍ Àû¿ë.
        m_bTiltFilter                = FALSE;
 
        // 2.3. ÈÄ󸮠Á¤º¸.
        m_nDefectMergePixel            = 4;// ¸ÓÁö 4 Çȼ¿
 
        // 2.4. Zone Sorting, Thresholding, Zone ThresholdingÀÏ ¶§ÀÇ Zone Á¤º¸, RSCale ÃßÃâÀ» À§ÇÑ °ªµé
        s_pZoneData                    = NULL;
        s_pZoneThreshold            = NULL;
        s_nZoneDataWidth            = 0;
        s_nZoneBufferWidth            = 0;
        s_nZoneDataHeight            = 0;
 
        // 2.5. °áÇÔ Á¤º¸ °¡°ø Á¤º¸.
        s_dScanResolution            = 0.0;
        s_dConvResolution            = 0.0;
 
        //======================================
        // 99. ¾²´ÂÁö ¾È ¾²´Â Áö ¸ð¸£´Â °Í.
        s_sSkipSave                    = 0;
        s_uiProcessing                = 0;
        s_nRegionType                = -1;
 
        //¼¼ÄÁµå °Ë»ç
        s_bUse2ndInspection            = FALSE;
        s_n2ndThres                    = 255;;
        s_n2ndThresSlide            = 0;
        s_d2ndPitch                    = 0;
 
        // Add by PJH
        s_nASGDynamicHi                = 0;
        s_nASGDynamicLow            = 0;
 
        // 200090612 size choigudal
        s_bUseTrimmer                = FALSE;
        s_nTrimmerWidth                = 0;
        s_nTrimmerHeight            = 0;
        //.
        // 20150811 °Å´ë CS
        for(int i = 0; i < MAX_ZONE_NUM; i++)
        {
            m_nCSThres[i] = 0;
            m_nOriThres[i] = 0;
 
            m_nZoneVeriPitch[i] = 0;
            m_nZoneVeriPitchVert[i] = 0;
            m_nZoneVeriConvDir[i] = 0;
        }
        
 
    }
 
    BOOL IsAllInspected(int endLine)
    {
        if(m_ConvDir == ConvDir_Hori)
            return s_RectConv.bottom - endLine < 16;
        return s_RectConv.right - endLine < 16;
    }
};