Itp.WpfCamera
3.0.1
dotnet add package Itp.WpfCamera --version 3.0.1
NuGet\Install-Package Itp.WpfCamera -Version 3.0.1
<PackageReference Include="Itp.WpfCamera" Version="3.0.1" />
<PackageVersion Include="Itp.WpfCamera" Version="3.0.1" />
<PackageReference Include="Itp.WpfCamera" />
paket add Itp.WpfCamera --version 3.0.1
#r "nuget: Itp.WpfCamera, 3.0.1"
#:package Itp.WpfCamera@3.0.1
#addin nuget:?package=Itp.WpfCamera&version=3.0.1
#tool nuget:?package=Itp.WpfCamera&version=3.0.1
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
MediaFrameReaderframe's D3D11 surface is copied into a texture shared with a D3D9Ex device, whose surface is theD3DImageback 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
SoftwareBitmapis locked in place (LockBuffer) and copied once into a frozenBitmapSource.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows10.0.22621 is compatible. |
-
net10.0-windows10.0.22621
- DirectNAot (>= 1.6.9)
- DirectNAot.Extensions (>= 1.6.9)
- Esatto.Win32.Registry (>= 3.0.22)
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 |