예제 #1
0
        public void ShowOnMainWindow(Window MainWindow)
        {
            //To change the video device, a dispose is needed.
            if (Capture != null)
            {
                Capture.Dispose();
                Capture = null;
            }

            //Create capture object.
            if (VideoDevice != null)
            {
                var source = PresentationSource.FromVisual(MainWindow) as HwndSource;

                Capture = new CaptureWebcam(VideoDevice)
                {
                    PreviewWindow = source.Handle,
                    Scale         = Scale()
                };

                Capture.StartPreview();

                Capture.OnPreviewWindowResize(50, 40, new System.Drawing.Point(257, 1));
            }
        }
예제 #2
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 && PresentationSource.FromVisual(this) is HwndSource source)
            {
                Capture = new CaptureWebcam(VideoDevice, OpenPreview, source.Handle)
                {
                    Scale = Dpi.X
                };

                SizeChanged += (S, E) => OnSizeChange();

                if (IsVisible)
                {
                    Capture.StartPreview();
                }

                OnSizeChange();
            }
        }
예제 #3
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)
            {
                var source = PresentationSource.FromVisual(this) as HwndSource;

                Capture = new CaptureWebcam(VideoDevice)
                {
                    PreviewWindow = source.Handle,
                    Scale         = Scale()
                };

                SizeChanged += (s, e) => OnSizeChange();

                if (IsVisible)
                {
                    Capture.StartPreview();
                }

                OnSizeChange();
            }
        }
예제 #4
0
    public void Refresh()
    {
        try
        {
            //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 = Scale()
                };
                Capture.StartPreview();

                //Width = Height * ((double)Capture.Width / (double)Capture.Height);
            }
        }
        catch (Exception e)
        {
            LogWriter.Log(e, "It was not possible to access the webcam feed.");
            ErrorDialog.Ok("ScreenToGif", "It was not possible to access the webcam's feed", e.Message, e);
        }
    }
예제 #5
0
        public WebcamCapture(Filter Filter, Action OnClick)
        {
            _filter        = Filter;
            _onClick       = OnClick;
            _captureWebcam = new CaptureWebcam(Filter, OnClick, IntPtr.Zero);

            _captureWebcam.StartPreview();
        }
예제 #6
0
        public void UpdatePreview(IWindow Window, Rectangle Location)
        {
            if (Window != null)
            {
                Dispose();

                _captureWebcam = new CaptureWebcam(_filter, _onClick, Window.Handle);

                _captureWebcam.StartPreview();
            }

            _captureWebcam.OnPreviewWindowResize(Location.X, Location.Y, Location.Width, Location.Height);
        }
예제 #7
0
        public void UpdatePreview(IWindow Window, Rectangle Location)
        {
            _syncContext.Run(() =>
            {
                if (Window != null && _lastWin != Window.Handle)
                {
                    Dispose();

                    _captureWebcam = new CaptureWebcam(_filter, _onClick, Window.Handle);

                    _captureWebcam.StartPreview();

                    _lastWin = Window.Handle;
                }

                _captureWebcam.OnPreviewWindowResize(Location.X, Location.Y, Location.Width, Location.Height);
            });
        }
예제 #8
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);
            }
        }
예제 #9
0
        public void ShowOnMainWindow(Window MainWindow)
        {
            // To change the video device, a dispose is needed.
            if (Capture != null)
            {
                Capture.Dispose();
                Capture = null;
            }

            // Create capture object.
            if (VideoDevice != null && PresentationSource.FromVisual(MainWindow) is HwndSource source)
            {
                Capture = new CaptureWebcam(VideoDevice, OpenPreview, source.Handle)
                {
                    Scale = Dpi.X
                };

                Capture.StartPreview();

                Capture.OnPreviewWindowResize(50, 40, new Point(280, 1));
            }
        }
예제 #10
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");
            }
        }