Ejemplo n.º 1
0
        private void UpCamea_FilterSet_SelectedIndexChanged(object sender, EventArgs e)
        {
            var cb   = (ComboBox)sender;
            var list = upSet.GetSet(cb.SelectedItem.ToString());

            if (list != null)
            {
                currentUpBinding = list; //local copy;
                uFilter_dataGridView.DataSource = currentUpBinding;
                upVideoProcessing.SetFunctionsList(currentUpBinding);
            }
        }
Ejemplo n.º 2
0
        /* Filter Set Management */
        /*************************/
        private void DownCamera_FilterSet_SelectedIndexChanged(object sender, EventArgs e)
        {
            var cb   = (ComboBox)sender;
            var list = downSet.GetSet(cb.SelectedItem.ToString());

            if (list != null)
            {
                currentDownBinding = list; //local copy
                dFilter_dataGridView.DataSource = currentDownBinding;
                downVideoProcessing.SetFunctionsList(currentDownBinding);
                Console.WriteLine("new downcamera set = " + currentDownBinding.GetHashCode());
            }
        }
        public static void DoNeedleErrorMeasurement(VideoProcessing vp)
        {
            var          cnc = Global.Instance.cnc;
            var          originalLocation = cnc.XYALocation;
            PartLocation testLocation     = Global.GoTo("Up Camera");

            cnc.Zdown(Properties.Settings.Default.focus_height, true);

            // setup camera
            vp.SetFunctionsList("Needle");
            vp.s.FindCircles = true;
            vp.s.Draw1mmGrid = true;
            var Needle = Global.Instance.needle;

            List <PartLocation> offsetError = new List <PartLocation>();

            for (int i = 0; i <= 360; i += 45)
            {
                testLocation.A = i;
                var pp = testLocation - Needle.NeedleOffset;

                Needle.Move_m(pp); // move to target
                // mark erro
                var circle = VideoDetection.GetClosestCircle(vp, 10);
                if (circle != null)
                {
                    vp.MarkA.Add(circle.ToScreenResolution().ToPartLocation().ToPointF());

                    circle.ToMMResolution();
                    offsetError.Add(circle.ToPartLocation());
                }
                Thread.Sleep(500); //wait 1 second
            }

            Global.Instance.mainForm.ShowSimpleMessageBox("Upcamera offset Error is " + PartLocation.Average(offsetError) + "\nMax Error is " + PartLocation.MaxValues(offsetError));

            cnc.Zup();
            cnc.CNC_XYA(originalLocation);

            //revert to previous state
            vp.Reset();
        }
Ejemplo n.º 4
0
        public static void DoNeedleErrorMeasurement(VideoProcessing vp)
        {
            var cnc = Global.Instance.cnc;
            var originalLocation = cnc.XYALocation;
            PartLocation testLocation = Global.GoTo("Up Camera");

            cnc.Zdown(Properties.Settings.Default.focus_height, true);

            // setup camera
            vp.SetFunctionsList("Needle");
            vp.s.FindCircles = true;
            vp.s.Draw1mmGrid = true;
            var Needle = Global.Instance.needle;

            List<PartLocation> offsetError = new List<PartLocation>();
            for (int i = 0; i <= 360; i += 45) {
                testLocation.A = i;
                var pp = testLocation - Needle.NeedleOffset;

                Needle.Move_m(pp); // move to target
                // mark erro
                var circle = VideoDetection.GetClosestCircle(vp, 10);
                if (circle != null) {
                    vp.MarkA.Add(circle.ToScreenResolution().ToPartLocation().ToPointF());

                    circle.ToMMResolution();
                    offsetError.Add(circle.ToPartLocation());
                }
                Thread.Sleep(500); //wait 1 second
            }

            Global.Instance.mainForm.ShowSimpleMessageBox("Upcamera offset Error is " + PartLocation.Average(offsetError) + "\nMax Error is " + PartLocation.MaxValues(offsetError));

            cnc.Zup();
            cnc.CNC_XYA(originalLocation);

            //revert to previous state
            vp.Reset();
        }
