SDC C-Project CF Review 프로그램
LYW
2022-06-30 c220de6f70051797e9d8b371830d06def9dc9cbd
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
419
420
421
422
423
424
425
426
427
428
429
#pragma once
 
#include <vector>
#include "Singleton.h"
 
struct _DefectDisplayOption //±×³É ¿©±â¿¡ ¸¸µéÀÚ..;; ÇØ´õ Çϳª´õ ÆÄ±â ±ÍÂù..
{
    _DefectDisplayOption()
    {
        m_bShowDefectNormal = TRUE;
        m_bShowDefectGroupRound = TRUE;
        m_bShowDefectGroupLine = TRUE;
        m_bShowNoFilteredDefect = FALSE;
 
        m_nShowLabel = -1;
        m_nShowSize = 0;
    }
    BOOL m_bShowDefectNormal;
    BOOL m_bShowDefectGroupRound;
    BOOL m_bShowDefectGroupLine;
    BOOL m_bShowNoFilteredDefect;
 
    int m_nShowLabel; // 0º¸´Ù ÀÛÀ¸¸é ¸ðµÎ º¸±â
    int m_nShowSize; //ÇØ´ç°ªº¸´Ù À۰ųª °°À¸¸é Á¦°Å
};
 
struct _akDefect
{
    int nDefectID;
    double dPositionX;
    double dPositionY;
 
    int nLabel;
    
    int nSize; //
    int nType;//0:black defect, 1:white defect
 
    int nGraySrc;
    int nGrayTar;
    int nGrayDiff;
 
    int nFilter;//1À̸é Á¦¿Ü
    //("SIZE_S");
    //("SIZE_W"); 
   //("SIZE_L"); 
   //("SIZE_H"); 
   //("DEFECT_CODE"); 
   //("DEF_AVG_1");
   //("REF_AVG_1");
   //("REF_GRAY_1");
   //("MASK_DEFECT");
   //("COMMON_DEFECT");
   //("XY_RATIO");
   //("CAM_NUM");
   //("LAMP_VALUE");
    CString m_strInfos[16];    
 
    short            m_nDefectID;
    short            m_nCameraID;
    short            m_nScanIdx;
    //short            m_nDefectIdx;                // Ä«¸Þ¶ó¿¡¼­ÀÇ °áÇÔ À妽º
    int                m_nDefectIdx;                // Ä«¸Þ¶ó¿¡¼­ÀÇ °áÇÔ À妽º 201207 CJH - ÀÚ¸´ ¼ö ³Ñħ. intÇüÀ¸·Î º¯°æ
 
    int                m_nPixelConv;                // pixel ´ÜÀ§ ÁÂÇ¥
    int                m_nPixelScan;                // pixel ´ÜÀ§ ÁÂÇ¥
 
    short                            m_nPixelSize;                // °áÇÔÅ©±â        ---------------------------------PS
    short/*SERVER_DefectType*/        m_DefectType;                // °áÇԠŸÀÔ    ---------------------------------DT
    short/*SERVER_DefectSubType*/    m_DefectSubType;            // °áÇÔÀÇ ÆÇÁ¤»óÅÂ.
    short/*SERVER_DefectBDType*/    m_DefectBDType;                // °áÇԠŸÀÔ - Bright, Dark, Both
 
    short            m_sPixelWidth;                // Çȼ¿´ÜÀ§ °áÇÔ ³Êºñ
    short            m_sPixelHeight;                // Çȼ¿´ÜÀ§ °áÇÔ ³ôÀÌ
    short            m_nLevelSrcMin;                // °áÇÔ ¹à±â Min    -----------------------------SN
    short            m_nLevelSrcMax;                // °áÇÔ ¹à±â Max    -----------------------------SX
    short            m_nLevelSrcAvg;                // °áÇÔ ¹à±â Avg    -----------------------------SA
    short            m_nLevelRefMin;                // ºñ±³´ë»ó ¹à±â Min    -------------------------RN
    short            m_nLevelRefMax;                // ºñ±³´ë»ó ¹à±â Max    -------------------------RX
    short            m_nLevelRefAvg;                // ºñ±³´ë»ó ¹à±â Avg    -------------------------RA
    short            m_nLevelDiffMin;            // ºñ±³Â÷ Min    ---------------------------------DN
    short            m_nLevelDiffMax;            // ºñ±³Â÷ Max    ---------------------------------DX
    short            m_nLevelDiffAvg;            // ºñ±³Â÷ Avg    ---------------------------------DA
 
