#pragma once
|
|
#include "MosisAssem/AssemParam.h"
|
#include "MosisAssem/AssemDefect.h"
|
#include <math.h>
|
|
class CScanCell;
|
|
enum DefectLocation { DefectLoc_Pattern = 0, DefectLoc_Crack, DefectLoc_BM, DefectLoc_ASG };
|
enum CellLineType { CellLine_Gate = 0, CellLine_Data };
|
enum DefectFiltering { Filtering_NO = 0, Filtering_CO }; // Filtering_CO : Cosmic Ray FALSE
|
#define DEFECTIMAGE_WIDTH 280
|
#define DEFECTIMAGE_HEIGHT 120
|
|
class CInspectParam : public CConvParam
|
{
|
public:
|
int m_iFrame;
|
CScanCell *m_pScanCell;
|
BOOL m_bUseMatchFilter;
|
BOOL m_MatchFilter2by2;
|
int m_EchoThreshold;
|
//int m_iModel;
|
};
|
|
|
class CReDefect
|
{
|
public:
|
enum ReKind{Re_Other, Re_TFE_CIRCLE, Re_PI_CONVEX, Re_PI_CONCAVE};
|
public:
|
float m_Mean1, m_Mean2;
|
float m_StdDeviation1, m_StdDeviation2;
|
float m_Mean, m_StdDeviation;
|
float m_Rough;
|
|
float m_ProMean1, m_ProMean2; // Æò±Õ°ª°ú StdDeviation ºñ±³½Ã mean°ª¿¡ °¡ÁßÄ¡¸¦ µÎ¾î º¯°æÇÑ mean °ªÀ» »ç¿ëÇÑ´Ù.
|
void CalcProcessMean(float minus= -1.2, float plus= 0.8)
|
{
|
if(m_Mean1 < 0)
|
{
|
m_ProMean1= m_Mean1*minus;
|
}else
|
{
|
m_ProMean1= m_Mean1*plus;
|
}
|
|
if(m_Mean2 < 0)
|
{
|
m_ProMean2= m_Mean2*minus;
|
}else
|
{
|
m_ProMean2= m_Mean2*plus;
|
}
|
}
|
|
ReKind m_ReKind, m_ReKind2;
|
int m_ReStage;
|
|
#define AutoStage() m_ReStage++;
|
#define AutoReturn(kind) {m_ReKind= kind; return m_ReKind;}
|
|
ReKind JudgeTFE(float mean1, float dev1, float rough)
|
{
|
m_Mean1= mean1, m_StdDeviation1= dev1;
|
m_ReStage= 0;
|
m_Rough= rough;
|
|
m_ReKind= Re_Other;
|
if(m_StdDeviation1 < 10)
|
AutoReturn(Re_Other);
|
|
CalcProcessMean(-1.2f, 0.8f);
|
AutoStage();
|
if(m_ProMean1 < m_StdDeviation1)
|
AutoReturn(Re_TFE_CIRCLE);
|
|
AutoReturn(Re_Other);
|
}
|
|
ReKind JudgeTFE(float mean1, float dev1, float mean2, float dev2, float mean, float dev, float rough)
|
{
|
m_Mean1= mean1, m_StdDeviation1= dev1;
|
m_Mean2= mean2, m_StdDeviation2= dev2;
|
m_Mean= mean, m_StdDeviation= dev;
|
m_Rough= rough;
|
|
m_ReStage= 0;
|
m_ReKind= Re_Other;
|
if(m_StdDeviation1 < 10 && m_StdDeviation2 < 10)
|
AutoReturn(Re_Other);
|
|
CalcProcessMean(-1.2f, 0.8f);
|
|
AutoStage();
|
if(m_ProMean1 < m_StdDeviation1)
|
AutoReturn(Re_TFE_CIRCLE);
|
|
AutoStage();
|
if(m_ProMean2 < m_StdDeviation2)
|
AutoReturn(Re_TFE_CIRCLE);
|
|
AutoStage();
|
if(fabs(m_Mean1- m_Mean2) > 15)
|
{
|
if(m_Mean1 > -10 || m_Mean2 > -10)
|
AutoReturn(Re_TFE_CIRCLE);
|
}
|
|
AutoReturn(Re_Other);
|
}
|
|
ReKind JudgePI(float mean1, float dev1, float mean2, float dev2, float mean, float dev, float rough)
|
{
|
m_Mean1= mean1, m_StdDeviation1= dev1;
|
m_Mean2= mean2, m_StdDeviation2= dev2;
|
m_Mean= mean, m_StdDeviation= dev;
|
m_Rough= rough;
|
|
m_ReStage= 0;
|
m_ReKind= Re_Other;
|
|
if(m_StdDeviation1 < 10 && m_StdDeviation2 < 10)
|
{
|
AutoReturn(Re_Other);
|
}
|
|
AutoStage();
|
if(m_Mean1 < 10 && m_Mean2 < 10)
|
{
|
AutoReturn(Re_Other);
|
}
|
|
float absDiff= fabs(m_Mean1- m_Mean2);
|
|
CalcProcessMean(-1.2f, 0.8f);
|
|
|
AutoStage();
|
if(m_ProMean1 < m_StdDeviation1 || m_ProMean2 < m_StdDeviation2)
|
{
|
if(m_Mean2 > m_Mean1)
|
{
|
AutoReturn(Re_PI_CONVEX);
|
}else
|
{
|
AutoReturn(Re_PI_CONCAVE);
|
}
|
}
|
|
AutoStage();
|
if((m_Mean1 > 0 || m_Mean2 > 0) && absDiff > 15)
|
{
|
if(m_Mean2 > m_Mean1)
|
{
|
AutoReturn(Re_PI_CONVEX);
|
}else
|
{
|
AutoReturn(Re_PI_CONCAVE);
|
}
|
}
|
|
|
AutoReturn(Re_Other);
|
}
|
};
|
|
class CDefect : public CReDefect
|
{
|
public:
|
int m_nIndex;
|
int m_nScanIdx;
|
int m_iModel;
|
CDefectBlob m_Defect;
|
DefectLocation m_DefectLoc;
|
DefectFiltering m_DefectFiltering;
|
char m_strPosition[20];
|
//BYTE m_Image[DEFECTIMAGE_WIDTH * DEFECTIMAGE_HEIGHT + 1];
|
|
//OhByungGil
|
int m_iFrameIdx;
|
|
CDefect()
|
{
|
Reset();
|
}
|
virtual ~CDefect()
|
{
|
|
}
|
void Reset()
|
{
|
m_nIndex = -1;
|
m_nScanIdx = -1;
|
m_iModel = -1;
|
m_Defect.Reset();
|
m_DefectLoc = DefectLoc_Pattern;
|
m_DefectFiltering = Filtering_NO;
|
ZeroMemory(m_strPosition, 20);
|
//ZeroMemory(m_Image, DEFECTIMAGE_WIDTH * DEFECTIMAGE_HEIGHT + 1);
|
}
|
};
|
|
class CBlobStorage;
|
class CMosisBuffer;
|
class CConvParam;
|
class CAssemControl;
|
class CZoneReference;
|
|
class CDefectStorage
|
{
|
protected:
|
CRITICAL_SECTION m_csDefect;
|
|
public:
|
int m_nDefect;
|
CDefect *m_pDefect;
|
|
int m_maxDefect;
|
int m_nDefectSpace;
|
|
int InitDefectStorage(int maxDefect= 10000);
|
void ResetDefectStorage() ;
|
int GetDefectCount() {return m_nDefect;}
|
CDefect* GetDefect(int i){return m_pDefect+ i;}
|
|
public:
|
CDefectStorage(void);
|
~CDefectStorage(void);
|
|
int ExtractDefect(CZoneReference *pZoneReference, CBlobStorage *pBlobStorage, CInspectParam *pParam, int iModel, int nCosmicThreshold, BOOL bDelBlack, BOOL bDelWhite, int filterSize, BOOL bDelGeneral);
|
BOOL IsCosmicRayDefect(CDefectBlob *blob, CMosisBuffer &fBuffer, int crFilterThreshold);
|
void CheckDefectRect(CPoint* pVertex, CRect* pRect, int nX, int nY);
|
|
int StopInspection(CAssemControl *pAssemControl);
|
};
|