#pragma once #include "Config.h" #include "cv.h" #include "highgui.h" #include "opencv.hpp" #include "core.hpp" #include #include //20140528 #include "HardwareSettings.h" #define MAX_STRING_LENGTH 1024 #define MAX_MARKER_COUNT 3 typedef struct tagJUDGEEDGE { BOOL bError; //¿¡·¯ ¿©ºÎ.. int nRefernce; // ±âÁØ int nTolPlus; // +Çã¿ë¿ÀÂ÷ int nTolMinus; // -Çã¿ë¿ÀÂ÷ int nSlant; //»ç¼± }JUDGEEDGE, *PJUDGEEDGE; typedef struct tagUserDefectArea { int x; int y; int area_width; int area_height; int defect_threshold; int defect_dilation; int defect_width; int defect_height; void clear(void) { x = 0; y = 0; area_width = 0; area_height = 0; defect_threshold = 0; defect_dilation = 0; defect_width = 0; defect_height = 0; } tagUserDefectArea(void) { clear(); } }ST_USER_DEFECT_AREA; typedef struct tagEXECPTION_AREA { int nAreaType; CRect rc; // ¿µ¿ª À§Ä¡ (Mark ¿øÁ¡) SIZE szErrSize; // ÀÌ ¿µ¿ª¿¡¼­ Àû¿ëµÉ Size int nAppDefect; // Àû¿ëµÉ Defect Á¾·ù int nDetectLimitedArea; // »ç¿ëÀÚ ¼³Á¤ ROI »ç¿ë À¯¹« void Init() { nAreaType = 0; nAppDefect = 0; nDetectLimitedArea = 0; rc = CRect(0,0,0,0); szErrSize.cx = 0; szErrSize.cy = 0; }; void CopyData(tagEXECPTION_AREA *pExp) { nAreaType = pExp->nAreaType; rc = pExp->rc; szErrSize = pExp->szErrSize; nAppDefect = pExp->nAppDefect; nDetectLimitedArea = pExp->nDetectLimitedArea; } }EXECPTION_AREA; typedef std::vector EXCEPTION_AREA_LIST; typedef EXCEPTION_AREA_LIST::iterator itEXCEPTION_AREA_LIST; typedef std::vector USER_DEFECT_AREA_LIST; typedef std::vector::iterator itUSER_DEFECT_AREA_LIST; typedef struct stLinkList { CString m_strUpperName; CString m_strStepName; CString m_strInsName; public: stLinkList() { reset(); } void reset() { m_strUpperName = _T(""); m_strStepName = _T(""); m_strInsName = _T(""); } } LinkList, *pLinkList; typedef std::vector VectorLinkList; typedef std::vector::iterator VectorLinkListIt; class CRECIPE_INFO_PARM { public: CRECIPE_INFO_PARM(); virtual ~CRECIPE_INFO_PARM(void); public: BOOL ReadRecipe(CConfig *pFile); BOOL WriteRecipe(CConfig *pFile); public: void Reset(); void SetRecipeName(CString strRecipe); void SetRecipeFileName(CString strFile); void SetRecipeFileNameBackUp(CString strFile); CString GetRecipeName(); CString GetRecipeFileName(); public: TCHAR m_strRecipeName[MAX_STRING_LENGTH]; // ·¹½ÃÇÇ À̸§. TCHAR m_strRecipeFileName[MAX_STRING_LENGTH]; // ·¹Çǽà ÆÄÀϸí TCHAR m_strRecipeFileNameBackUp[MAX_STRING_LENGTH]; // ·¹Çǽà ÆÄÀϸí int m_nSoftRevision; CString m_strComment; // Comment double m_dOneScanTime_sec; // Scan Time }; class CRECIPE_INFO_COFG { public: CRECIPE_INFO_COFG() { Reset(); }; virtual ~CRECIPE_INFO_COFG(void) {}; public: void Reset(); BOOL LoadRecipeConfigFile(CString strRecipe); BOOL SaveRecipeConfigFile(CString strRecipe); public: BOOL m_bUse; }; //park enum LIGHT_CONTROL_METHOD{LIGHT_CONTROL_METHOD_AUTO=0,LIGHT_CONTROL_METHOD_MANUAL,LIGHT_CONTROL_METHOD_NONE}; #define LIGHT_CONTROL_COUNT 2 #define LIGHT_CONTROL_CH_COUNT 8 class CLIGHT_PARM { public: CLIGHT_PARM(); virtual ~CLIGHT_PARM(void); public: BOOL ReadRecipe(CConfig *pFile); BOOL WriteRecipe(CConfig *pFile); BOOL WriteRecipe(std::vector>* pParamList); public: void Reset(); CString GetFileString(void *pValue); public: BOOL m_bLightControl; int m_nContValue[LIGHT_CONTROL_COUNT][LIGHT_CONTROL_CH_COUNT]; void SetContValue(int nIdx, int nCh, int nContValue); }; class CSIDE_INSPECTT_PARM { public: CSIDE_INSPECTT_PARM() {Reset();}; virtual ~CSIDE_INSPECTT_PARM(void) {}; void Reset(); BOOL ReadRecipe(CConfig *pFile, int nSideIdx, eSideInsType eInsType); BOOL WriteRecipe(CConfig *pFile, int nSideIdx, eSideInsType eInsType); public: BOOL m_bUseInspect; int m_nInspect_Method; // 0 : Gray, 1 : Pitch, 2 : Gray + Pitch int m_nInspect_Range_um; int m_nInspect_SideLine_Offset_um; int m_nMin_Threshold; int m_nMax_Threshold; int m_nDiff_Threshold; int m_nDiff_Pitch; BOOL m_bSide_Filter; int m_nSide_Filter_um; int m_nMinSize_Filter_pxl; int m_nMinSize_Filter_X_um; int m_nMinSize_Filter_Y_um; int m_nDefect_Size_Dilation; // - : Erosion, + : Dilation // First, Second, Third int m_nJudge_Size_Min_X_um[3]; int m_nJudge_Size_Min_Y_um[3]; int m_nJudge_Size_Min_OR_AND[3]; // 0 : No Use, 1 : OR, 2 : AND }; class CNOTCH_PARM { public: CNOTCH_PARM() {Reset();}; virtual ~CNOTCH_PARM(void) {}; void Reset(); BOOL ReadRecipe(CConfig *pFile, int nSideIdx, int nNotchIdx); BOOL WriteRecipe(CConfig *pFile, int nSideIdx, int nNotchIdx); public: int m_nGlassStartLine_pxl; // Notch µî·Ï ÇÒ ¶§ Glass Start Line.. CPoint m_ptTopMarkPos; // Notch µî·Ï ÇÒ ¶§ Top Align Mark.. CPoint m_ptBotMarkPos; // Notch µî·Ï ÇÒ ¶§ Bot Align Mark.. BOOL m_bNotch_Use; CRect m_rtNotch_Area_pxl; int m_nGrind_Threshold; int m_nGlass_Threshold; int m_nSmooth_Filter; int m_nReferece_Line_Threshold; int m_nNotchCenter_Offset_pxl; BOOL m_bNotch_Inspect_Defect_Use; int m_nNotch_Inspect_Defect_Threshold; int m_nNotch_Inspect_Defect_Offset; int m_nNotch_Inspect_Defect_dilate; int m_nNotch_Inspect_Defect_Min_X_um; int m_nNotch_Inspect_Defect_Min_Y_um; int m_nNotch_Inspect_Defect_Judge_X_um; int m_nNotch_Inspect_Defect_Judge_Y_um; int m_nNotch_Inspect_Defect_Judge_And; BOOL m_bNotch_Dimension_Use[MAX_SIDE_NOTCH_MEASURE_COUNT]; double m_dNotch_Dimension_STD_mm[MAX_SIDE_NOTCH_MEASURE_COUNT]; double m_dNotch_Dimension_Diff_MIN_mm[MAX_SIDE_NOTCH_MEASURE_COUNT]; double m_dNotch_Dimension_Diff_MAX_mm[MAX_SIDE_NOTCH_MEASURE_COUNT]; BOOL m_bNotch_Chamfer_Use[MAX_SIDE_NOTCH_MEASURE_COUNT]; double m_dNotch_Chamfer_STD_mm[MAX_SIDE_NOTCH_MEASURE_COUNT]; double m_dNotch_Chamfer_Diff_MIN_mm[MAX_SIDE_NOTCH_MEASURE_COUNT]; double m_dNotch_Chamfer_Diff_MAX_mm[MAX_SIDE_NOTCH_MEASURE_COUNT]; // Notch Circle int m_nNotch_Circle_Count; BOOL m_bNotch_Circle_Use[MAX_SIDE_NOTCH_CIRCLE_COUNT]; CPoint m_ptNotch_Circle_TopMarkPos[MAX_SIDE_NOTCH_CIRCLE_COUNT]; // Notch Circle µî·Ï ÇÒ ¶§ Top Align Mark.. CPoint m_ptNotch_Circle_BotMarkPos[MAX_SIDE_NOTCH_CIRCLE_COUNT]; // Notch Circle µî·Ï ÇÒ ¶§ Bot Align Mark.. CRect m_rtNotch_Circle_Area_pxl[MAX_SIDE_NOTCH_CIRCLE_COUNT]; double m_dNotch_Circle_Spec_Radius_um[MAX_SIDE_NOTCH_CIRCLE_COUNT]; double m_dNotch_Circle_Spec_Radius_Min_um[MAX_SIDE_NOTCH_CIRCLE_COUNT]; double m_dNotch_Circle_Spec_Radius_Max_um[MAX_SIDE_NOTCH_CIRCLE_COUNT]; }; class CEXCEPTION_AREA_PARM { public: CEXCEPTION_AREA_PARM() {Reset();}; virtual ~CEXCEPTION_AREA_PARM(void) {}; void Reset(); BOOL ReadRecipe(CConfig *pFile, int nSideIdx, int nExceptionIdx); BOOL WriteRecipe(CConfig *pFile, int nSideIdx, int nExceptionIdx); public: CPoint m_ptTopMarkPos; CPoint m_ptBotMarkPos; CRect m_rtExceptionArea; int m_nFilterType; // 0 : No Use, 1 : Intersection, 2 : Fully int m_nFilterSizeX; int m_nFilterSizeY; BOOL m_bFilterAnd; }; class CUSER_DEFECT_AREA_PARM { public: CUSER_DEFECT_AREA_PARM() {Reset();}; virtual ~CUSER_DEFECT_AREA_PARM(void) {}; void Reset(); BOOL ReadRecipe(CConfig *pFile, int nSideIdx, int nUserDefectAreaIdx); BOOL WriteRecipe(CConfig *pFile, int nSideIdx, int nUserDefectAreaIdx); public: CPoint m_ptTopMarkPos; CPoint m_ptBotMarkPos; CRect m_rtUserDefectArea; BOOL m_bUseInspect; int m_nInspect_Method; // 0 : Gray, 1 : Y Pitch, 2 : X Pitch int m_nMin_Threshold; int m_nMax_Threshold; int m_nDiff_Threshold; int m_nDiff_Pitch; int m_nMinSize_Filter_pxl; int m_nJudge_Size_Min_X_um; int m_nJudge_Size_Min_Y_um; int m_nJudge_Size_Min_OR_AND; // 0 : No Use, 1 : OR, 2 : AND }; class CSIDE_PARM { public: CSIDE_PARM(); virtual ~CSIDE_PARM(void); public: void Reset(); BOOL ReadRecipe(CConfig *pFile, int nSideIdx); BOOL WriteRecipe(CConfig *pFile, int nSideIdx); public: int m_nSidePanelSize_um; // Scan ¸éÀÇ ¼¼·Î ¹æÇâ Å©±â int m_nFindStartEndLine_X_pxl; // Start/End Find Pos X int m_nFindStartEndLine_Threshold; int m_nSideLineThreshold; int m_nChamferLineThreshold; // Top Corner Size int m_nTopCornerShape; // 0 : None, 1 : CCut, 2 : RCut BOOL m_bTopCornerFindDefect; BOOL m_bTopCornerMeasureSize; int m_nTopCornerEdgeFilterSize; int m_nTopCornerEdgeThreshold; int m_nTopCornerSizeX_um; int m_nTopCornerSizeY_um; BOOL m_bTopCornerDimension_Use[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dTopCornerDimensionSpec_mm_Std[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dTopCornerDimensionSpec_mm_Min[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dTopCornerDimensionSpec_mm_Max[MAX_CORNER_DIMENSION_MEASURE_COUNT]; BOOL m_bTopCornerChamfer_Use[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dTopCornerChamfer_Spec_mm_Std[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dTopCornerChamfer_Spec_mm_Min[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dTopCornerChamfer_Spec_mm_Max[MAX_CORNER_DIMENSION_MEASURE_COUNT]; int m_nTopCornerIns_StartOffset; int m_nTopCornerIns_Range; int m_nTopCornerIns_Thres_Min; int m_nTopCornerIns_Thres_Max; int m_nTopCornerIns_Min_Size; int m_nTopCornerIns_Defect_Size_Dilation; int m_nTopCorner_Measure_Judge_Std_um_X; int m_nTopCorner_Measure_Judge_Min_um_X; int m_nTopCorner_Measure_Judge_Max_um_X; int m_nTopCorner_Measure_Judge_Std_um_Y; int m_nTopCorner_Measure_Judge_Min_um_Y; int m_nTopCorner_Measure_Judge_Max_um_Y; int m_nTopCorner_Measure_Judge_OR_AND; int m_nTopCorner_Judge_Size_Min_X_um; int m_nTopCorner_Judge_Size_Min_Y_um; int m_nTopCorner_Judge_Size_Min_OR_AND; // 0 : No Use, 1 : OR, 2 : AND // Bottom Corner Size int m_nBottomCornerShape; // 0 : CCut, 1 : RCut BOOL m_bBottomCornerFindDefect; BOOL m_bBottomCornerMeasureSize; int m_nBottomCornerEdgeFilterSize; int m_nBottomCornerEdgeThreshold; int m_nBottomCornerSizeX_um; int m_nBottomCornerSizeY_um; BOOL m_bBottomCornerDimension_Use[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dBottomCornerDimensionSpec_mm_Std[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dBottomCornerDimensionSpec_mm_Min[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dBottomCornerDimensionSpec_mm_Max[MAX_CORNER_DIMENSION_MEASURE_COUNT]; BOOL m_bBottomCornerChamfer_Use[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dBottomCornerChamfer_Spec_mm_Std[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dBottomCornerChamfer_Spec_mm_Min[MAX_CORNER_DIMENSION_MEASURE_COUNT]; double m_dBottomCornerChamfer_Spec_mm_Max[MAX_CORNER_DIMENSION_MEASURE_COUNT]; int m_nBottomCornerIns_StartOffset; int m_nBottomCornerIns_Range; int m_nBottomCornerIns_Thres_Min; int m_nBottomCornerIns_Thres_Max; int m_nBottomCornerIns_Min_Size; int m_nBottomCornerIns_Defect_Size_Dilation; int m_nBottomCorner_Measure_Judge_Std_um_X; int m_nBottomCorner_Measure_Judge_Min_um_X; int m_nBottomCorner_Measure_Judge_Max_um_X; int m_nBottomCorner_Measure_Judge_Std_um_Y; int m_nBottomCorner_Measure_Judge_Min_um_Y; int m_nBottomCorner_Measure_Judge_Max_um_Y; int m_nBottomCorner_Measure_Judge_OR_AND; int m_nBottomCorner_Judge_Size_Min_X_um; int m_nBottomCorner_Judge_Size_Min_Y_um; int m_nBottomCorner_Judge_Size_Min_OR_AND; // 0 : No Use, 1 : OR, 2 : AND // Top Mark BOOL m_bTopMark_Use; int m_nTopMarkToEdgeY_um; int m_nTopMarkToEdgeX_um; double m_dTopMarkTemplateMatchingRate; int m_nTopMarkType; // 0 : Black Mark, 1 : White Mark, 2 : Image Matching // Bottom Mark BOOL m_bBottomMark_Use; int m_nBottomMarkToEdgeY_um; int m_nBottomMarkToEdgeX_um; double m_dBottomMarkTemplateMatchingRate; int m_nBottomMarkType; // 0 : Black Mark, 1 : White Mark, 2 : Image Matching // Find Side Line int m_nSideDimensionCount; int m_nSideDimensionPos_TopMarkToDistance_um[MAX_SIDE_DIMENSION_MEASURE_COUNT]; BOOL m_bSideDimension_Use[MAX_SIDE_DIMENSION_MEASURE_COUNT]; int m_nSideDimensionSpec_Thres[MAX_SIDE_DIMENSION_MEASURE_COUNT]; double m_dSideDimensionSpec_mm_Std[MAX_SIDE_DIMENSION_MEASURE_COUNT]; double m_dSideDimensionSpec_mm_Min[MAX_SIDE_DIMENSION_MEASURE_COUNT]; double m_dSideDimensionSpec_mm_Max[MAX_SIDE_DIMENSION_MEASURE_COUNT]; double m_dSideDimensionSpec_mm_Off[MAX_SIDE_DIMENSION_MEASURE_COUNT]; BOOL m_bSideChamfer_Use[MAX_SIDE_DIMENSION_MEASURE_COUNT]; double m_dSideChamfer_Spec_mm_Std[MAX_SIDE_DIMENSION_MEASURE_COUNT]; double m_dSideChamfer_Spec_mm_Min[MAX_SIDE_DIMENSION_MEASURE_COUNT]; double m_dSideChamfer_Spec_mm_Max[MAX_SIDE_DIMENSION_MEASURE_COUNT]; // Judge Area int m_nCenterJudgeArea_StartLine_To_Start_pxl; int m_nCenterJudgeArea_StartLine_To_End_pxl; // Inspect Param CSIDE_INSPECTT_PARM m_InspectPrm[MAX_SIDE_INSPECT_TYPE]; //pose direction CString m_strPosDirection; // Notch int m_nNotchCount; CNOTCH_PARM m_NotchPrm[MAX_SIDE_NOTCH_COUNT]; // Exception int m_nExptionCount; CEXCEPTION_AREA_PARM m_ExpAreaPrm[MAX_SIDE_EXCEPTION_AREA_COUNT]; // User Defect int m_nUserDefectAreaCount; CUSER_DEFECT_AREA_PARM m_UserDefectPrm[MAX_SIDE_USER_DEFECT_AREA_COUNT]; }; class CGlassRecipe { public: CGlassRecipe(void); virtual ~CGlassRecipe(void); public: BOOL ReadRecipe(CConfig *pFile); BOOL WriteRecipe(CConfig *pFile); BOOL WriteRecipeFile(); BOOL WriteRecipeFileBackUp(); BOOL MakeRecipeFileName(CString strRecipe); BOOL MakeRecipeFileNameBackUp(CString strRecipe); BOOL ReadRecipeFile(); int GetLightValue(int iCon,int iCh); CString GetRecipeName(); void Reset(); BOOL Save_Image(CString strPath,IplImage *IpImg); BOOL Load_Image(CString strPath,IplImage **pIpImg); BOOL LoadRecipeConfigFile(CString strRecipe); BOOL SaveRecipeConfigFile(CString strRecipe); public: CRECIPE_INFO_COFG m_RecieCofg; CRECIPE_INFO_PARM m_RecieParm; CLIGHT_PARM m_LightParm; CSIDE_PARM m_SideParam[MAX_DIMENSION_COUNT]; protected: // CConfig m_RecipeFile; };