Beispiel #1
0
 public void UpdateViewData(int val)
 {
     switch (val)
     {
     case ViewROI.ROIController.EVENT_CHANGED_ROI_SIGN:
     case ViewROI.ROIController.EVENT_DELETED_ACTROI:
     case ViewROI.ROIController.EVENT_UPDATE_ROI:
         bool genROI = view1.roiController.defineModelROI();
         ModelRoi = view1.roiController.getModelRegion();
         if (ModelRoi == null)
         {
             return;
         }
         if (!TemplateParam.CreateShapeModel(CurrentImage, ModelRoi))
         {
             Logger.PopError("模板创建失败!", true);
             return;
         }
         view1.ResetWindow();
         view1.AddViewObject(CurrentImage);
         view1.SetDraw("blue", "margin");
         view1.AddViewObject(ModelRoi);
         HXLD ModelContour = new HXLD();
         TemplateParam.GetShapeModelContour(out ModelContour);
         view1.SetDraw("green", "margin");
         view1.AddViewObject(ModelContour);
         view1.Repaint();
         break;
     }
 }
Beispiel #2
0
 private void GetProductPixelPosBtn_Click(object sender, EventArgs e)  //计算示教产品的像素的坐标,并保存到配置文件
 {
     this.GetProductPixelPosBtn.Enabled   = false;
     this.ProductPixelPosTeachBtn.Enabled = true;
     try
     {
         LocalResult  localResult = new LocalResult();
         LocalManager myLocal     = new LocalManager();
         //1.0设置定位模式
         myLocal.SetLocalModel(LocalPara0.localSetting.localModel);
         //2.0设置定位参数
         myLocal.SetParam(CurImg, LocalPara0);
         //3.执行定位
         myLocal.doLocal();
         localResult = myLocal.GetResult();
         this.LocalPara0.localSetting.TeachImgLocal = new St_VectorAngle(localResult.row, localResult.col, localResult.angle);
         view1.ResetWindow();
         view1.AddImage(CurImg.CopyObj(1, -1));
         view1.SetDraw("blue", "margin");
         view1.AddViewObject(localResult.ShowContour.CopyObj(1, -1));
         view1.Repaint();
         this.ProductPixelPosTbx.Text = "Col:" + localResult.col.ToString("f2") + "   Row:" + localResult.row.ToString("f2") +
                                        "   Angle:" + localResult.angle.ToString("f2");
     }
     catch
     { }
 }
Beispiel #3
0
        private void DrawLinesProcess()
        {
            ShowRoiFlag = true;
            HObject RoiContour = new HObject();
            HObject DetectRegions = new HObject();
            HTuple  ResultRows = new HTuple(), ResultCols = new HTuple();

            #region  //直线参数示教
            //2.1画出直线的检测区域
            bool CurIsOk = true;
            this.myView.AddViewImage(GrabedImg);
            while (ShowRoiFlag)
            {
                try  {
                    //2.2显示直线的检测ROI,调整ROI的参数
                    Thread.Sleep(10);
                    myView.ResetWindow();
                    myView.AddImage(GrabedImg);
                    CurIsOk = MyVisionBase.gen_rake_ROI1(GrabedImg, out DetectRegions, out RoiContour,
                                                         Element, DetectHeight, Threshold, LineRow1, LineCol1, LineRow2, LineCol2);
                    myView.Repaint();
                    Thread.Sleep(100);
                    myView.SetDraw("blue", "margin");
                    myView.AddViewObject(RoiContour);
                    myView.Repaint();
                    Thread.Sleep(300);
                    //2.5显示测量出每个示教小ROI的平均灰度,并保存到ListGrays变量中
                    HTuple MeanGrays = new HTuple(), GrayDivs = new HTuple();
                    HOperatorSet.Intensity(DetectRegions, GrabedImg, out MeanGrays, out GrayDivs);
                    MyVisionBase.HTupleToList(MeanGrays, out ListGrays);
                }
                catch (Exception e0) {
                    MessageBox.Show(e0.Message + e0.Source);
                    StartTeachBtn1.Enabled = true;
                    break;
                }
            }
            #endregion
        }