    int                m_nDefectRScale;            // Çȼ¿´ÜÀ§ °áÇÔ ³ôÀÌ    -------------------------RS
    short            m_sThreshold;                // °áÇÔÀ» °ËÃâÇÒ ¶§ÀÇ Threshold
    short            m_sThresholdAvg;            // °áÇÔÀ» °ËÃâÇÒ ¶§ÀÇ Threshold AVG
    short            m_sDefectPeak;                // °áÇÔÀÇ Peak.
    short            m_sDefectLevel;                // (DiffAvg - Th) BOE 8G ¿äû»çÇ×
 
    int                m_nPixelGlassStart;            // Glass ½ÃÀÛ Çȼ¿
    short            m_sDefectLoc;
 
    short            m_sZonePixelCount[16];    // Zoneº° °áÇÔ Pixel ¼ö
    short            m_sZoneValueMin[16];    // Zoneº° °áÇÔ Min
    short            m_sZoneValueMax[16];    // Zoneº° °áÇÔ Max
    short            m_sZoneValueAvg[16];    // Zoneº° °áÇÔ Avg
    short            m_sZonePixelPercent[16];    // --------------------------------------Z0~ZF
 
    //210127 CJH - Zoneº° Source Gray ÀÔ·Â
    short            m_sZoneValueSrcMin[16];    // Zoneº° Source Min
    short            m_sZoneValueSrcMax[16];    // Zoneº° Source Max
    short            m_sZoneValueSrcAvg[16]; // Zoneº° Source Avg
 
    int                m_nUMOriginX;                // um´ÜÀ§ xÁÂÇ¥ (¿øÁ¡±âÁØ)
    int                m_nUMOriginY;                // um´ÜÀ§ yÁ¶Ç¥ (¿øÁ¡±âÁØ)
    int                m_nUMCenterAlignX;            // um´ÜÀ§ XÁÂÇ¥ (Glass Center ±âÁØ, ¾ó¶óÀκ¸Á¤ ÈÄ)
    int                m_nUMCenterAlignY;            // um´ÜÀ§ YÁÂÇ¥ (Glass Center ±âÁØ, ¾ó¶óÀκ¸Á¤ ÈÄ)
    int                m_nUMCenterX;                // um´ÜÀ§ XÁÂÇ¥ (Glass Center ±âÁØ, ¾ó¶óÀκ¸Á¤ Àü)
    int                m_nUMCenterY;                // um´ÜÀ§ YÁÂÇ¥ (Glass Center ±âÁØ, ¾ó¶óÀκ¸Á¤ Àü)
    int                m_nUMSizeX;                    // um´ÜÀ§ X Å©±â    -----------------------------UX
    int                m_nUMSizeY;                    // um´ÜÀ§ Y Å©±â    -----------------------------UY
    int                m_nUMSize;                    // um´ÜÀ§ Å©±â.
    CRect            m_RectUM;                    // µðÆå ¼¾ÅÍ ±âÁØ »ç°¢Çü.
 
    short/*SERVER_DefectSizeType*/    m_DefectSizeType;            // °áÇÔ Å©±â Á¾·ùenum SERVER_DefectSizeType        { SizeType_Unknown = 0, SizeType_Small, SizeType_Mid, SizeType_Large, SizeType_Huge, SizeType_Ultra };
    short/*SERVER_DefectPeakType*/    m_DefectPeakType;            // PeakÀÇ Á¾·ù.
    short/*Judgement*/                m_DefectJudgement;            // °áÇÔ ÆÇÁ¤.
    BOOL                    m_bDefectCutoff;            // ÄÆ ¿ÀÇÁ µðÆå(TRUE= Cutoff, FALSE)
    short/*MAP16_DefectClass*/        m_DefectClass;                // BOE Defect Class 16µîºÐ ±¸ºÐ
    int                m_nPadRegionIdx;            // PAD ¿µ¿ª À妽º
 
    int                m_nUMCellX;                    // ¼¿ ¿øÁ¡ ±âÁØ x ÁÂÇ¥
    int                m_nUMCellY;                    // ¼¿ ¿øÁ¡ ±âÁØ y ÁÂÇ¥
    short            m_nModelIdx;                // ¸î ¹øÂ° ¸ðµ¨Àΰ¡?
    short            m_nCellIdx;                    // ¸î¹øÂ° ¼¿Àΰ¡?
    short            m_nCellGate;                // ¼¿º° Gate¶óÀÎ(¾ó¶óÀΠº¸Á¤ Àü)
    short            m_nCellData;                // ¼¿º° Data¶óÀÎ(¾ó¶óÀΠº¸Á¤ Àü)
    short            m_nCellGateAlign;            // ¼¿º° Gate¶óÀÎ(¾ó¶óÀΠº¸Á¤ ÈÄ)
    short            m_nCellDataAlign;            // ¼¿º° Data¶óÀÎ(¾ó¶óÀΠº¸Á¤ ÈÄ)
 
