public void HookEvents() { enabled = false; cfs = null; foreach (Camera cam in CameraService.AvailableCameras) { if (cam.Name == webcamName) { Console.Write(""); cfs = new CameraFrameSource(cam); break; } } if (cfs != null) { /* cfs.Camera.CaptureWidth = 1920; * cfs.Camera.CaptureHeight = 1080; * cfs.Camera.Fps = 30;*/ cfs.NewFrame += Cfs_NewFrame; try { cfs.StartFrameCapture(); stopWatch.Start(); captureStarted = true; } catch (Exception exc) { } } }
public CameraViewer(string camera) { InitializeComponent(); foreach (Camera item in CameraService.AvailableCameras) { if (item.Name == camera) { _Camera = item; } } try { _frameSource = new CameraFrameSource(_Camera); _frameSource.Camera.CaptureWidth = 640; _frameSource.Camera.CaptureHeight = 480; _frameSource.Camera.Fps = 50; _frameSource.NewFrame += OnImageCapturedCamera1; _frameSource.StartFrameCapture(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void startCapturing() { try { Camera c = (Camera)comboBoxCameras.SelectedItem; setFrameSource(new CameraFrameSource(c)); _frameSource.Camera.CaptureWidth = CaptureWidthLocal = Convert.ToInt32(textBoxWidth.Text); _frameSource.Camera.CaptureHeight = CaptureHeightLocal = Convert.ToInt32(textBoxHeight.Text); _frameSource.Camera.Fps = 30; _frameSource.NewFrame += OnImageCaptured; int PixelCount = CaptureWidthLocal * CaptureHeightLocal; _orig = new byte[PixelCount * 3]; arr1 = new byte[PixelCount]; arr2 = new byte[PixelCount]; arr3 = new byte[PixelCount]; _SobelArr = new byte[PixelCount]; _dest1 = new Bitmap(CaptureWidthLocal, CaptureHeightLocal, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); _dest2 = new Bitmap(CaptureWidthLocal, CaptureHeightLocal, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); _dest3 = new Bitmap(CaptureWidthLocal, CaptureHeightLocal, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); //_destSobel = new Bitmap(CaptureWidthLocal, CaptureHeightLocal, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); pictureBoxDisplay.Paint += new PaintEventHandler(drawLatestImage); pictureBox1.Paint += new PaintEventHandler(drawLatestImage1); pictureBox2.Paint += new PaintEventHandler(drawLatestImage2); pictureBox3.Paint += new PaintEventHandler(drawLatestImage3); _frameSource.StartFrameCapture(); } catch (Exception ex) { comboBoxCameras.Text = "Select A Camera"; MessageBox.Show(ex.Message); } }
public void StartCapturing() { // Early return if we've selected the current camera if (_frameSource != null && _frameSource.Camera == VideoDevicesComboBox.SelectedItem) { return; } StopCapturing(); try { Camera c = (Camera)VideoDevicesComboBox.SelectedItem; setFrameSource(new CameraFrameSource(c)); _frameSource.Camera.CaptureWidth = 700; _frameSource.Camera.CaptureHeight = 500; _frameSource.Camera.Fps = 50; _frameSource.NewFrame += OnImageCaptured; pictureBoxDisplay.Paint += new PaintEventHandler(drawLatestImage); _frameSource.StartFrameCapture(); } catch (Exception ex) { VideoDevicesComboBox.Text = "Select A Camera"; System.Windows.MessageBox.Show(ex.Message); } }
private void GetVideo() { try { _frameSource.Camera.CaptureWidth = 320; _frameSource.Camera.CaptureHeight = 240; _frameSource.Camera.Fps = 20; _frameSource.NewFrame += OnImageCaptured; _frameSource.StartFrameCapture(); } catch (Exception ex) { logger.Log("Error: Couldn't start frame capture on webcam {0}: {1}", _frameSource.Camera.ToString(), ex.ToString()); } }
public void StartVision(Camera c) { try { setFrameSource(new CameraFrameSource(c)); _frameSource.Camera.CaptureWidth = 320; _frameSource.Camera.CaptureHeight = 240; _frameSource.Camera.Fps = 20; _frameSource.NewFrame += OnImageCaptured; Control.Paint += new System.Windows.Forms.PaintEventHandler(drawLatestImage); _frameSource.StartFrameCapture(); } catch (Exception ex) { throw new Exception("Select a Camera"); } }
private void startCapturing() { try { Camera c = theCamera; if (_frameSource == null) { setFrameSource(new CameraFrameSource(c)); _frameSource.Camera.CaptureWidth = 640; //640; _frameSource.Camera.CaptureHeight = 360; // 480; _frameSource.Camera.Fps = 50; _frameSource.NewFrame += OnImageCaptured; _frameSource.StartFrameCapture(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void startCapturing() { try { Camera c = (Camera)comboBoxCameras.SelectedItem; setFrameSource(new CameraFrameSource(c)); _frameSource.Camera.CaptureWidth = 1280; //640; _frameSource.Camera.CaptureHeight = 720; //480; _frameSource.Camera.Fps = 50; _frameSource.NewFrame += OnImageCaptured; pictureBoxDisplay.Paint += new PaintEventHandler(drawLatestImage); cameraPropertyValue.Enabled = _frameSource.StartFrameCapture(); } catch (Exception ex) { comboBoxCameras.Text = "Select A Camera"; MessageBox.Show(ex.Message); } }
private void startCapturing() { try { Camera c = (Camera)comboBoxCameras.SelectedItem; setFrameSource(new CameraFrameSource(c)); _frameSource.Camera.CaptureWidth = 320; _frameSource.Camera.CaptureHeight = 240; _frameSource.Camera.Fps = 20; _frameSource.NewFrame += OnImageCaptured; picCam1.Paint += new PaintEventHandler(drawLatestImage); _frameSource.StartFrameCapture(); } catch (Exception ex) { comboBoxCameras.Text = "Select A Camera"; MessageBox.Show(ex.Message); } }
private void InitCamera() { // Configuramos la camara foreach (Camera cam in CameraService.AvailableCameras) { comboBoxCameras.Items.Add(cam); } comboBoxCameras.SelectedIndex = 0; comboBoxCameras.Select(); Camera c = (Camera)comboBoxCameras.SelectedItem; _frameSource = new CameraFrameSource(c); _frameSource.Camera.CaptureWidth = 320; _frameSource.Camera.CaptureHeight = 240; _frameSource.Camera.Fps = 20; _frameSource.NewFrame += OnImageCaptured; pictureBox1.Paint += new PaintEventHandler(drawLatestImage); _frameSource.StartFrameCapture(); }
/// <summary> /// Start streaming from SelectedCamera to PictureBox. /// </summary> /// <returns></returns> public bool Start() { bool success = false; try { if (_selectedCamera == null) { string emsg = "Error: Must set SelectedCamera before calling Webcam.Start()."; Debug.WriteLine(emsg); throw new ApplicationException(emsg); } Camera c = _selectedCamera; SetFrameSource(new CameraFrameSource(c)); _frameSource.Camera.CaptureWidth = Default_CaptureWidth; _frameSource.Camera.CaptureHeight = Default_CaptureHeight; _frameSource.Camera.Fps = Default_Fps; _frameSource.NewFrame += OnImageCaptured; _renderViewControl.Paint += DrawLatestImage; _frameSource.StartFrameCapture(); success = true; } catch (Exception ex) { if (MessageboxUponException) { MessageBox.Show("Exception attempting to start camera streaming. " + ex.Message, ex.GetType().Name); } } return(success); }
private void startCapturing() { try { Camera c = (Camera)comboBoxCameras.SelectedItem; setFrameSource(new CameraFrameSource(c)); _frameSource.Camera.CaptureWidth = 480; _frameSource.Camera.CaptureHeight = 360; _frameSource.Camera.Fps = 20; _frameSource.NewFrame += OnImageCaptured; ptbhinhhoivien.Paint += new PaintEventHandler(drawLatestImage); _frameSource.StartFrameCapture(); } catch (Exception ex) { comboBoxCameras.Text = "Select A Camera"; //MessageBox.Show(ex.Message); MessageBox.Show("Hệ thồng đang xử lý\n" + ex.Message, "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } }
public void startCapturing() { try { bool camStatus = false; string camName = ConfigurationManager.AppSettings["defaultcam"].ToString(); foreach (Camera cam in CameraService.AvailableCameras) { if (cam.Name == camName) { setFrameSource(new CameraFrameSource(cam)); camStatus = true; } } if (camStatus == true) { _frameSource.Camera.CaptureWidth = this.ImgControl.Width; _frameSource.Camera.CaptureHeight = this.ImgControl.Height; _frameSource.Camera.Fps = 50; _frameSource.NewFrame += OnImageCaptured; ImgControl.Paint += new PaintEventHandler(drawLatestImage); _frameSource.StartFrameCapture(); } else { MessageBox.Show("Please chech your camera connection.", "MediPro :: Clinic System", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }