예제 #1
0
        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();
        }
예제 #2
0
        private void _ToUI_SetPTRNView(string strFileName, Rectangle rc)
        {
            string strFullFilePath = Path.Combine(m_fm.param_path.i06_PATH_IMG_PTRN, strFileName);

            // path verification
            if (m_speaker.Check_Is_Error_File_Path_Validity(strFullFilePath) == true)
            {
                return;
            }

            // just loading
            using (Bitmap bmp = Bitmap.FromFile(strFullFilePath) as Bitmap)
            {
                Bitmap buff = new Bitmap(bmp);
                // set display & backup
                PIC_PTRN_NORMAL.Image = buff.Clone() as Bitmap;
                MAIN_TEACH            = buff.Clone() as Bitmap;
                PIC_PTRN_EDGE.Image   = _Ptrn_Preprocess_Edge(buff.Clone() as Bitmap);

                // update file name
                TXT_PTRN_FILE_NAME.Text = strFileName;

                CControl.SetTextBoxFrom_RectangleF(rc, TXT_PTRN_TEACH_ROI_X, TXT_PTRN_TEACH_ROI_Y, TXT_PTRN_TEACH_ROI_W, TXT_PTRN_TEACH_ROI_H);

                CHK_PTRN_APPLY_EDGE_BASED.Checked = false;
            }
        }
예제 #3
0
        public bool SetParam(CFigureManager fm)
        {
            uc_view_ptrn.VIEW_Set_Clear_DispObject();

            m_fm = fm;

            // Set language type
            m_speaker.LANGUAGE = fm.LANGUAGE;

            // load ptrn setting
            PARAM_PTRN param_ptrn = fm.param_ptrn;

            // Check current ptrn teaching file
            string strPtrnPath = Path.GetFileName(param_ptrn.PTRN_FILE);

            /*****/ strPtrnPath = Path.Combine(m_fm.param_path.i06_PATH_IMG_PTRN, strPtrnPath);

            // check the status in case of empty ptrn teaching data info.
            if (m_speaker.Check_Ptrn_Is_Error_Teaching_File_Validity(strPtrnPath) == true)
            {
                return(false);
            }

            //*************************************************************************************
            // Set Draw Ptrn Image

            if (m_speaker.Check_Is_Error_File_Path_Validity(strPtrnPath) == false)
            {
                Bitmap bmpTemp = Bitmap.FromFile(strPtrnPath) as Bitmap;
                PIC_PTRN_NORMAL.Image = new Bitmap(bmpTemp);
                PIC_PTRN_EDGE.Image   = _Ptrn_Preprocess_Edge(bmpTemp);
                bmpTemp.Dispose();
            }
            else
            {
                param_ptrn.PTRN_FILE = string.Empty;
            }

            //*************************************************************************************
            // Display parameter

            TXT_PTRN_FILE_NAME.Text = param_ptrn.PTRN_FILE;
            TXT_PTRN_ACC_RATIO.Text = param_ptrn.ACC_RATIO.ToString("F4");

            CHK_PTRN_APPLY_EDGE_BASED.Checked = param_ptrn.BOOL_EDGE_BASED;
            CHK_PTRN_SEARCH_GLOBAL.Checked    = param_ptrn.BOOL_GLOBAL_SEARCHING;

            CControl.SetTextBoxFrom_RectangleF(param_ptrn.RC_SEARCH_RGN, TXT_LOCAL_SEARCH_RGN_X, TXT_LOCAL_SEARCH_RGN_Y, TXT_LOCAL_SEARCH_RGN_W, TXT_LOCAL_SEARCH_RGN_H);
            CControl.SetTextBoxFrom_RectangleF(param_ptrn.RC_TEMPLATE, TXT_PTRN_TEACH_ROI_X, TXT_PTRN_TEACH_ROI_Y, TXT_PTRN_TEACH_ROI_W, TXT_PTRN_TEACH_ROI_H);

            // set image on the view
            BTN_SET_INTERNAL_IMAGE_Click(null, EventArgs.Empty);

            // update ptrn file list
            BTN_UPDATE_PTRN_LIST_Click(null, EventArgs.Empty);

            // draw searcing region
            if (param_ptrn.BOOL_GLOBAL_SEARCHING == false &&
                param_ptrn.RC_SEARCH_RGN.Width != 0 &&
                param_ptrn.RC_SEARCH_RGN.Height != 0)
            {
                uc_view_ptrn.DrawRect(param_ptrn.RC_SEARCH_RGN, Color.Orange);
            }
            return(true);
        }
예제 #4
0
        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);
        }