StartPreview() public method

Starts the video preview from the video source.
public StartPreview ( ) : void
return void
        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);
            }
        }
示例#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");
            }
        }