Gets the video output of a webcam or other video device.
Inheritance: EditStreaming.ISampleGrabberCB, IDisposable
Ejemplo n.º 1
0
        public void Refresh()
        {
            //To change the video device, a dispose is needed.
            if (Capture != null)
            {
                Capture.Dispose();
                Capture = null;
            }

            //Create capture object.
            if (VideoDevice != null)
            {
                Capture = new CaptureWebcam(VideoDevice) { PreviewWindow = this, Scale = this.Scale() };
                Capture.StartPreview();

                //Width = Height * ((double)Capture.Width / (double)Capture.Height);
            }
        }
Ejemplo n.º 2
0
        private void VideoDevicesComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                // Get current devices and dispose of capture object
                // because the video device can only be changed
                // by creating a new Capture object.
                Filter videoDevice = null;

                // To change the video device, a dispose is needed.
                if (_capture != null)
                {
                    _capture.Dispose();
                    _capture = null;
                }

                // Get new video device
                videoDevice = (VideoDevicesComboBox.SelectedIndex > -1 ? _filters.VideoInputDevices[VideoDevicesComboBox.SelectedIndex] : null);

                // Create capture object
                if (videoDevice != null)
                {
                    _capture = new CaptureWebcam(videoDevice) { PreviewWindow = this };
                    _capture.StartPreview();

                    Height = _capture.Height + 70;
                    Width = _capture.Width;
                }
            }
            catch (Exception ex)
            {
                LogWriter.Log(ex, "Video device not supported");
            }
        }