Esempio n. 1
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();
        }
Esempio n. 2
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));
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
 public VideoProcessing(VideoCapture vc, VideoOverlaySettings settings)
 {
     videoCapture = vc;
     s            = settings;
 }