Ejemplo n.º 1
0
        private void Frm_MaskEditor_Load(object sender, EventArgs e)
        {
            hWindowControl1.HMouseDown  += HWindowControl1_HMouseDown;
            hWindowControl1.HMouseMove  += HWindowControl1_HMouseMove;
            hWindowControl1.HMouseUp    += HWindowControl1_HMouseUp;
            hWindowControl1.HMouseWheel += HWindowControl1_HMouseWheel;

            hWndCtrller = new HWndCtrller(hWindowControl1);
            hWindowControl1.SizeChanged += (s, ev) => { hWndCtrller.Repaint(); };
            hWndCtrller.RegisterROICtroller(ctrller);


            if (hImage.IsInitialized())
            {
                hImage.GetImageSize(out imageWidth, out imageHeigh);
                hWndCtrller.AddIconicVar(hImage);
                hWndCtrller.Repaint();
            }
            AdjHalconWindow(panel2, hWindowControl1);

            toolStripMenuItem1.PerformClick();
            SetFromDisplay();


            hWndCtrller.SetGUICompRangeX(new int[] { XTrackBar.Minimum,
                                                     XTrackBar.Maximum },
                                         XTrackBar.Value);
            hWndCtrller.SetGUICompRangeY(new int[] { YTrackBar.Minimum,
                                                     YTrackBar.Maximum },
                                         YTrackBar.Maximum - YTrackBar.Value);
        }
Ejemplo n.º 2
0
 private void MainCamera_HInitWindow(object sender, EventArgs e)
 {
     if (!DesignMode)
     {
         hWndCtrller       = new HWndCtrllerEx(this, this.Locker);
         this.SizeChanged += (s, ev) => { hWndCtrller.Repaint(); };
     }
 }
Ejemplo n.º 3
0
        private void Frm_CheckStick_Load(object sender, EventArgs e)
        {
            hWndCtrller = new HWndCtrllerEx(hWindowControl1);
            hWndCtrller.ChangeGraphicSettings("DrawMode", "margin");
            hWndCtrller.ChangeGraphicSettings("Color", "green");

            ((HWndCtrllerEx)hWndCtrller).Paint += Frm_CheckStick_Paint;
            hWindowControl1.SizeChanged        += (s, ev) => { hWndCtrller.Repaint(); };

            hWindowControl1.HMouseMove  += HWindowControl1_HMouseMove;
            hWindowControl1.HMouseUp    += HWindowControl1_HMouseUp;
            hWindowControl1.HMouseWheel += HWindowControl1_HMouseWheel;
            hWndCtrller.RegisterROICtroller(ctrller);


            ShapeModel model = VisionProject.Instance.visionTool.checkStick.Location;

            if (model.ModelImg != null && model.ModelImg.IsInitialized())
            {
                hWndCtrller.AddIconicVar(model.ModelImg.Clone());
                hWndCtrller.Repaint();
            }
            hWindowControl1.HalconWindow.SetColor("blue");
            foreach (var item in VisionProject.Instance.visionTool.checkStick.CheckRegion)
            {
                if (item != null && item.IsInitialized())
                {
                    this.hWindowControl1.HalconWindow.DispObj(item);
                }
            }
            trackBar1.Value    = (int)VisionProject.Instance.visionTool.checkStick.Threshold;
            DrawRegionCtrlFlag = 0;

            if (VisionProject.Instance.visionApi.CheckStick.Count == 4)
            {
                label3.Text = string.Format("上:X={0:0.00},Y={1:0.00},R={2:0.00}",
                                            VisionProject.Instance.visionApi.CheckStick[0].X,
                                            VisionProject.Instance.visionApi.CheckStick[0].Y,
                                            VisionProject.Instance.visionApi.CheckStick[0].R);
                label5.Text = string.Format("下:X={0:0.00},Y={1:0.00},R={2:0.00}",
                                            VisionProject.Instance.visionApi.CheckStick[1].X,
                                            VisionProject.Instance.visionApi.CheckStick[1].Y,
                                            VisionProject.Instance.visionApi.CheckStick[1].R);
                label4.Text = string.Format("左:X={0:0.00},Y={1:0.00},R={2:0.00}",
                                            VisionProject.Instance.visionApi.CheckStick[2].X,
                                            VisionProject.Instance.visionApi.CheckStick[2].Y,
                                            VisionProject.Instance.visionApi.CheckStick[2].R);
                label6.Text = string.Format("右:X={0:0.00},Y={1:0.00},R={2:0.00}",
                                            VisionProject.Instance.visionApi.CheckStick[3].X,
                                            VisionProject.Instance.visionApi.CheckStick[3].Y,
                                            VisionProject.Instance.visionApi.CheckStick[3].R);
            }
        }
