CvInspect.Wpf 0.22.0

dotnet add package CvInspect.Wpf --version 0.22.0
                    
NuGet\Install-Package CvInspect.Wpf -Version 0.22.0
                    
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="CvInspect.Wpf" Version="0.22.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CvInspect.Wpf" Version="0.22.0" />
                    
Directory.Packages.props
<PackageReference Include="CvInspect.Wpf" />
                    
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 CvInspect.Wpf --version 0.22.0
                    
#r "nuget: CvInspect.Wpf, 0.22.0"
                    
#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 CvInspect.Wpf@0.22.0
                    
#: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=CvInspect.Wpf&version=0.22.0
                    
Install as a Cake Addin
#tool nuget:?package=CvInspect.Wpf&version=0.22.0
                    
Install as a Cake Tool

CvInspect.Wpf

ci NuGet CvInspect.Wpf License: Apache-2.0

WPF display and shape-editing controls for the CvInspect machine-vision toolkit, based on OpenCvSharp.

  • CvDispCtrl — an image display control with a dockable toolbar (grab / live toggle / fit / zoom / pan / clear), a status bar (cursor position, pixel value, image size, zoom level), and a right-click menu (load / save image file, view operations). Renders OpenCvSharp.Mat frames, renderer-neutral result overlays (ViOverlay), and interactive teaching shapes.
  • Teaching shapes — the draggable shapes (CvEditShape family: rotated rect, segment, circle, arc, concentric ring) and the contract by which option POCOs supply them (ICvShapeSource, implemented by every CvInspect option that has geometry, and by host-defined options the same way) live in the core package under CvInspect.Vision.Edit. This package draws them and turns mouse drags into moves, corner resizes and rotation/angle/radius grips; each drag writes straight back into the POCO through the shape's Changed event.

Install

dotnet add package CvInspect.Wpf

This package references only the managed assemblies (CvInspectOpenCvSharp4). Pick a native OpenCV runtime yourself in the application project, e.g.:

dotnet add package OpenCvSharp4.runtime.win

Quick start

<Window xmlns:cv="clr-namespace:CvInspect.Controls;assembly=CvInspect.Wpf" ...>
  <cv:CvDispCtrl Frame="{Binding Frame}"
                 Overlay="{Binding Overlay}"
                 Shapes="{Binding Shapes}"
                 GrabCommand="{Binding GrabCmd}"
                 ContinuousCommand="{Binding LiveCmd}"
                 StopCommand="{Binding StopCmd}"
                 LoadFrameCommand="{Binding LoadFrameCmd}"
                 IsRunning="{Binding IsLive}" />
</Window>
Property Type Meaning
Frame Mat or ICvPixelSource Frame to display — a Mat is copied on assignment, an ICvPixelSource (e.g. CamFrame from CvInspect.Imaging) is held by reference. null shows a placeholder. Auto-fits when dimensions change.
Overlay ViOverlay Result graphics (segments, labels, rects, polylines); replace the reference to refresh.
Shapes IReadOnlyList<CvEditShape> Editable teaching shapes; drag edits raise Changed immediately.
GrabCommand / ContinuousCommand / StopCommand ICommand Camera actions behind the 📸 / ⏯️ toolbar buttons.
LoadFrameCommand ICommand Receives a Mat loaded from a file via the right-click menu. Unset it to hide the load menu entry.
IsRunning bool Live state shown by the ⏯️ toggle (the view-model is the source of truth).
IsToolbarVisible / IsCamControlVisible / ToolbarDock Toolbar visibility and docking (top/bottom/left/right).

Property editor

CvPropEditCtrl unfolds any option POCO into category groups and rows — checkbox for bool, text for numbers and strings, combo for enums, a button for Action — using only the standard System.ComponentModel attributes, which the core's [CvCategory] / [CvName] / [CvDesc] derive from. So a core Cv*Opt needs nothing extra:

<cv:CvPropEditCtrl Source="{Binding ToolOpt}" Committed="OnCommitted" />
Member Meaning
Source The POCO to edit; replacing it rebuilds the rows. null shows nothing.
ShowDesc Show each row's description as a caption under it (the label tooltip always has it).
ExecuteText Button text for Action rows; defaults to the cv:Execute translation.
Committed A row wrote a value into the POCO — the host's only dirty-marking signal, since most POCOs do not implement INotifyPropertyChanged.
ActionExecuting / ActionExecuted / ActionFailed Around an Action row's button. Failures are logged through CvLog and never escape to the dispatcher.

Rules the rows follow: [Browsable(false)] hides, [ReadOnly(true)] or a getter-only property disables, group order comes from ICvOrderedCategory (or a "N. " prefix on plain [Category] strings), and numeric text commits on Enter or focus loss — an unparsable entry is rejected and the row snaps back to the stored value, so what you see is always what is stored. The control references no UI library; it adopts the host theme's SecondaryTextBrush and PrimaryBrush when those keys exist and falls back to fixed colors otherwise.

Frame lifetime

Frame accepts two kinds of value, with different lifetime rules:

  • MatCvDispCtrl copies the pixels into its own buffer, so the host may Dispose() the Mat right after setting the property. That copy is the price of a type that can be disposed underneath the control.
  • ICvPixelSource (the core contract, implemented by CamFrame in CvInspect.Imaging) — the control holds the pixel array by reference and copies it only once, into the WPF back buffer. The reference is kept for the status-bar pixel probe and for file save, not for rendering — so a buffer that changes after publishing does not tear the picture, it makes those two disagree with what is on screen. This relies on the contract that Pixels is immutable once published; a source that recycles its buffer must not implement it.

Supported formats either way: 8-bit with 1 (Gray8), 3 (Bgr24) or 4 (Bgra32) channels; anything else shows the no-image placeholder. A value of any other type also shows the placeholder and logs a warning through CvLog.

The Mat passed to LoadFrameCommand is owned by the receiver — the view-model disposes it when done (typically after assigning it back to Frame).

Overlay and shape coordinates are in the pixel space of the image being displayed — bind an image and coordinates from the same space, whether that is the original or a derived (scaled) stage image.

Localization and theming

UI strings (menu labels, placeholder text) come from CvLoc in the core package, under the cv: scope. Labels are re-read every time the context menu opens, so a language switch applies without rebuilding the control. Toolbar accent colors use the host theme's PrimaryBrush / SuccessBrush / DangerBrush resource keys when present, and fall back to fixed colors otherwise — no UI library is referenced.

Targets

net8.0-windows, AnyCPU. The native OpenCV runtime is chosen by the consuming application.

License

Apache-2.0. Not affiliated with OpenCV or OpenCvSharp.

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
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
0.22.0 43 9/11/2026
0.21.0 48 9/10/2026
0.20.0 55 9/10/2026
0.19.0 45 9/9/2026
0.18.0 55 9/8/2026
0.17.0 48 9/8/2026