Exemplo n.º 1
0
        public bool Read(string Path)
        {
            bool IsOk = true;
            // BasePath = System.IO.Directory.GetCurrentDirectory();
            string path = Path + ConfigName + @"\";

            this.localSetting = XML <LocalSettingPara> .Read(path + "LocalSetting.xml");

            this.Template = XML <St_TemplateParam> .Read(path + "Template.xml");

            this.Lines = XML <St_LinesParam> .Read(path + "Lines.xml");

            this.Circles = XML <St_CirclesParam> .Read(path + "Circles.xml");

            this.Blobs = XML <St_BlobLocalParam> .Read(path + "Blobs.xml");

            this.LineCirRectInspParam = XML <St_InspectImageSetting> .Read(path + "LineCirRectInspParam.xml");

            if (localSetting == null)
            {
                return(true);
            }
            if (localSetting.localModel.ToString().Contains("Temp"))
            {
                Template.Load(path);
            }
            return(IsOk);
        }
Exemplo n.º 2
0
 //LocalPara VisionParaIn,   St_BlobInspectParam1 blobInSpectParam, HWindow InHWindow, HObject ImgIn, Action<bool> drawRoiInHWindow
 public SubFrmRecheck(LocalPara VisionParaIn, St_InspectImageSetting setting, ViewControl viewIn, HObject ImgIn, Action <bool> drawRoiInHWindow)
 {
     InitializeComponent();
     TeachLocalPara      = VisionParaIn;
     InspectImageSetting = setting;
     if (ImgIn != null && ImgIn.IsInitialized())
     {
         GrabedImg = ImgIn;
     }
     myView             = viewIn;
     ActionIsDrawingRoi = drawRoiInHWindow;
 }
Exemplo n.º 3
0
        public static bool LineCircleRectInsp(HObject ImgIn, St_InspectImageSetting LineCircleRectParaIn, out HObject DetectContours, out HObject BadRegions)
        {
            bool LineIsOK = true, CircleIsOk = true, RectIsOk = true;
            St_InspectImageSetting ImgInspectPara0 = LineCircleRectParaIn;

            HOperatorSet.GenEmptyObj(out BadRegions);
            HOperatorSet.GenEmptyObj(out DetectContours);
            //3.1直线区域检测
            HObject LineBadRegions = new HObject(), DetectLineContours = new HObject();

            HOperatorSet.GenEmptyObj(out LineBadRegions);
            HOperatorSet.GenEmptyObj(out DetectLineContours);
            LineIsOK = MyVisionBase.DectectLines(ImgIn, ImgInspectPara0.InspectLinePara, out LineBadRegions, out DetectLineContours);
            HOperatorSet.ConcatObj(BadRegions, LineBadRegions, out BadRegions);
            HOperatorSet.ConcatObj(DetectLineContours, DetectContours, out DetectContours);
            //3.2圆形区域检测
            HObject CircleBadRegion = new HObject(), DetectCircleContours = new HObject();

            HOperatorSet.GenEmptyObj(out CircleBadRegion);
            HOperatorSet.GenEmptyObj(out DetectCircleContours);
            CircleIsOk = MyVisionBase.DetectCircles(ImgIn, ImgInspectPara0.InspectCirclePara, out CircleBadRegion, out DetectCircleContours);
            HOperatorSet.ConcatObj(BadRegions, CircleBadRegion, out BadRegions);
            HOperatorSet.ConcatObj(DetectCircleContours, DetectContours, out DetectContours);
            //3.3矩形区域检测
            HObject RectBadRegion = new HObject(), DetectRectContours = new HObject();

            HOperatorSet.GenEmptyObj(out RectBadRegion);
            HOperatorSet.GenEmptyObj(out DetectRectContours);
            St_InspectRectanglePara NowRectPara = new St_InspectRectanglePara(ImgInspectPara0.InspectRectPara.Cols.Count(), true);

            NowRectPara = ImgInspectPara0.InspectRectPara;
            RectIsOk    = MyVisionBase.DetetctRectangles(ImgIn, ImgInspectPara0.InspectRectPara, out RectBadRegion, out DetectRectContours);
            HOperatorSet.ConcatObj(RectBadRegion, BadRegions, out BadRegions);
            HOperatorSet.ConcatObj(DetectRectContours, DetectContours, out DetectContours);
            if (LineIsOK && CircleIsOk && RectIsOk)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 4
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;
        }