    int                m_nUMShotX;                    // ¼¦ ±âÁØ XÁÂÇ¥
    int                m_nUMShotY;                    // ¼¦ ±âÁØ YÁÂÇ¥
    short            m_nMaskDefectIdx;            // ÇÑ Glass¿¡¼­ ¹ß°ßµÈ ¸¶½ºÅ©°áÇÔ ¹­À½ÀÇ À妽º.
    short            m_nShotIdx;                    // ³ë±¤¼¦ ¹øÈ£
    short            m_nMatchShotCount;            // µ¿ÀÏÇÑ ¸¶½ºÅ© °áÇÔÀÇ ¼ö.
    short            m_nMatchMaxSize;            // µ¿ÀÏÇÑ ¸¶½ºÅ© Áß °¡Àå Å« °áÇÔÀÇ Å©±â.
 
    short            m_nRepeatCount;                // ¿¬¼Ó°áÇԹ߰ßÀ§ÇÑ µ¿ÀÏÁÂÇ¥ ¹Ýº¹¼ö
    short            m_nMaskRepeatCount;
    int                m_StackInfo;                // Stack Flag
    BOOL            m_bRealStack;                // Stack ¸ÓÁö¿¡ ÀÇÇÑ TD(TRUE) ÀÎÁö, ÇÊÅ͸µ¿¡ ÀÇÇÑ TD(FALSE)±¸ºÐÇÒ ¼ö ÀÖ´Ù.
    short            m_nStackStepCount;            // Stack ¼ö
    short            m_nStackColorIdx;            // Color¸¦ ¼±ÅÃÇϴ À妽º.
    //CString            m_strStackStep[CFDEFECT_STACKCOUNT];            // Stack Step.
    char            m_strStackFirst[60];            // Stack Step. //201221 CJH - ÃÖ´ë »çÀÌÁî 60bytes
    char            m_strUnitID[16];                // À¯´Ö¾ÆÀ̵ð
 
    int                m_ClassificationType;                // enum ClassificationType            { ClassType_None= 0, ClassType_PI_Over= 1, ClassType_PI_Under= 2, ClassType_TFE_Circle= 3, ClassType_Bubble, ClassType_Scratch, ClassType_Particle}; Classification Type, PI³ª TFEµî Ãß°¡ ºÐ·ù  ¾Ë°í¸®Áò Àû¿ë °á°ú.
    int                m_nAtomWidth;                // TFE ÇÙ ³Êºñ
    int                m_nAtomHeight;                // TFE ÇÙ ³ôÀÌ
    short/*ReKind*/            m_DefectKind;                // °áÇÔ Á¾·ù
 
    char            m_strDefectCode[32];            // Defect Code
    BOOL            m_bMergeState;                // Merge Status
    char            m_strAoiImageName[256];            // Defect Image Name(CCD Image)
    CString            m_strReviewImageName;
    int                m_nDefectMerge;        // ÇöÀç µðÆåÀÇ ¸ÓÁö ¿©ºÎ
 
    int                m_nPixelSizeOrigin;
    int                m_nScratchRatio;
    int                m_nDensity;            // ¿øÇü °áÇÔ ±¸ºÐÀ» À§ÇÑ ¹Ðµµ [2017.8.2 bhs]
 
    char            m_strDefectName[16];
    char            m_strDefectType[16];
 
    double            m_dScanResolution;
    double            m_dConvResolution;
 
    int                m_nAngle;                    // °¢µµ
    int                m_nMajor;                    // ÀåÃà ±æÀÌ(Long)
    int                m_nMinor;                    // ´ÜÃà ±æÀÌ(Short)
    int                m_nCompact;                    // Blob ÀåÃàÀ» Áö¸§À¸·Î Çϴ ¿øÀÇ ³ÐÀ̿͠Blob ³ÐÀÌÀÇ ºñÀ²
    int                m_nThickness;                // Blob ³ÐÀ̿͠ÀåÃàÀÇ ºñÀ² (Area / Major)
 
    short            m_nHliLevelIdx;                // ¸î ¹øÂ° ·¹º§(ä³Î)Àΰ¡?
    int                m_nHliLayers;                // ÇØ´ç°áÇÔ¿¡ Æ÷ÇԵȠ·¹À̾î bitó¸®
 
