|
#include "stdafx.h"
|
|
#include "BlobStorage.h"
|
#include "ASGInspection.h"
|
|
#include "StopWatch3.h"
|
|
#include "Pad.h"
|
|
|
#ifdef _DEBUG
|
#define new DEBUG_NEW
|
#endif
|
|
#define CONV_SPR_MULTI 16
|
#define CONV_SPR_SHIFT 4
|
|
|
#include "SISAssem.h"
|
//#include "Memory.h"
|
#include "AssemParam.h"
|
|
|
|
|
extern "C"{
|
|
int ConvFloatE(BYTE* pImgBuff, short* pConBuff, __int64 maxDefect, __int64 nDefect
|
, __int64 left, __int64 right, __int64 top, __int64 bottom
|
, int* DefectX, int* DefectY, short* DefectType, short* DefectValue
|
, __int64 frameWidth, __int64 piPitch, __int64 pfSPR, __int64 psSPR
|
, __int64 Threshold, __int64 Suppress, __int64 SPR, __int64 ShiftCount
|
);
|
int ConvFloatDPCE(BYTE* pImgBuff, short* pConBuff, __int64 maxDefect, __int64 nDefect
|
, __int64 left, __int64 right, __int64 top, __int64 bottom
|
, int* DefectX, int* DefectY, short* DefectType, short* DefectValue
|
, __int64 frameWidth, short* piPitch, short* pfSPR, short* psSPR
|
, __int64 Threshold, __int64 Suppress, __int64 SPR, __int64 ShiftCount
|
, __int64 iPitch
|
);
|
|
int ConvPixelE(BYTE *pImgBuff, __int64 Threshold, __int64 maxDefect, __int64 nDefect
|
, __int64 left, __int64 right, __int64 top, __int64 bottom
|
, int* DefectX, int* DefectY, short* DefectType, short* DefectValue
|
, int* pGraySrc, int* pGrayCmp, int* pZoneID, int* pZoneTh
|
, __int64 frameWidth, __int64 iPitch, __int64 fSPR, __int64 sSPR
|
, __int64 Suppress, __int64 DTH_StartThreshold, __int64 DTH_Gradient, __int64 DTH_SectionStart
|
, __int64 ShiftCount
|
);
|
int ConvPixelE2(BYTE *pImgBuff, __int64 Threshold, __int64 maxDefect, __int64 nDefect
|
, __int64 left, __int64 right, __int64 top, __int64 bottom
|
, int* DefectX, int* DefectY, short* DefectType, short* DefectValue
|
, int* pGraySrc, int* pGrayCmp, int* pZoneID, int* pZoneTh
|
, __int64 frameWidth, __int64 iPitch, __int64 fSPR, __int64 sSPR
|
, __int64 Suppress, __int64 DTH_StartThreshold, __int64 DTH_Gradient, __int64 DTH_SectionStart
|
, __int64 ShiftCount
|
);
|
int ConvPixelDPCE(BYTE *pImgBuff, __int64 Threshold, __int64 maxDefect, __int64 nDefect
|
, __int64 left, __int64 right, __int64 top, __int64 bottom
|
, int* DefectX, int* DefectY, short* DefectType, short* DefectValue
|
, int* pGraySrc, int* pGrayCmp, int* pZoneID, int* pZoneTh
|
, __int64 frameWidth, short* piPitch, short* pfSPR, short* psSPR
|
, __int64 Suppress, __int64 DTH_StartThreshold, __int64 DTH_Gradient, __int64 DTH_SectionStart
|
, __int64 ShiftCount, __int64 iPitch
|
);
|
|
int ConvZone(BYTE *pImgBuff, __int64 Threshold, __int64 maxDefect, __int64 nDefect
|
, __int64 left, __int64 right, __int64 top, __int64 bottom
|
, int* DefectX, int* DefectY, short* DefectType, short* DefectValue
|
, int* pGraySrc, int* pGrayCmp, int* pZoneID, int* pZoneTh
|
, __int64 frameWidth, __int64 iPitch, __int64 fSPR, __int64 sSPR
|
, short* ZoneThTable, short* ZoneIdTable, __int64 ZoneTableWidth, void* pMatchTable
|
, CDefectPair *pDefectdPair, __int64 StartPair, __int64 MaxPair, __int64 PairSize
|
, __int64 dxPattern, __int64 dyPattern, __int64 yZoneByte, __int64 bReverseFilter
|
);
|
int ConvZoneDPC(BYTE *pImgBuff, __int64 Threshold, __int64 maxDefect, __int64 nDefect
|
, __int64 left, __int64 right, __int64 top, __int64 bottom
|
, int* DefectX, int* DefectY, short* DefectType, short* DefectValue
|
, int* pGraySrc, int* pGrayCmp, int* pZoneID, int* pZoneTh
|
, __int64 frameWidth, short* iPitch, short* fSPR, short* sSPR
|
, short* ZoneThTable, short* ZoneIdTable, __int64 ZoneTableWidth, void* pMatchTable
|
, CDefectPair *pDefectdPair, __int64 StartPair, __int64 MaxPair, __int64 PairSize
|
, __int64 dxPattern, __int64 dyPattern, __int64 bReverseFilter, __int64 iPitch16
|
, __int64 yZoneByte
|
);
|
int ConvZoneVert(BYTE *pImgBuff, __int64 Threshold, __int64 maxDefect, __int64 nDefect
|
, __int64 left, __int64 right, __int64 top, __int64 bottom
|
, int* DefectX, int* DefectY, short* DefectType, short* DefectValue
|
, int* pGraySrc, int* pGrayCmp, int* pZoneID, int* pZoneTh
|
, __int64 frameWidth, __int64 iPitch16, __int64 fSPR, __int64 sSPR
|
, short* ZoneThTable, short* ZoneIdTable, __int64 ZoneTableWidth, void* pMatchTable
|
, CDefectPair *pDefectdPair, __int64 StartPair, __int64 MaxPair, __int64 PairSize
|
, __int64 dxPattern, __int64 dyPattern, __int64 yZoneByte, __int64 bReverseFilter
|
);
|
|
|
int ConvZoneE(BYTE *pImgBuff, __int64 Threshold, __int64 maxDefect, __int64 nDefect
|
, __int64 left, __int64 right, __int64 top, __int64 bottom
|
, int* DefectX, int* DefectY, short* DefectType, short* DefectValue
|
, int* pGraySrc, int* pGrayCmp, int* pZoneID, int* pZoneTh
|
, __int64 frameWidth, __int64 iPitch, __int64 fSPR, __int64 sSPR
|
, __int64 Suppress, __int64 DTH_StartThreshold, __int64 DTH_Gradient, __int64 DTH_SectionStart
|
, __int64 ShiftCount, short* ZoneThTable, short* ZoneIdTable, __int64 ZoneTableWidth
|
, __int64 ZoneTableX, __int64 ZoneTableY
|
);
|
int ConvZoneDPCE(BYTE *pImgBuff, __int64 Threshold, __int64 maxDefect, __int64 nDefect
|
, __int64 left, __int64 right, __int64 top, __int64 bottom
|
, int* DefectX, int* DefectY, short* DefectType, short* DefectValue
|
, int* pGraySrc, int* pGrayCmp, int* pZoneID, int* pZoneTh
|
, __int64 frameWidth, short* piPitch, short* pfSPR, short* psSPR
|
, __int64 Suppress, __int64 DTH_StartThreshold, __int64 DTH_Gradient, __int64 DTH_SectionStart
|
, __int64 ShiftCount, short* ZoneThTable, short* ZoneIdTable, __int64 ZoneTableWidth
|
, __int64 ZoneTableX, __int64 ZoneTableY, __int64 iPitch
|
);
|
|
int ConvFloat2(BYTE* pImgBuff, short* pConBuff, __int64 maxDefect, __int64 nDefect
|
, __int64 left, __int64 right, __int64 top, __int64 bottom
|
, int* DefectX, int* DefectY, short* DefectType, short* DefectValue
|
, CDefectPair *pDefectdPair, __int64 StartPair, __int64 MaxPair, __int64 PairSize
|
, __int64 iPitch16, __int64 BuffWidth, __int64 Threshold, __int64 Suppress
|
, BYTE* pIndexBuff, __int64 IndexWidth, __int64 IndexHeight, __int64 iIndex
|
, __int64 IndexLeft, __int64 IndexTop
|
, short* piPitch, short* pfSpr, short* psSpr
|
);
|
};
|
|
|
|
void CSISAssem::Compare_Zone()
|
{
|
double xpitch= m_Param.GetRealConvPitch();
|
double ypitch= m_Param.GetRealScanPitch();
|
int oldBlob;
|
oldBlob= m_nBlob;
|
|
if(m_Param.m_ConvDir == ConvDir_Vert)
|
{
|
m_nPair= ConvZoneVert(m_Param.s_lpBuffer, m_Param.s_nThreshold, m_maxPixel, m_nPixel// 4
|
, m_Param.s_RectConv.left, m_Param.s_RectConv.right, m_Param.s_RectConv.top, m_Param.s_RectConv.bottom
|
, m_pPixelX, m_pPixelY, m_pPixelType, m_pPixelValue // 4
|
, m_pGraySrc, m_pGrayCmp, m_pZoneID, m_pZoneTh// 4
|
, m_Param.s_nFrameWidth, (__int64)(ypitch*16), 0, 0 // 4
|
, m_Param.s_psZoneThTable, m_Param.s_psZoneTable, m_Param.s_nThresTableWidth, m_Param.m_pGammaTable
|
, m_pPairDefect, m_nPair, m_maxPair, sizeof(CDefectPair)
|
, (__int64) m_Param.GetZoneConvPitch(), (__int64) m_Param.GetZoneScanPitch(), m_Param.m_nGammaXCount*8, (__int64) m_Param.s_bReverseFilter
|
);
|
CBlobStorage::BlobDefectVert();
|
CBlobStorage::MergeDivision(oldBlob, m_Param.m_nDefectMergePixel);
|
CBlobStorage::ShadowFilterVert(oldBlob, m_Param.GetRealScanPitch());
|
return;
|
}
|
|
if(m_Param.m_pPitch)
|
{
|
m_nPair= ConvZoneDPC(m_Param.s_lpBuffer, m_Param.s_nThreshold, m_maxPixel, m_nPixel// 4
|
, m_Param.s_RectConv.left, m_Param.s_RectConv.right, m_Param.s_RectConv.top, m_Param.s_RectConv.bottom
|
, m_pPixelX, m_pPixelY, m_pPixelType, m_pPixelValue // 4
|
, m_pGraySrc, m_pGrayCmp, m_pZoneID, m_pZoneTh// 4
|
, m_Param.s_nFrameWidth, m_Param.m_pPitch, m_Param.m_pfSPR, m_Param.m_psSPR // 4
|
, m_Param.s_psZoneThTable, m_Param.s_psZoneTable, m_Param.s_nThresTableWidth, m_Param.m_pGammaTable
|
, m_pPairDefect, m_nPair, m_maxPair, sizeof(CDefectPair)
|
, (__int64)xpitch, (__int64)ypitch, m_Param.s_bReverseFilter, (__int64)(xpitch*16)
|
, m_Param.m_nGammaXCount*8
|
);
|
/*
|
m_nPixel= ConvZoneDPC(m_Param.s_lpBuffer, m_Param.s_nThreshold, m_maxPixel, m_nPixel// 4
|
, m_Param.s_RectConv.left, m_Param.s_RectConv.right, m_Param.s_RectConv.top, m_Param.s_RectConv.bottom
|
, m_pPixelX, m_pPixelY, m_pPixelType, m_pPixelValue // 4
|
, m_pGraySrc, m_pGrayCmp, m_pZoneID, m_pZoneTh// 4
|
, m_Param.s_nFrameWidth, m_Param.m_pPitch, m_Param.m_pfSPR, m_Param.m_psSPR // 4
|
, m_Param.s_nThresholdSupress, m_Param.s_nAddThreshold, m_Param.s_nAddGradient, m_Param.s_nAddThresLevel
|
, CONV_SPR_SHIFT, m_Param.s_psZoneThTable, m_Param.s_psZoneTable, m_Param.s_nThresTableWidth
|
, m_Param.s_nThresTableStartX, m_Param.s_nThresTableStartY, (__int64)(xpitch+ 0.5), (__int64) m_Param.s_bReverseFilter
|
);
|
CPairStorage::PairingPlus_Pixel(xpitch);
|
*/
|
}else
|
{
|
m_nPair= ConvZone(m_Param.s_lpBuffer, m_Param.s_nThreshold, m_maxPixel, m_nPixel// 4
|
, m_Param.s_RectConv.left, m_Param.s_RectConv.right, m_Param.s_RectConv.top, m_Param.s_RectConv.bottom
|
, m_pPixelX, m_pPixelY, m_pPixelType, m_pPixelValue // 4
|
, m_pGraySrc, m_pGrayCmp, m_pZoneID, m_pZoneTh// 4
|
, m_Param.s_nFrameWidth, (__int64)(xpitch*16), 0, 0 // 4
|
, m_Param.s_psZoneThTable, m_Param.s_psZoneTable, m_Param.s_nThresTableWidth, m_Param.m_pGammaTable
|
, m_pPairDefect, m_nPair, m_maxPair, sizeof(CDefectPair)
|
, (__int64)xpitch, (__int64)ypitch, m_Param.m_nGammaXCount*8, m_Param.s_bReverseFilter
|
);
|
}
|
CBlobStorage::BlobDefect();
|
CBlobStorage::MergeDivision(oldBlob, m_Param.m_nDefectMergePixel);
|
CBlobStorage::ShadowFilter(oldBlob, m_Param.GetRealConvPitch());
|
return;
|
}
|
|
|
DIT_RESULT CAssemControl::ASGVertConvolution(int iThread, CConvParam *pParam)
|
{
|
if(iThread >= m_nThread || iThread < 0)
|
return DIT_CONV_INVALIDPARAM;
|
return GetSISAssem(iThread)->ASGVertConvolution(pParam);
|
}
|
|
|
DIT_RESULT CSISAssem::ASGVertConvolution(CConvParam *pParam)
|
{
|
// ÀÌ ÇÔ¼ö ¾È ¾¹´Ï´Ù..
|
// È£Ãâ ÇÏÁö ¸¶¼¼¿ä..
|
// ³ªÁß¿¡ Á¤¸® ÇÒ °Ì´Ï´Ù.
|
DIT_RESULT rslt= DIT_CONV_SUCCESS;
|
|
// copy prameter to member variable
|
SetConvParam(pParam);
|
|
BOOL bPassInspect;
|
rslt= CheckParameter_Vert(bPassInspect);
|
if(rslt != DIT_CONV_SUCCESS)
|
return rslt;
|
|
// Reset 3 Storage (Blob, Pair, Pixel)
|
ResetSISAssem();
|
|
|
|
// SupPixel Á¤¹Ðµµ¸¦ 1/8(3½Â¹è) °ú 1/16(4½Â¹è) µÑÁß¿¡ Çϳª·Î ¼±ÅÃÇØ¾ß ÇÑ´Ù..
|
|
//Compare_Vert(); //¹Ú°úÀå ÄÚµå
|
|
|
if (m_Param.s_uiProcessing & DIT_CONV_PPAIRING)
|
{
|
DIT_RESULT PairResu;
|
PairResu = CPairStorage::PairingPlus_Vert(m_Param.s_dPitchScanReal * m_Param.s_nPitchCycleScan);
|
|
if (PairResu != DIT_CONV_SUCCESS)
|
{
|
if (rslt == DIT_CONV_FRAMEOVERFLOW)
|
return rslt;
|
else
|
return PairResu;
|
}
|
|
if (m_Param.s_uiProcessing & DIT_CONV_MPAIRING)// && FALSE)
|
{
|
PairResu = CPairStorage::PairingMinus_Vert(m_Param.s_dPitchScanReal * m_Param.s_nPitchCycleScan);
|
|
if (PairResu != DIT_CONV_SUCCESS)
|
{
|
if (rslt == DIT_CONV_FRAMEOVERFLOW)
|
return rslt;
|
else
|
return PairResu;
|
}
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
// Blobing
|
if (m_Param.s_uiProcessing & DIT_CONV_BLOBING)
|
{
|
int nBlobStart = m_nBlob;
|
DIT_RESULT PairResu= DIT_CONV_SUCCESS;
|
// PairResu = CBlobStorage::BlobDefect2();
|
////Debug_test();
|
if (PairResu != DIT_CONV_SUCCESS)
|
{
|
if (rslt == DIT_CONV_FRAMEOVERFLOW)
|
return rslt;
|
else
|
return PairResu;
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
// Unpair Blobing
|
if (m_Param.s_uiProcessing & DIT_CONV_UNPAIRBLOB)// && FALSE)
|
{
|
// PairResu = CBlobStorage::BlobUnpairDefect();
|
//Debug_test();
|
if (PairResu != DIT_CONV_SUCCESS)
|
{
|
if (rslt == DIT_CONV_FRAMEOVERFLOW)
|
return rslt;
|
else
|
return PairResu;
|
}
|
}
|
// TRACE("Blobing %d\n", GetTickCount() - dwTick);
|
// dwTick = GetTickCount();
|
|
//////////////////////////////////////////////////////////////////////////
|
// Defect Classification
|
if (m_Param.s_uiProcessing & DIT_CONV_CLASSIFY)
|
{
|
PairResu = CBlobStorage::ClassificationDefectVert(nBlobStart);
|
//Debug_test();
|
if (PairResu != DIT_CONV_SUCCESS)
|
{
|
if (rslt == DIT_CONV_FRAMEOVERFLOW)
|
return rslt;
|
else
|
return PairResu;
|
}
|
}
|
|
// TRACE("ClassificationDefect %d\n", GetTickCount() - dwTick);
|
// dwTick = GetTickCount();
|
//////////////////////////////////////////////////////////////////////////
|
// Merge Defect
|
int nDefectMergePixel= m_Param.m_nDefectMergePixel;
|
if (m_Param.s_uiProcessing & DIT_CONV_MERGE_DIVISION && nDefectMergePixel > 0)
|
{
|
PairResu = CBlobStorage::MergeDivision(nBlobStart, nDefectMergePixel);
|
//Debug_test();
|
if (PairResu != DIT_CONV_SUCCESS)
|
{
|
if (rslt == DIT_CONV_FRAMEOVERFLOW)
|
return rslt;
|
else
|
return PairResu;
|
}
|
}
|
else if (m_Param.s_uiProcessing & DIT_CONV_MERGE_MIX && nDefectMergePixel > 0)
|
{
|
PairResu = CBlobStorage::MergeMix(nBlobStart, nDefectMergePixel);
|
//Debug_test();
|
if (PairResu != DIT_CONV_SUCCESS)
|
{
|
if (rslt == DIT_CONV_FRAMEOVERFLOW)
|
return rslt;
|
else
|
return PairResu;
|
}
|
}
|
// TRACE("Merging %d\n", GetTickCount() - dwTick);
|
// dwTick = GetTickCount();
|
}
|
}
|
return rslt;
|
}
|