// EdgeFind.h: interface for the CSISEdgeFind class.
|
//
|
//////////////////////////////////////////////////////////////////////
|
#pragma once
|
|
#include <map>
|
|
class CSISBuffer;
|
|
|
// defect count ±â¹ÝÀ¸·Î cutoff point ¸¦ ã¾Æ ÁØ´Ù.
|
// AddCountData¸¦ ÅëÇÑ ¹æ¹ý°ú FindCutoff_Continue¸¦ ÅëÇÑ ¹æ¹ý µÎ°¡Áö°¡ ÀÖ´Ù.
|
class AFX_EXT_CLASS CCutoffFind
|
{
|
int m_nContinuousCutoff;
|
int *m_pCountData;
|
public:
|
int m_maxCount;
|
int m_nCountData;
|
CCutoffFind()
|
{
|
m_nCountData= 0;
|
m_pCountData= NULL;
|
}
|
virtual ~CCutoffFind()
|
{
|
if(m_pCountData)
|
delete m_pCountData;
|
}
|
BOOL SetSize(int nData)
|
{
|
m_nCountData= nData;
|
if(m_pCountData)
|
delete m_pCountData;
|
m_pCountData= new int[nData];
|
return TRUE;
|
}
|
|
// ¼øÂ÷ÀûÀ¸·Î È£ÃâµÇ¸é cutoffÀÎÁö¸¦ ÆÇº°ÇØ ¿¬¼Ó cutoff count¸¦ ¸®ÅÏÇØ ÁØ´Ù.
|
int AddCountData(int data, int nCutoff)
|
{
|
if(data >= nCutoff)
|
{
|
m_nContinuousCutoff++;
|
return m_nContinuousCutoff;
|
}
|
m_nContinuousCutoff= 0;
|
return 0;
|
}
|
|
|
void SetCountData(int iData, int data)
|
{
|
m_pCountData[iData]= data;
|
}
|
// Á¤,¿ª¹æÇâÀ¸·Î line by line °Ë»çÇϸç Cutoff_Continuous¸¦ ã¾Æ ³½´Ù. Cutoff_Continuous°¡ ¾øÀ¸¸é false, Cutoff À§Ä¡´Â Á¤¹æÇâ ±âÁØÀÇ indexÀÌ´Ù.
|
// nContinue°³¼ö ÀÌ»ó Áö¼ÓÀûÀ¸·Î cutoff°¡ »ý°Ü¾ß Cutoff_Continuous·Î °£ÁÖÇÑ´Ù.
|
BOOL FindCutoff_Continuous(BOOL bForwardScan, int nCutoff, int nContinue, int &iForwardResult,int nOffset=0)
|
{
|
int i;
|
int nOccur= 0;
|
|
if(bForwardScan)
|
{
|
for(i= nOffset; i< m_nCountData; i++)
|
{
|
if(m_pCountData[i] >= nCutoff)
|
{
|
nOccur++;
|
if(nOccur >= nContinue)
|
{
|
iForwardResult= i- nContinue+ 1;
|
return TRUE;
|
}
|
}else
|
{
|
nOccur= 0;
|
}
|
}
|
return FALSE;
|
}
|
|
for(i= m_nCountData-1; i >= nOffset; i--)
|
{
|
if(m_pCountData[i] >= nCutoff)
|
{
|
nOccur++;
|
if(nOccur >= nContinue)
|
{
|
iForwardResult= i+ nContinue;
|
return TRUE;
|
}
|
}else
|
{
|
nOccur= 0;
|
}
|
}
|
return FALSE;
|
}
|
};
|
|
enum SISEdgePos{eEP_LEFT, eEP_TOP, eEP_RIGHT, eEP_BOTTOM};
|
|
struct stEdgeLRResult
|
{
|
int iFrame;
|
int nPos;
|
};
|
|
typedef std::multimap<int, stEdgeLRResult> mapEdgeResult;
|
typedef std::multimap<int, stEdgeLRResult>::iterator mapEdgeResultIt;
|
|
class AFX_EXT_CLASS CSISEdgeFind
|
{
|
public:
|
CSISEdgeFind();
|
virtual ~CSISEdgeFind();
|
|
protected:
|
CSISBuffer *m_Buffer;
|
|
//Left Result
|
mapEdgeResult m_mapLeftEdge;
|
//Right Result
|
mapEdgeResult m_mapRightEdge;
|
//Top Result
|
int m_nTopEdge;
|
//Bottom Result
|
int m_nBottomEdge;
|
|
public:
|
void ResetEdge();
|
|
int GetEdgeResult(SISEdgePos eEP, int iFrame = 0, BOOL bNearResult = FALSE);
|
BOOL IsFindEdge(SISEdgePos eEP, int iFrame = 0);
|
|
public:
|
BOOL FindEdge_ToTop(CSISBuffer *pBuffer, int &offset, double pitch, int threshold, double rDefect);
|
BOOL FindEdge_ToBottom(CSISBuffer *pBuffer, int &offset, double pitch, int threshold, double rDefect);
|
BOOL FindEdge_ToLeft(CSISBuffer *pBuffer, int &offset, double pitch, int threshold, double rDefect,int nOffset);
|
BOOL FindEdge_ToRight(CSISBuffer *pBuffer, int &offset, double pitch, int threshold, double rDefect,int nOffset);
|
BOOL FindEdge_ToRightROI(CSISBuffer *pBuffer, int &offset, double pitch, int threshold, double rDefect,int nOffset,CRect rtROI);
|
|
public:
|
int Find_LeftEdge(CSISBuffer *pBuffer, double pitch, int threshold, double rDefect, int nContinue);
|
int Find_RightEdge(CSISBuffer *pBuffer, double pitch, int threshold, double rDefect, int nContinue);
|
int Find_TopEdge(CSISBuffer *pBuffer, double pitch, int threshold, double rDefect, int nContinue);
|
int Find_GlassStart(CSISBuffer *pBuffer, double pitch);
|
public:
|
void GetCount_X(CSISBuffer *pBuffer, double pitch, int threshold, CCutoffFind &find,int nOffset);
|
void GetCount_XROI(CSISBuffer *pBuffer, double pitch, int threshold, CCutoffFind &find,int nOffset,CRect rtROI);
|
void GetCount_Y(CSISBuffer *pBuffer, double pitch, int threshold, CCutoffFind &find);
|
|
int ImageProjection(BYTE* pBuff, int nWidth, int nHeight, CRect ROI, int nThres, int nDist = 8, int nContinue = 2);
|
int ImageProjection_R(BYTE* pBuff, int nWidth, int nHeight, CRect ROI, int nThres, int nDist = 8, int nContinue = 2);
|
int ImageProjection_Vert(BYTE* pBuff, int nWidth, int nHeight, CRect ROI, int nThres, int nDist = 8, int nContinue = 2);
|
int ImageProjection_Vert_R(BYTE* pBuff, int nWidth, int nHeight, CRect ROI, int nThres, int nDist = 8, int nContinue = 2);
|
|
int FindEdge(CSISBuffer framebuffer, SISEdgePos eEP, CRect rtROI, int nThres);
|
int FindEdgeVert(CSISBuffer framebuffer, SISEdgePos eEP, CRect rtROI, int nThres);
|
};
|