Example #1
0
        protected virtual void OnMatcihngEvent(MatchingResualArgs e)
        {
            EventHandler <MatchingResualArgs> handler = this.MatchingResualCallback;

            if (handler != null)
            {
                handler.BeginInvoke(this, e, null, e);
            }
        }
Example #2
0
        private void _matching_MatchingResualCallback(object sender, MatchingResualArgs e)
        {
            this.BeginInvoke(new MethodInvoker(delegate
            {
                if (e.Resual != null)
                {
                    this.viewPort.HalconWindow.SetColor("green");
                    this.viewPort.HalconWindow.WriteString("OK");

                    for (int i = 0; i < e.Resual.Count; i++)
                    {
                        this._resualId++;

                        this.viewPort.HalconWindow.DispCross(e.Resual[i].Row, e.Resual[i].Column, 16.0, e.Resual[i].Angle);
                        //this._matchingResual.Add(e.Resual[i]);
                        this._matchingResual.Add(new Model.MatchingResual(this._resualId, e.Resual[i].Row, e.Resual[i].Column, e.Resual[i].Angle, e.Resual[i].Score));

                        #region roi仿射变换

                        List <ViewWindow.Model.RoiData> m_CheckRoiParameterTrans;
                        HObject m_CheckRoiTrans, m_Arrow;

                        Model.MatchingConfig.tansRoiData(this._regions, this._regionsCheckRoi,
                                                         new Model.MatchingResual(this._resualId, e.Resual[i].Row, e.Resual[i].Column, e.Resual[i].Angle, e.Resual[i].Score),
                                                         out m_CheckRoiParameterTrans, out m_CheckRoiTrans, out m_Arrow);

                        if (m_CheckRoiParameterTrans != null)
                        {
                            //if (m_CheckRoiParameterTrans.Count > 0)
                            //{
                            //    this._windowControl.displayROI(m_CheckRoiParameterTrans);
                            //}
                            HOperatorSet.DispObj(m_CheckRoiTrans, this.viewPort.HalconWindow);
                            HOperatorSet.DispObj(m_Arrow, this.viewPort.HalconWindow);
                        }


                        //HObject m_Regions;
                        //HOperatorSet.GenEmptyObj(out m_Regions);
                        //Model.MatchingConfig.tansRegions(this._regions,
                        //    new Model.MatchingResual(this._resualId, e.Resual[i].Row, e.Resual[i].Column, e.Resual[i].Angle, e.Resual[i].Score),
                        //    out m_Regions);
                        //HOperatorSet.DispObj(m_Regions, this.viewPort.HalconWindow);



                        //List<ViewWindow.Model.RoiData> m_RoiParameterTrans;
                        //Model.MatchingConfig.tansRoiData(this._regions,
                        //        new Model.MatchingResual(this._resualId, e.Resual[i].Row, e.Resual[i].Column, e.Resual[i].Angle, e.Resual[i].Score),
                        //        out m_RoiParameterTrans);

                        //if (m_RoiParameterTrans != null)
                        //{
                        //    if (m_RoiParameterTrans.Count > 0)
                        //    {
                        //        this._windowControl.displayROI(m_RoiParameterTrans);

                        //    }
                        //}

                        #endregion
                    }
                }
                else
                {
                    this.viewPort.HalconWindow.SetColor("red");
                    this.viewPort.HalconWindow.WriteString("NG");
                }

                if ((this.cBcontinual.Checked) && (ListBoxTrainImage.SelectedIndex < this._listImages_Training.Count - 1))
                {
                    System.Threading.Thread.Sleep(200);
                    List <Model.MatchingResual> resual;
                    HObject ho_image;
                    HOperatorSet.GenEmptyObj(out ho_image);
                    ho_image.Dispose();

                    ListBoxTrainImage.SelectedIndex++;
                    string file = (string)ListBoxTrainImage.SelectedItem;

                    ho_image = (HObject)this._listImages_Training[file];

                    bool rct = this._matching.findShapeModel(ho_image, this.hv_ModelId, this._matchingConfig[0].FindModelParameter[0], out resual);

                    this._windowControl.displayImage(ho_image);
                }
                else
                {
                    this._canChangeTab             = true;
                    this.gb_ImageOperation.Enabled = true;
                    this.gb_Setting.Enabled        = true;
                }
            }));
        }