private void BTN_RGN_INFO_SEARCH_Click(object sender, EventArgs e) { RectangleF rcSearching = CControl.GetRectangleFrom_TextBox_Set(TXT_LOCAL_SEARCH_RGN_X, TXT_LOCAL_SEARCH_RGN_Y, TXT_LOCAL_SEARCH_RGN_W, TXT_LOCAL_SEARCH_RGN_H); uc_view_ptrn.iSet_Roi_Ptrn(Rectangle.Round(rcSearching)); uc_view_ptrn.Refresh(); }
private void BTN_RGN_INFO_PTRN_Click(object sender, EventArgs e) { RectangleF rcMatching = CControl.GetRectangleFrom_TextBox_Set(TXT_PTRN_TEACH_ROI_X, TXT_PTRN_TEACH_ROI_Y, TXT_PTRN_TEACH_ROI_W, TXT_PTRN_TEACH_ROI_H); uc_view_ptrn.iSet_Roi_Ptrn(Rectangle.Round(rcMatching)); uc_view_ptrn.Refresh(); }
private void BTN_PTRN_GET_LOCAL_SEARCHING_RGN_Click(object sender, EventArgs e) { Rectangle rc = uc_view_ptrn.iGet_Roi_Ptrn(); if (m_fm.param_ptrn.BOOL_GLOBAL_SEARCHING == false) { // not the global searching but there is no new drawn rectangle. if (rc.Width <= 0 && rc.Height <= 0) { // get the previous records rc = Rectangle.Round(CControl.GetRectangleFrom_TextBox_Set(TXT_LOCAL_SEARCH_RGN_X, TXT_LOCAL_SEARCH_RGN_Y, TXT_LOCAL_SEARCH_RGN_W, TXT_LOCAL_SEARCH_RGN_H)); } } // validation check if (m_speaker.Check_Is_Invalid_Figure(rc, uc_view_ptrn.VIEW_GetImageW(), uc_view_ptrn.VIEW_GetImageH()) == true) { return; } CControl.SetTextBoxFrom_RectangleF(rc, TXT_LOCAL_SEARCH_RGN_X, TXT_LOCAL_SEARCH_RGN_Y, TXT_LOCAL_SEARCH_RGN_W, TXT_LOCAL_SEARCH_RGN_H); uc_view_ptrn.VIEW_Set_Clear_DispObject(); uc_view_ptrn.iSet_Roi_Ptrn(rc); uc_view_ptrn.Refresh(); }
private void BTN_MATCHING_Click(object sender, EventArgs e) { uc_view_ptrn.VIEW_Set_Clear_DispObject(); //************************************************************************************* // get main image Bitmap bmpSource = MAIN_IMAGE.Clone() as Bitmap; //************************************************************************************* // get template image path and do verification. copy template if it is valid. string strPtrnFile = Path.Combine(m_fm.param_path.i06_PATH_IMG_PTRN, TXT_PTRN_FILE_NAME.Text); Bitmap bmpTemplate = null; if (m_speaker.Check_Is_Error_File_Path_Validity(strPtrnFile) == true) { // Error Case : empty path or non file existance return; } else if (m_speaker.Check_Is_Error_File_Path_Validity(strPtrnFile) == false) { bmpTemplate = Bitmap.FromFile(strPtrnFile).Clone() as Bitmap; } //************************************************************************************* // Set images if edge-based appraoches are required. if (CHK_PTRN_APPLY_EDGE_BASED.Checked == true) { bmpSource = _Ptrn_Preprocess_Edge(bmpSource); bmpTemplate = _Ptrn_Preprocess_Edge(bmpTemplate); } //************************************************************************************* // Get Searching Region RectangleF rcSearching = new RectangleF(); // searching region setting if (CHK_PTRN_SEARCH_GLOBAL.Checked == true) { rcSearching = new RectangleF(0, 0, bmpSource.Width, bmpSource.Height); } else if (CHK_PTRN_SEARCH_GLOBAL.Checked == false) { rcSearching = CControl.GetRectangleFrom_TextBox_Set(TXT_LOCAL_SEARCH_RGN_X, TXT_LOCAL_SEARCH_RGN_Y, TXT_LOCAL_SEARCH_RGN_W, TXT_LOCAL_SEARCH_RGN_H); } //************************************************************************************* // Set Base parameters & Do pattern matching RectangleF rcTemplate = new RectangleF(); PointF ptTemplateCenter = new PointF(); double fAccRatio = double.Parse(TXT_PTRN_ACC_RATIO.Text); double fMatchingRatio = m_pHandle.iPtrn_DoPtrn(bmpSource, bmpTemplate, fAccRatio, rcSearching, out rcTemplate, out ptTemplateCenter); //************************************************************************************* // Refreshes image view uc_view_ptrn.DrawPatternMathcing(ptTemplateCenter, rcTemplate); uc_view_ptrn.DrawRect(rcSearching, Color.Orange); uc_view_ptrn.Refresh(); //************************************************************************************* // print matching result _PRINT_MESSAGE(string.Format("MR = {0} %", fMatchingRatio.ToString("F2"))); _PRINT_MESSAGE(string.Format("POS[X,Y] = [{0},{1}]", ptTemplateCenter.X.ToString("F2"), ptTemplateCenter.Y.ToString("F2"))); //************************************************************************************* // write matching information to the region information text box CControl.SetTextBoxFrom_RectangleF(rcTemplate, TXT_PTRN_TEACH_ROI_X, TXT_PTRN_TEACH_ROI_Y, TXT_PTRN_TEACH_ROI_W, TXT_PTRN_TEACH_ROI_H); }
private void BTN_PTRN_APPLY_Click(object sender, EventArgs e) { PARAM_PTRN ptrn = new PARAM_PTRN(); ptrn.BOOL_EDGE_BASED /*********/ = CHK_PTRN_APPLY_EDGE_BASED.Checked; ptrn.BOOL_GLOBAL_SEARCHING /***/ = CHK_PTRN_SEARCH_GLOBAL.Checked; //************************************************************************************* // Makesure Teaching File Existance string strCurrentPtrnFile = TXT_PTRN_FILE_NAME.Text; /*****/ strCurrentPtrnFile = Path.Combine(m_fm.param_path.i06_PATH_IMG_PTRN, strCurrentPtrnFile); // path verification if (m_speaker.Check_Is_Error_File_Path_Validity(strCurrentPtrnFile) == true) { return; } ptrn.PTRN_FILE /***************/ = Path.GetFileName(strCurrentPtrnFile); //************************************************************************************* // Set Template Teaching Region and Verification RectangleF rcTeaching = CControl.GetRectangleFrom_TextBox_Set(TXT_PTRN_TEACH_ROI_X, TXT_PTRN_TEACH_ROI_Y, TXT_PTRN_TEACH_ROI_W, TXT_PTRN_TEACH_ROI_H); if (m_speaker.Check_Is_Invalid_Figure(rcTeaching, uc_view_ptrn.VIEW_GetImageW(), uc_view_ptrn.VIEW_GetImageH()) == true) { return; } ptrn.RC_TEMPLATE = rcTeaching; //************************************************************************************* // Set Searching Region if (CHK_PTRN_SEARCH_GLOBAL.Checked == false) { ptrn.RC_SEARCH_RGN = CControl.GetRectangleFrom_TextBox_Set(TXT_LOCAL_SEARCH_RGN_X, TXT_LOCAL_SEARCH_RGN_Y, TXT_LOCAL_SEARCH_RGN_W, TXT_LOCAL_SEARCH_RGN_H); } else if (CHK_PTRN_SEARCH_GLOBAL.Checked == true) { ptrn.RC_SEARCH_RGN = new RectangleF(0, 0, uc_view_ptrn.VIEW_GetImageW(), uc_view_ptrn.VIEW_GetImageH()); } //************************************************************************************* // Set Acceptance Ration and Verification double fACCR = CControl.GetDoubleFrom_TextBox(TXT_PTRN_ACC_RATIO); if (m_speaker.Check_Ptrn_Is_Error_Acceptance_ratio(fACCR) == true) { return; } ptrn.ACC_RATIO = fACCR; //************************************************************************************* eventDele_ApplyParamPtrn(ptrn); this.Hide(); }