Ejemplo n.º 4
0
        private void Frm_NccModelControl_Load(object sender, EventArgs e)
        {
            hWndCtrller = new HWndCtrller(hWindowControl1);
            hWindowControl1.SizeChanged += (s, ev) => { hWndCtrller.Repaint(); };

            hWindowControl1.HMouseMove  += HWindowControl1_HMouseMove;
            hWindowControl1.HMouseUp    += HWindowControl1_HMouseUp;
            hWindowControl1.HMouseWheel += HWindowControl1_HMouseWheel;
            hWndCtrller.RegisterROICtroller(ctrller);

            AdjHalconWindow(panel2, hWindowControl1);

            comboBox2.Items.Clear();
            comboBox2.Items.Add("矩形");
            comboBox2.Items.Add("圆");
            comboBox2.Items.Add("矩形2");
            comboBox2.SelectedIndex = 0;


            if (nCCModel == null)
            {
                nCCModel = new NCCModel();
            }

            if (nCCModel.nCCModel == null || !nCCModel.nCCModel.IsInitialized())
            {
            }
            else
            {
                InspectModel();
            }


            //if (nCCModel.InputImg != null && nCCModel.InputImg.IsInitialized())
            //{
            //    nCCModel.InputImg.GetImageSize(out imageHeigh, out imageWidth);
            //    hWndCtrller.AddIconicVar(nCCModel.InputImg);
            //    hWndCtrller.Repaint();
            //}



            SafeSetUpDownRange(StartingAngleUpDown, DegFromRad(nCCModel.nCCParam.mStartingAngle));
            SafeSetUpDownRange(AngleExtentUpDown, DegFromRad(nCCModel.nCCParam.mAngleExtent));
            SafeSetUpDownRange(AngleStepUpDown, DegFromRad(nCCModel.nCCParam.AngleStep) * 10);
            SafeSetUpDownRange(numUpDwnNumLevels, (nCCModel.nCCParam.NumLevels));


            if (nCCModel.nCCParam.Metric == "use_polarity")
            {
                MetricBox.SelectedIndex = 0;
            }
            else if (nCCModel.nCCParam.Metric == "ignore_global_polarity")
            {
                MetricBox.SelectedIndex = 1;
            }

            if (nCCModel.nCCParam.SubPixel == "true")
            {
                comboBox1.SelectedIndex = 0;
            }
            else if (nCCModel.nCCParam.SubPixel == "false")
            {
                comboBox1.SelectedIndex = 1;
            }


            SafeSetUpDownRange(numericUpDown6, nCCModel.nCCParam.MinScore * 100);
            SafeSetUpDownRange(numericUpDown7, nCCModel.nCCParam.NumMatches);
            SafeSetUpDownRange(numericUpDown1, nCCModel.nCCParam.mMaxOverlap * 100);
            SafeSetUpDownRange(numericUpDown2, nCCModel.OutTime);

            checkBox1.Checked = nCCModel.TimeOutEnable;
            checkBox2.Checked = nCCModel.nCCParam.IsAuto(NCCParam.AUTO_ANGLE_STEP);
            checkBox3.Checked = nCCModel.nCCParam.IsAuto(NCCParam.AUTO_NUM_LEVEL);
        }
        private void Frm_ShapeModelControl_Load(object sender, EventArgs e)
        {
            tabControl2.TabPages.Remove(tabPage4);
            tabControl3.TabPages.Remove(tabPage6);


            hWndCtrller = new HWndCtrller(hWindowControl1);
            hWindowControl1.SizeChanged += (s, ev) => { hWndCtrller.Repaint(); };

            hWindowControl1.HMouseMove  += HWindowControl1_HMouseMove;
            hWindowControl1.HMouseUp    += HWindowControl1_HMouseUp;
            hWindowControl1.HMouseWheel += HWindowControl1_HMouseWheel;
            hWndCtrller.RegisterROICtroller(ctrller);

            comboBox2.Items.Clear();
            comboBox2.Items.Add("矩形");
            comboBox2.Items.Add("圆");
            comboBox2.Items.Add("矩形2");
            comboBox2.SelectedIndex = 0;


            if (Model == null)
            {
                Model = new ShapeModel();
            }

            if (Model.ModelImg != null && Model.ModelImg.IsInitialized())
            {
                Model.ModelImg.GetImageSize(out imageWidth, out imageHeigh);
                hWndCtrller.AddIconicVar(Model.ModelImg);
                //hWndCtrller.Repaint();
            }
            toolStripStatusLabel1.Text = "耗时:" + Model.OutputResult.Time.ToString();


            if (Model.shapeModel == null || !Model.shapeModel.IsInitialized())
            {
                button6.Enabled = false;
                button5.Enabled = false;
            }
            else
            {
                InspectModel();
            }


            AdjHalconWindow(panel2, hWindowControl1);


            SafeSetUpDownRange(StartingAngleUpDown, DegFromRad(Model.shapeParam.mStartingAngle));
            SafeSetUpDownRange(AngleExtentUpDown, DegFromRad(Model.shapeParam.mAngleExtent));
            SafeSetUpDownRange(AngleStepUpDown, DegFromRad(Model.shapeParam.mAngleStep) * 10);

            SafeSetUpDownRange(numericUpDown5, Model.shapeParam.mMinScale);
            SafeSetUpDownRange(numericUpDown4, Model.shapeParam.mMaxScale);
            SafeSetUpDownRange(numericUpDown3, Model.shapeParam.mScaleStep * 100);

            SafeSetUpDownRange(numUpDwnNumLevels, Model.shapeParam.mNumLevel);
            SafeSetUpDownRange(numericUpDown9, Model.shapeParam.mContrast);
            SafeSetUpDownRange(numericUpDown8, Model.shapeParam.mMinContrast);


            if (Model.shapeParam.mOptimization == "none")
            {
                comboBox4.SelectedIndex = 0;
            }
            else if (Model.shapeParam.mOptimization == "point_reduction_low")
            {
                comboBox4.SelectedIndex = 1;
            }
            else if (Model.shapeParam.mOptimization == "point_reduction_medium")
            {
                comboBox4.SelectedIndex = 2;
            }
            else if (Model.shapeParam.mOptimization == "point_reduction_high")
            {
                comboBox4.SelectedIndex = 3;
            }

            if (Model.shapeParam.mMetric == "use_polarity")
            {
                comboBox3.SelectedIndex = 0;
            }
            else if (Model.shapeParam.mMetric == "ignore_global_polarity")
            {
                comboBox3.SelectedIndex = 1;
            }

            if (Model.shapeParam.mSubpixel == "none")
            {
                comboBox1.SelectedIndex = 0;
            }
            else if (Model.shapeParam.mSubpixel == "least_squares")
            {
                comboBox1.SelectedIndex = 1;
            }
            else if (Model.shapeParam.mSubpixel == "interpolation")
            {
                comboBox1.SelectedIndex = 2;
            }


            SafeSetUpDownRange(numericUpDown6, Model.shapeParam.mMinScore * 100);
            SafeSetUpDownRange(numericUpDown7, Model.shapeParam.mNumMatches);
            SafeSetUpDownRange(numericUpDown1, Model.shapeParam.mMaxOverlap * 100);
            SafeSetUpDownRange(numericUpDown2, Model.OutTime);
            SafeSetUpDownRange(numericUpDown10, Model.shapeParam.mGreediness);


            checkBox1.Checked = Model.TimeOutEnable;
            checkBox2.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_ANGLE_STEP);
            checkBox4.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_SCALE_STEP);
            checkBox3.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_NUM_LEVEL);
            checkBox7.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_OPTIMIZATION);
            checkBox5.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_CONTRAST);
            checkBox6.Checked = Model.shapeParam.IsAuto(ShapeParam.AUTO_MIN_CONTRAST);
        }