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)); } }
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(); } }
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(); } }
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); } }
public WebcamCapture(Filter Filter, Action OnClick) { _filter = Filter; _onClick = OnClick; _captureWebcam = new CaptureWebcam(Filter, OnClick, IntPtr.Zero); _captureWebcam.StartPreview(); }
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); }
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); }); }
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); } }
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)); } }
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"); } }