Ejemplo n.º 5
0
        public CameraView()
        {
            InitializeComponent();
            //call this function when closing
            //this.Closing +=new CancelEventHandler(Cleanup); //this is depreciated
            this.FormClosing += new FormClosingEventHandler(CameraView_FormClosing); //do not allow the cameraview to be closed by itself

            //setup key handeling
            KeyPreview = true;
            Global.Instance.mainForm.SetupCursorNavigation(Controls);
            KeyUp += Global.Instance.mainForm.My_KeyUp;

            //setup video processing
            // load the different filter blocks
            upSet   = new AForgeFunctionSet("UP");
            downSet = new AForgeFunctionSet("DOWN");
            HideFilters(); //start hidden

            //Setup Checkbox Bindings
            DownCamera_drawGrid_checkBox.DataBindings.Add("Checked", downSettings, "Draw1mmGrid", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCameraDrawCross_checkBox.DataBindings.Add("Checked", downSettings, "DrawCross", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCameraDrawBox_checkBox.DataBindings.Add("Checked", downSettings, "DrawBox", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCameraDrawTicks_checkBox.DataBindings.Add("Checked", downSettings, "DrawSidemarks", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCamFindCircles_checkBox.DataBindings.Add("Checked", downSettings, "FindCircles", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCamFindRectangles_checkBox.DataBindings.Add("Checked", downSettings, "FindRectangles", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCam_FindComponents_checkBox.DataBindings.Add("Checked", downSettings, "FindComponent", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCamera_FindFiducials_cb.DataBindings.Add("Checked", downSettings, "FindFiducial", false, DataSourceUpdateMode.OnPropertyChanged);

            UpCam_DrawCross.DataBindings.Add("Checked", upSettings, "DrawCross", false, DataSourceUpdateMode.OnPropertyChanged);
            UpCan_DrawBox.DataBindings.Add("Checked", upSettings, "DrawBox", false, DataSourceUpdateMode.OnPropertyChanged);
            UpCam_DrawDashedBox.DataBindings.Add("Checked", upSettings, "DrawDashedCross", false, DataSourceUpdateMode.OnPropertyChanged);
            UpCam_FindCircles.DataBindings.Add("Checked", upSettings, "FindCircles", false, DataSourceUpdateMode.OnPropertyChanged);
            UpCam_FindComponents.DataBindings.Add("Checked", upSettings, "FindComponent", false, DataSourceUpdateMode.OnPropertyChanged);
            UpCam_FindRectangles.DataBindings.Add("Checked", upSettings, "FindRectangles", false, DataSourceUpdateMode.OnPropertyChanged);

            //start video capture
            upVideoCapture    = new VideoCapture(CameraType.UpCamera);
            upVideoProcessing = new VideoProcessing(upVideoCapture, upSettings);
            upVideoCapture.FrameCaptureDelegates.Add(UpCameraVideoProcessingCallback);
            upVideoProcessing.SetFunctionsList("");

            downVideoCapture    = new VideoCapture(CameraType.DownCamera);
            downVideoProcessing = new VideoProcessing(downVideoCapture, downSettings);
            downVideoCapture.FrameCaptureDelegates.Add(DownCameraVideoProcessingCallback);
            downVideoProcessing.SetFunctionsList("");


            //fill combobox // todo - restore from defaults
            UpCamera_FilterSet.DataSource = new BindingSource {
                DataSource = upSet.GetNames()
            };
            DownCamera_FilterSet.DataSource = new BindingSource {
                DataSource = downSet.GetNames()
            };
            var videoSources = VideoCapture.GetVideoDeviceList();

            UpCam_ComboBox.DataSource = new BindingSource {
                DataSource = videoSources
            };
            DownCam_ComboBox.DataSource = new BindingSource {
                DataSource = videoSources
            };

            //load saved values
            var s = Properties.Settings.Default;

            if (s.UpCam_index != s.DownCam_index)
            {
                if (s.DownCam_index > 0 && s.DownCam_index <= videoSources.Count + 1)
                {
                    DownCam_ComboBox.SelectedIndex = s.DownCam_index - 1;
                    downVideoCapture.Start(DownCam_ComboBox.SelectedIndex);
                }

                if (s.UpCam_index > 0 && s.UpCam_index <= videoSources.Count + 1)
                {
                    UpCam_ComboBox.SelectedIndex = s.UpCam_index - 1;
                    upVideoCapture.Start(UpCam_ComboBox.SelectedIndex);
                }
            }

            //right click context menu
            ContextMenu cms = new System.Windows.Forms.ContextMenu();
            var         i   = Global.Instance;

            cms.MenuItems.Add(new MenuItem("Needle To Table (Probe) And Back", delegate { var x = i.cnc.XYLocation; if (i.needle.Move_m(x) && i.needle.ProbeDown() && i.cnc.Zup() && i.cnc.CNC_XY(x))
                                                                                          {
                                                                                          }
                                                                                          ; }));
            cms.MenuItems.Add(new MenuItem("Move To Closest Circle", delegate { i.mainForm.FindPositionAndMoveToClosest(Shapes.ShapeTypes.Circle, 5, .1); }));
            DownCamera_PictureBox.ContextMenu = cms;


            //bind editor values
            uFilter_dataGridView.DataSource             = currentUpBinding;
            dFilter_dataGridView.DataSource             = currentDownBinding;
            methodDataGridViewTextBoxColumn.DataSource  = Enum.GetValues(typeof(AForgeMethod));
            methodDataGridViewTextBoxColumn1.DataSource = Enum.GetValues(typeof(AForgeMethod));

            //monitor frame rate
            FPStimer.Elapsed += delegate { UpdateFPS(); };
            FPStimer.Start();
        }
Ejemplo n.º 6
0
        public CameraView()
        {
            InitializeComponent();
            //call this function when closing
            //this.Closing +=new CancelEventHandler(Cleanup); //this is depreciated
            this.FormClosing += new FormClosingEventHandler(CameraView_FormClosing); //do not allow the cameraview to be closed by itself

            //setup key handeling
            KeyPreview = true;
            Global.Instance.mainForm.SetupCursorNavigation(Controls);
            KeyUp += Global.Instance.mainForm.My_KeyUp;

            //setup video processing
            // load the different filter blocks
            upSet = new AForgeFunctionSet("UP");
            downSet = new AForgeFunctionSet("DOWN");
            HideFilters(); //start hidden

            //Setup Checkbox Bindings
            DownCamera_drawGrid_checkBox.DataBindings.Add("Checked", downSettings, "Draw1mmGrid", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCameraDrawCross_checkBox.DataBindings.Add("Checked", downSettings, "DrawCross", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCameraDrawBox_checkBox.DataBindings.Add("Checked", downSettings, "DrawBox", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCameraDrawTicks_checkBox.DataBindings.Add("Checked", downSettings, "DrawSidemarks", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCamFindCircles_checkBox.DataBindings.Add("Checked", downSettings, "FindCircles", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCamFindRectangles_checkBox.DataBindings.Add("Checked", downSettings, "FindRectangles", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCam_FindComponents_checkBox.DataBindings.Add("Checked", downSettings, "FindComponent", false, DataSourceUpdateMode.OnPropertyChanged);
            DownCamera_FindFiducials_cb.DataBindings.Add("Checked", downSettings, "FindFiducial", false, DataSourceUpdateMode.OnPropertyChanged);

            UpCam_DrawCross.DataBindings.Add("Checked", upSettings, "DrawCross", false, DataSourceUpdateMode.OnPropertyChanged);
            UpCan_DrawBox.DataBindings.Add("Checked", upSettings, "DrawBox", false, DataSourceUpdateMode.OnPropertyChanged);
            UpCam_DrawDashedBox.DataBindings.Add("Checked", upSettings, "DrawDashedCross", false, DataSourceUpdateMode.OnPropertyChanged);
            UpCam_FindCircles.DataBindings.Add("Checked", upSettings, "FindCircles", false, DataSourceUpdateMode.OnPropertyChanged);
            UpCam_FindComponents.DataBindings.Add("Checked", upSettings, "FindComponent", false, DataSourceUpdateMode.OnPropertyChanged);
            UpCam_FindRectangles.DataBindings.Add("Checked", upSettings, "FindRectangles", false, DataSourceUpdateMode.OnPropertyChanged);

            //start video capture
            upVideoCapture = new VideoCapture(CameraType.UpCamera);
            upVideoProcessing = new VideoProcessing(upVideoCapture, upSettings);
            upVideoCapture.FrameCaptureDelegates.Add(UpCameraVideoProcessingCallback);
            upVideoProcessing.SetFunctionsList("");

            downVideoCapture = new VideoCapture(CameraType.DownCamera);
            downVideoProcessing = new VideoProcessing(downVideoCapture, downSettings);
            downVideoCapture.FrameCaptureDelegates.Add(DownCameraVideoProcessingCallback);
            downVideoProcessing.SetFunctionsList("");

            //fill combobox // todo - restore from defaults
            UpCamera_FilterSet.DataSource = new BindingSource { DataSource = upSet.GetNames() };
            DownCamera_FilterSet.DataSource = new BindingSource { DataSource = downSet.GetNames() };
            var videoSources = VideoCapture.GetVideoDeviceList();
            UpCam_ComboBox.DataSource = new BindingSource { DataSource =  videoSources};
            DownCam_ComboBox.DataSource = new BindingSource { DataSource = videoSources};

            //load saved values
            var s = Properties.Settings.Default;
            if (s.UpCam_index != s.DownCam_index) {
                if (s.DownCam_index > 0 && s.DownCam_index <= videoSources.Count) {
                    DownCam_ComboBox.SelectedIndex = s.DownCam_index-1;
                    downVideoCapture.Start(DownCam_ComboBox.SelectedIndex);
                }

                if (s.UpCam_index > 0 && s.UpCam_index <= videoSources.Count) {
                    UpCam_ComboBox.SelectedIndex = s.UpCam_index-1;
                    upVideoCapture.Start(UpCam_ComboBox.SelectedIndex);
                }
            }

            //right click context menu
            ContextMenu cms = new System.Windows.Forms.ContextMenu();
            var i = Global.Instance;
            cms.MenuItems.Add(new MenuItem("Needle To Table (Probe) And Back", delegate {  var x = i.cnc.XYLocation; if (i.needle.Move_m(x) && i.needle.ProbeDown() && i.cnc.Zup() && i.cnc.CNC_XY(x)) { }; }));
            cms.MenuItems.Add(new MenuItem("Move To Closest Circle", delegate { i.mainForm.FindPositionAndMoveToClosest(Shapes.ShapeTypes.Circle, 5, .1); }));
            DownCamera_PictureBox.ContextMenu = cms;

            //bind editor values
            uFilter_dataGridView.DataSource = currentUpBinding;
            dFilter_dataGridView.DataSource = currentDownBinding;
            methodDataGridViewTextBoxColumn.DataSource = Enum.GetValues(typeof(AForgeMethod));
            methodDataGridViewTextBoxColumn1.DataSource = Enum.GetValues(typeof(AForgeMethod));

            //monitor frame rate
            FPStimer.Elapsed += delegate { UpdateFPS();};
            FPStimer.Start();
        }
Ejemplo n.º 7
0
        public CameraView()
        {
            InitializeComponent();
            this.Closing += new CancelEventHandler(Cleanup);

            //setup video processing
            // load the different filter blocks
            upSet   = new AForgeFunctionSet("UP");
            downSet = new AForgeFunctionSet("DOWN");
            HideFilters(); //start hidden

            //start video capture
            upVideoCapture    = new VideoCapture(CameraType.UpCamera);
            upVideoProcessing = new VideoProcessing(upVideoCapture);
            upVideoCapture.FrameCaptureDelegates.Add(UpCameraVideoProcessingCallback);
            upVideoProcessing.SetFunctionsList(currentUpBinding);

            downVideoCapture    = new VideoCapture(CameraType.DownCamera);
            downVideoProcessing = new VideoProcessing(downVideoCapture);
            downVideoCapture.FrameCaptureDelegates.Add(DownCameraVideoProcessingCallback);
            downVideoProcessing.SetFunctionsList(currentDownBinding);


            //fill combobox // todo - restore from defaults
            UpCamera_FilterSet.DataSource = new BindingSource {
                DataSource = upSet.GetNames()
            };
            DownCamera_FilterSet.DataSource = new BindingSource {
                DataSource = downSet.GetNames()
            };
            var videoSources = VideoCapture.GetVideoDeviceList();

            UpCam_ComboBox.DataSource = new BindingSource {
                DataSource = videoSources
            };
            DownCam_ComboBox.DataSource = new BindingSource {
                DataSource = videoSources
            };

            //load saved values
            var s = Properties.Settings.Default;

            if (s.DownCam_index > 0 && s.DownCam_index <= videoSources.Count + 1)
            {
                DownCam_ComboBox.SelectedIndex = s.DownCam_index - 1;
                downVideoCapture.Start(DownCam_ComboBox.SelectedIndex);
            }

            if (s.UpCam_index > 0 && s.UpCam_index <= videoSources.Count + 1 && s.UpCam_index != s.DownCam_index)
            {
                UpCam_ComboBox.SelectedIndex = s.UpCam_index - 1;
                upVideoCapture.Start(UpCam_ComboBox.SelectedIndex);
            }


            //bind editor values
            uFilter_dataGridView.DataSource             = currentUpBinding;
            dFilter_dataGridView.DataSource             = currentDownBinding;
            methodDataGridViewTextBoxColumn.DataSource  = Enum.GetValues(typeof(AForgeMethod));
            methodDataGridViewTextBoxColumn1.DataSource = Enum.GetValues(typeof(AForgeMethod));
        }