    BOOL            m_bShrinked;                //210323 CJH - Frame Shrink Á¤º¸ Ãß°¡
};
 
struct _akModule
{
    int                m_nModuleIndex;
    int                m_nUMShotX;                    // ¼¦ ±âÁØ XÁÂÇ¥
    int                m_nUMShotY;                    // ¼¦ ±âÁØ YÁÂÇ¥
    int                m_nShotIndex;
};
 
struct _akShort
{
    int                m_nUMShotX;                    // ¼¦ ±âÁØ XÁÂÇ¥
    int                m_nUMShotY;                    // ¼¦ ±âÁØ YÁÂÇ¥
    int                m_nShotIndex;
};
 
struct _akReviewList
{
    short            m_nDefectID;
    int                m_nDefectIdx;                // Ä«¸Þ¶ó¿¡¼­ÀÇ °áÇÔ À妽º 201207 CJH - ÀÚ¸´ ¼ö ³Ñħ. intÇüÀ¸·Î º¯°æ
    int                m_nReviewIdx;
    char            m_strAoiImageName[256];            // Defect Image Name(CCD Image)
    CString            m_strReviewImageName;
    CString            m_strGlassID;
    char            m_strAoiImagePath[256];
    char            m_strReviewImagePath[256];
    char            m_strAlignFirst[64];
    char            m_strAlignSecond[64];
 
    CString m_strInfos[16];
};
 
struct _akGlassInfo
{
    int                m_nGlassSelect;
    CString            m_strPPID;
    CString            m_strGlassID;
    int                m_nDefectNum;
    int                m_nReviewNum;
    CString            m_strGlassJudge;
    CString            m_strLotID;
    CString            m_strSLotID;
    int                m_nSlot_No;
    int                m_nCellNum;
    int                m_nGlassSizeHeight;
    int                m_nGlassSizeWidth;
 
    CString m_strInfos[16];
};
 
struct _akReviewHeader
{
    short            m_nDefectID;
    int                m_nDefectIdx;
    CString            m_strGlassID;
    CString            m_strPPID;
    int                m_nReviewIdx;
    CString            m_strJudge;
    CString            m_strFileTime;
    CString            m_strFileName;
    CString            m_strLoading;
    CString            m_strFilePath;
    
    CString m_strInfos[16];
};
 
struct _akFormation
{
    _akFormation()
    {
        m_nFormLabel = -1;
        m_nFormType = 0;
        m_dRectLeft = 0;
        m_dRectTop = 0;
        m_dRectRight = 0;
        m_dRectBottom = 0;
    }
    void MergeDefect(_akDefect* pDefect)
    {
        if (!m_vecForms.empty())
        {
            if(m_dRectLeft > pDefect->dPositionX) m_dRectLeft = pDefect->dPositionX;
            if(m_dRectRight < pDefect->dPositionX) m_dRectRight = pDefect->dPositionX;
            
            if (m_dRectTop > pDefect->dPositionY) m_dRectTop = pDefect->dPositionY;
            if (m_dRectBottom < pDefect->dPositionY) m_dRectBottom = pDefect->dPositionY;
        }
        else
        {
            m_dRectRight = m_dRectLeft = pDefect->dPositionX;
            m_dRectTop = m_dRectBottom = pDefect->dPositionY;
        }
        m_vecForms.push_back(pDefect);
    }
    void AnalysisDefectInfo()
    {
        m_nDefectNumS=0;
        m_nDefectNumM=0;
        m_nDefectNumL=0;
        m_nDefectNum1Px=0;
        m_nDefectNumWhite=0;
        m_nDefectNumBlack=0;
        m_nDefectNum1PxWhite = 0;
        m_dSizeAvg = 0;
        m_dSizeStdDev = 0;
        m_dDiffStdDev = 0;
        m_dDiffStdDevAbs = 0;
 
        double dDiffAvg=0;
        double dDiffAvgAbs=0;
 
        _akDefect* pDefect;
        for (int i = 0; i < m_vecForms.size(); i++)
        {
            pDefect = m_vecForms[i];
 
            if (pDefect->nSize >= 5) m_nDefectNumL++;
            else if (pDefect->nSize >= 2) m_nDefectNumM++;
            else if (pDefect->nSize >= 0) m_nDefectNumS++;
 
            if (pDefect->nSize == 1) m_nDefectNum1Px++;
 
            if (pDefect->nType == 1) m_nDefectNumWhite++;
            else m_nDefectNumBlack++;
 
            if (pDefect->nType == 1 && pDefect->nSize == 1) m_nDefectNum1PxWhite++;
 
            m_dSizeAvg += (double)pDefect->nSize;
            dDiffAvg += (double)pDefect->nGrayDiff;
            dDiffAvgAbs += abs((double)pDefect->nGrayDiff);
        }
        m_dSizeAvg /= m_vecForms.size();
        dDiffAvg /= m_vecForms.size();
        dDiffAvgAbs /= m_vecForms.size();
        
        for (int i = 0; i < m_vecForms.size(); i++)
        {
            pDefect = m_vecForms[i];
            double dDiff = m_dSizeAvg - m_vecForms[i]->nSize;
            m_dSizeStdDev += dDiff * dDiff;
 
            dDiff = dDiffAvg - m_vecForms[i]->nGrayDiff;
            m_dDiffStdDev += dDiff * dDiff;
 
            dDiff = dDiffAvgAbs - abs((double)pDefect->nGrayDiff);
            m_dDiffStdDevAbs += dDiff * dDiff;
        }
        m_dSizeStdDev = sqrt(m_dSizeStdDev / (double)m_vecForms.size());
        m_dDiffStdDev = sqrt(m_dDiffStdDev / (double)m_vecForms.size());
        m_dDiffStdDevAbs = sqrt(m_dDiffStdDevAbs / (double)m_vecForms.size());
 
        int nFilter = FALSE;
        {
            double d1PxRate = 100.0*((double)m_nDefectNum1Px / (double)m_vecForms.size());
            double d1PxWhiteRate = 100.0*((double)m_nDefectNum1PxWhite/(double)m_vecForms.size());
            
 
            if (m_nFormType == 0 && d1PxWhiteRate > 50)
            {
                nFilter = TRUE;
            }
            if (m_nFormType == 1 && d1PxWhiteRate > 30)
            {
                nFilter = TRUE;
            }
            if (m_dSizeStdDev == 0)
            {
                nFilter = TRUE;
            }
            if(d1PxRate>50)
            {
                nFilter = TRUE;
            }
            
        }
        
        if (nFilter)
        {
            for (int i = 0; i < m_vecForms.size(); i++)
            {
                pDefect = m_vecForms[i];
                pDefect->nFilter = 1;
            }
        }
 
        m_nFormJudge = nFilter;
    }
 
