Mediacapture in WPF

Camera preview in WPF Desktop apps using WinRT MediaCapture

Project maintained by mmaitre314 Hosted on GitHub Pages — Theme by mattgraham

Build status NuGet package Symbols

CameraPreview allows previewing the camera video stream of the WinRT MediaCapture API in Desktop WPF apps.


CameraPreview derives from D3DImage and can be used anywhere a GPU-accelerated ImageSource can be. For instance, inside an <Image> XAML element:

    <Image Name="Preview"/>

The C# code behind creates MediaCapture, initializes it, and passes it to CameraPreview. This object is then set as source of the <Image> element and preview is started.

var capture = new MediaCapture();
await capture.InitializeAsync();

var preview = new CapturePreview(capture);
Preview.Source = preview;
await preview.StartAsync();