public override bool doLocal()
        {
            LocalResult TempTwoCirLocalRlt = new LocalResult();

            NowResult = new LineCircRectRlt();

            try{
                MyTempTwoCirLocal.Set(NowImg, NowVisionPara);
                MyTempTwoCirLocal.doLocal();
                TempTwoCirLocalRlt = MyTempTwoCirLocal.GetResult();
                HTuple HomMat = new HTuple(); //
                //计算当前图片到示教图片的偏移矩阵
                HOperatorSet.VectorAngleToRigid(TempTwoCirLocalRlt.row, TempTwoCirLocalRlt.col, TempTwoCirLocalRlt.angle, TempTwoCirLocalRlt.TeachRow,
                                                TempTwoCirLocalRlt.TeachCol, TempTwoCirLocalRlt.TeachAngle, out HomMat);//
                HObject AffineImg = new HObject();
                //矫正图像位置
                HOperatorSet.AffineTransImage(NowImg, out AffineImg, HomMat, "constant", "false");
                ((LineCircRectRlt)NowResult).IsOk = LineCircleRectInspBase.LineCircleRectInsp(AffineImg, NowVisionPara.LineCirRectInspParam,
                                                                                              out ((LineCircRectRlt)NowResult).DetectContour, out ((LineCircRectRlt)NowResult).NgContour); //
                HOperatorSet.CopyObj(TempTwoCirLocalRlt.ShowContour, out ((LineCircRectRlt)NowResult).ShowContour, 1, -1);
                //位置的逆变换
                HOperatorSet.VectorAngleToRigid(TempTwoCirLocalRlt.TeachRow, TempTwoCirLocalRlt.TeachCol, TempTwoCirLocalRlt.TeachAngle,
                                                TempTwoCirLocalRlt.row, TempTwoCirLocalRlt.col, TempTwoCirLocalRlt.angle, out HomMat);//
                NowResult.AffineTransResult(HomMat, out NowResult);
                return(true);
            }
            catch (Exception e0)
            {
                Logger.PopError1(e0, false, "视觉运行错误日志");
                return(false);
            }
        }
示例#2
0
        public override bool doLocal()
        {
            NowResult = new LineCircRectRlt();
            BlobLocalRlt myBlobLocalRlt = new BlobLocalRlt();

            try {
                myBlobLocal.Set(NowImg, NowVisionPara);
                myBlobLocal.doLocal();
                myBlobLocalRlt = (BlobLocalRlt)myBlobLocal.GetResult();
                HTuple HomMat = new HTuple(); //
                //计算当前图片到示教图片的偏移矩阵
                HOperatorSet.VectorAngleToRigid(myBlobLocalRlt.row, myBlobLocalRlt.col, myBlobLocalRlt.angle,
                                                myBlobLocalRlt.TeachRow, myBlobLocalRlt.TeachCol, myBlobLocalRlt.TeachAngle, out HomMat);
                HObject AffineImg = new HObject();
                //矫正图像位置
                HOperatorSet.AffineTransImage(NowImg, out AffineImg, HomMat, "constant", "false");
                //开始检测
                ((LineCircRectRlt)NowResult).IsOk = LineCircleRectInspBase.LineCircleRectInsp(AffineImg, NowVisionPara.LineCirRectInspParam,
                                                                                              out ((LineCircRectRlt)NowResult).DetectContour, out ((LineCircRectRlt)NowResult).NgContour); //
                HOperatorSet.CopyObj(myBlobLocalRlt.ShowContour, out ((LineCircRectRlt)NowResult).ShowContour, 1, -1);
                //位置的逆变换
                HOperatorSet.VectorAngleToRigid(myBlobLocalRlt.TeachRow, myBlobLocalRlt.TeachCol, myBlobLocalRlt.TeachAngle,
                                                myBlobLocalRlt.row, myBlobLocalRlt.col, myBlobLocalRlt.angle, out HomMat);
                NowResult.AffineTransResult(HomMat, out NowResult);
                return(true);
            }
            catch
            {
                return(false);
            }
        }
示例#3
0
        private void btnRecheckTest_Click(object sender, EventArgs e)
        {
            btnRecheckTest.Enabled = false;
            if (!GrabedImg.IsInitialized())
            {
                MessageBox.Show("请先加载图片");
                return;
            }
            Task.Factory.StartNew(new Action(() => {
                HObject DetectContours = new HObject(), BadRegions = new HObject();
                bool IsOK = true;
                St_InspectImageSetting tmpInspectParam = new St_InspectImageSetting(true);
                tmpInspectParam          = InspectImageSetting;
                LocalManager MyLocalCtrl = new LocalManager();
                MyLocalCtrl.SetLocalModel(TeachLocalPara.localSetting.localModel);
                this.TeachLocalPara.LineCirRectInspParam = InspectImageSetting;
                MyLocalCtrl.SetParam(GrabedImg, TeachLocalPara);
                MyLocalCtrl.doLocal();
                LineCircRectRlt MyLineCircRectInspRlt = new LineCircRectRlt();
                MyLineCircRectInspRlt = (LineCircRectRlt)MyLocalCtrl.GetResult();
                this.myView.roiController.reset();
                this.myView.ResetWindow();
                this.myView.AddImage(GrabedImg);
                Thread.Sleep(200);
                this.myView.SetDraw("green");
                this.myView.AddViewObject(MyLineCircRectInspRlt.DetectContour);
                this.myView.AddViewObject(MyLineCircRectInspRlt.ShowContour);
                this.myView.SetDraw("red");
                this.myView.AddViewObject(MyLineCircRectInspRlt.NgContour);
                this.myView.Repaint();
                if (MyLineCircRectInspRlt.IsOk)
                {
                    this.myView.SetString(20, 50, "green", "复检OK");
                }
                else
                {
                    this.myView.SetString(100, 100, "Red", "复检NG");
                }
            }));

            Thread.Sleep(500);
            btnRecheckTest.Enabled = true;
        }