#pragma once
|
|
#include <vector>
|
|
#define ALIGN_MARK_WIDTH 100
|
#define ALIGN_MARK_HEIGHT 100
|
|
struct SAlignFindParam
|
{
|
SAlignFindParam()
|
{
|
Reset();
|
}
|
|
void Reset()
|
{
|
// match
|
bMatchProcess = TRUE;
|
dMatchRate = 0.8;
|
dMatchingPixelStandard = 0;
|
dMatchingAlarmCondition = 0;
|
|
// edge
|
bEdgeProcess = TRUE;
|
nAlignWidth = ALIGN_MARK_WIDTH;
|
nAlignHeight = ALIGN_MARK_HEIGHT;
|
nEdgeThreshold = 50;
|
nMergeRange = 5;
|
dEdgeRate = 0.8;
|
nKernelSize = 5;
|
|
// corner
|
nCorner_DirType = 0; // lefttop, leftbottom, righttop, rightbottom
|
nCorner_SobelKernelSize = 3;
|
nCorner_EdgeKernelSize = 5;
|
nCorner_EdgeThreshold = 80;
|
nCorner_IgnorePixel = 20;
|
|
// thickness
|
bMeasureThickness = FALSE;
|
nEDThicknessLR = 25;
|
nEDThicknessTB = 25;
|
nEDThicknessRange = 10;
|
}
|
|
// match
|
BOOL bMatchProcess;
|
double dMatchRate;
|
/*< LYW 20211014 - #3671 ADD Start >*/
|
int dMatchingPixelStandard;
|
int dMatchingAlarmCondition;
|
/*< LYW 20211014 - #3671 ADD End >*/
|
|
// edge
|
BOOL bEdgeProcess;
|
int nAlignWidth;
|
int nAlignHeight;
|
int nEdgeThreshold;
|
double dEdgeRate;
|
int nMergeRange;
|
int nKernelSize;
|
|
// corner
|
int nCorner_DirType;
|
int nCorner_SobelKernelSize;
|
int nCorner_EdgeKernelSize;
|
int nCorner_EdgeThreshold;
|
int nCorner_IgnorePixel;
|
|
// thickness
|
BOOL bMeasureThickness;
|
int nEDThicknessLR;
|
int nEDThicknessTB;
|
int nEDThicknessRange;
|
|
};
|
|
enum AlignProcess_Type { AlignProcess_Match=0, AlignProcess_Edge };
|
enum AlignMatch_Result { AlignMatch_None=0, AlignMatch_NoTemplate, AlignMatch_NotOneChannels, AlignMatch_MatchFail, AlignMatch_LowScore, AlignMatch_Success };
|
enum AlignEdge_Result { AlignEdge_None=0, AlignEdge_EdgeFail, AlignEdge_BinaryFail, AlignEdge_BlobFail, AlignEdge_LowScore, AlignEdge_Success };
|
|
struct SThicknessResult
|
{
|
SThicknessResult()
|
{
|
Reset();
|
}
|
|
void Reset()
|
{
|
rtSizeL.SetRect(-1,-1,-1,-1);
|
rtSizeT.SetRect(-1,-1,-1,-1);
|
rtSizeR.SetRect(-1,-1,-1,-1);
|
rtSizeB.SetRect(-1,-1,-1,-1);
|
}
|
|
BOOL IsAllSuccess()
|
{
|
return rtSizeL.top != -1
|
&& rtSizeL.bottom != -1
|
&& rtSizeR.top != -1
|
&& rtSizeR.bottom != -1
|
&& rtSizeT.left != -1
|
&& rtSizeT.right != -1
|
&& rtSizeB.left != -1
|
&& rtSizeB.right != -1;
|
}
|
|
CRect rtSizeL, rtSizeT, rtSizeR, rtSizeB;
|
};
|
|
struct SAlignFindResult
|
{
|
SAlignFindResult()
|
{
|
Reset();
|
}
|
|
void Reset()
|
{
|
nResultCode = 0;
|
nResultProcess = 0;
|
dMatchValue = 0;
|
dPosX = 0;
|
dPosY = 0;
|
|
sThicknessResult.Reset();
|
}
|
|
int nResultCode;
|
int nResultProcess;
|
double dMatchValue;
|
double dPosX;
|
double dPosY;
|
|
SThicknessResult sThicknessResult;
|
};
|
typedef std::vector<SAlignFindResult> VectorAlignFindResult;
|
typedef std::vector<SAlignFindResult>::iterator VectorAlignFindResultIt;
|
|
struct SPixelBlob
|
{
|
SPixelBlob()
|
{
|
Reset();
|
}
|
|
SPixelBlob(int left, int top, int right, int bottom)
|
{
|
dMatchValue = 0.0;
|
nLeft = left;
|
nTop = top;
|
nRight = right;
|
nBottom = bottom;
|
vectorPoint.clear();
|
sThicknessResult.Reset();
|
}
|
|
void Reset()
|
{
|
dMatchValue = 0.0;
|
nLeft = INT_MAX;
|
nTop = INT_MAX;
|
nRight = INT_MIN;
|
nBottom = INT_MIN;
|
vectorPoint.clear();
|
sThicknessResult.Reset();
|
}
|
|
int GetSquareSize() const { return (nRight-nLeft+1) * (nBottom-nTop+1); }
|
int GetWidth() const { return (nRight-nLeft+1); }
|
int GetHeight() const { return (nBottom-nTop+1); }
|
int GetCenterX() const { return nLeft + (nRight - nLeft + 1) / 2; }
|
int GetCenterY() const { return nTop + (nBottom - nTop + 1) / 2; }
|
int GetMaxSize() const { return (GetWidth() < GetHeight()) ? GetHeight(): GetWidth(); }
|
int GetMinSize() const { return (GetWidth() > GetHeight()) ? GetHeight(): GetWidth(); }
|
size_t GetPixelCount() const { return vectorPoint.size(); }
|
|
double dMatchValue;
|
int nLeft;
|
int nTop;
|
int nRight;
|
int nBottom;
|
std::vector<CPoint> vectorPoint;
|
SThicknessResult sThicknessResult;
|
};
|
typedef std::vector<SPixelBlob> VectorPixelBlob;
|
typedef std::vector<SPixelBlob>::iterator VectorPixelBlobIt;
|