Itp.WpfCamera 3.0.1

dotnet add package Itp.WpfCamera --version 3.0.1
                    
NuGet\Install-Package Itp.WpfCamera -Version 3.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Itp.WpfCamera" Version="3.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Itp.WpfCamera" Version="3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Itp.WpfCamera" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Itp.WpfCamera --version 3.0.1
                    
#r "nuget: Itp.WpfCamera, 3.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Itp.WpfCamera@3.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Itp.WpfCamera&version=3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Itp.WpfCamera&version=3.0.1
                    
Install as a Cake Tool

ITP WPF Camera API

Live preview and still capture from webcams in WPF applications. Uses WinRT MediaCapture for capture and presents preview frames to a D3DImage without copying them through the CPU.

Windows 10+ and WPF only. Unpackaged desktop apps are supported.

Capture dialog

CaptureWindow is a maximized dialog with a live preview, a camera switcher, and a Capture button (or F2). It returns one still, or throws OperationCanceledException if the user closes it.

try
{
    image.Source = await CaptureWindow.ShowDialogAsync(this);   // frozen, at capture resolution
}
catch (OperationCanceledException)
{
    // The user closed the dialog.
}
catch (Exception ex)
{
    // The camera could not be opened, failed while open, or could not capture.
    MessageBox.Show(this, ex.Message);
}

The dialog does not try to recover from failures. Any failure (including the camera being unplugged, taken by another application, or stopped by a session lock) closes the dialog and is rethrown from ShowDialogAsync.

Direct use

var cameras = await WinRtCameraDeviceEnumerator.EnumerateAsync();
using var camera = await WinRtCamera.OpenAsync(cameras[0],   // on the UI thread
    (_, e) => log.LogError((Exception)e.ExceptionObject, "Camera failed"));   // optional
previewImage.Source = camera.Preview;

BitmapSource still = await camera.CaptureAsync();

WinRtCamera must be opened, used, and disposed on a WPF dispatcher thread. Ownership is plain IDisposable: a camera that cannot be opened throws from OpenAsync, and an opened camera is released by Dispose whether or not it has failed.

The optional failure handler is notification only. It is called once, on the dispatcher thread, if an opened camera stops unexpectedly; afterwards CaptureAsync throws. It is never called for a camera that failed to open.

Cameras are opened for exclusive control, so only one WinRtCamera per device can be open at a time.

Settings

Settings are read with Esatto.Win32.Registry (HKCU/HKLM, with policy overrides) under SOFTWARE\In Touch Technologies\Esatto\Wpf.Camera:

Value Key Type Meaning
SelectedCameraId Wpf.Camera REG_SZ Last camera opened by CaptureWindow; selected by default next time.
FormatIndex Wpf.Camera\Cameras\VID_xxxx&PID_xxxx REG_DWORD Index into the color source's SupportedFormats for that camera model. -1 (default) uses the driver default. An out-of-range or unusable index fails the open. Also settable via CaptureCameraSettings.For(group.Id).FormatIndex.

Design

  • Preview frames stay in GPU memory. Each MediaFrameReader frame's D3D11 surface is copied into a texture shared with a D3D9Ex device, whose surface is the D3DImage back buffer. Frames are dropped, not queued, while a present is pending.
  • Stills use the low-lag photo pipeline, so they are not limited to the preview resolution. The photo's SoftwareBitmap is locked in place (LockBuffer) and copied once into a frozen BitmapSource.
Product Compatible and additional computed target framework versions.
.NET net10.0-windows10.0.22621 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.1 115 9/30/2026