    std::vector<_akDefect*> m_vecForms;
 
    int m_nFormJudge; //0:Normal, 1:Nodefect
    int m_nFormLabel;
    int m_nFormType; //-1:none, 0:round, 1:line
    double m_dRectLeft;
    double m_dRectTop;
    double m_dRectRight;
    double m_dRectBottom;
 
    //ºÐ¼® µ¥ÀÌÅ͵é [±èÅÂÇö2021/2/22]
    double m_dSizeAvg;
    double m_dSizeStdDev;
    int m_nDefectNumS;
    int m_nDefectNumM;
    int m_nDefectNumL;
    int m_nDefectNum1Px;
    int m_nDefectNumWhite;
    int m_nDefectNumBlack;
    int m_nDefectNum1PxWhite;
 
    double m_dDiffStdDev;        //±×·¹ÀÌ Â÷À̠ǥÁØÆíÂ÷
    double m_dDiffStdDevAbs;    //±×·¹ÀÌ Â÷ÀÌ Àý´ë°ª Ç¥ÁØÆíÂ÷
};
 
 
class akDefectFormation : public CSingleton< akDefectFormation >
{
public:
    akDefectFormation();
    virtual ~akDefectFormation();
 
public:
    void Clear();
    void AddDefect(double dPosX, double dPosY);
    void AddDefectTemp(double dPosX, double dPosY);
    void AddDefect2();
    void AddDefectImageTemp();
    void AddDefectImage();
    void AddGlassInfo();
    void AddDefectHeaderTemp();
 
public:
    std::vector<_akDefect> m_vecDefects;
    std::vector<_akDefect> m_vecTempDefects;
    std::vector<_akFormation> m_vecFormation;
    std::vector<_akReviewList> m_vecImage;
    std::vector<_akReviewList> m_vecTempImage;
    std::vector<_akReviewHeader> m_vecHeader;
    std::vector<_akReviewHeader> m_vecHeaderTemp;
    std::vector<_akGlassInfo> m_vecGlassInfo;
 
    std::vector<_akDefect> m_vecPath1;
    std::vector<_akDefect> m_vecPath2;
    std::vector<_akDefect> m_vecPath3;
    std::vector<_akDefect> m_vecPath4;
    std::vector<_akDefect> m_vecPath5;
    std::vector<_akDefect> m_vecPath6;
 
public:
    std::vector< std::vector<_akDefect > > m_vecMoudle;
};