CvInspect.Imaging 0.22.0

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

CvInspect.Imaging

ci NuGet CvInspect.Imaging License: Apache-2.0

Camera acquisition contract and tame frame sources for the CvInspect machine-vision toolkit, based on OpenCvSharp.

  • ICam — the acquisition contract: open/close, single grab, continuous grab, connection/grabbing events, best-effort exposure control. Frames are GC-owned CamFrame buffers (byte[] + width/height/stride/format/timestamps) with no lifetime contractframe.AsMat() gives a zero-copy Mat view for inspection, and the type implements the core ICvPixelSource contract, so CvDispCtrl (CvInspect.Wpf) displays it by reference without copying. A frame carries two clocks: TimestampUtc is when it arrived, and DeviceTimestamp is when the camera captured it (null if the device does not report one). The device clock has its own epoch, so compare frames to each other rather than reading it as wall time — the change in the gap between the two is time the frame spent waiting.
  • VirtualCam — no-hardware source: a shifting-gradient test pattern, or name-ordered cyclic replay of an image folder (CamOpt.VirtualImageDir), re-enumerated on folder change. Ideal for development, demos and CI regression runs. Note: color→gray decoding follows OpenCV's decoder coefficients, so pixel values may differ slightly from images converted by other stacks (e.g. GDI luma) — build regression baselines through the same path.
  • VideoCaptureCam — webcam (device index), video file (paced by FrameRate, loops at end) or stream URL (RTSP, …) through OpenCV VideoCapture (CamOpt.VideoSource).
  • CamFactoryComType string → implementation, with Register as the injection point for vendor SDK adapters (GigE etc.) so this package never references heavy SDKs.

Quick start

using CvInspect.Imaging;

var cam = CamFactory.Create(new CamOpt
{
    ComType = "Virtual",              // or "VideoCapture", or a registered vendor ComType
    VirtualImageDir = @"D:\samples",  // empty → test pattern
    FrameRate = 10,
});

cam.FrameAcquired += (_, frame) =>
{
    using var mat = frame.AsMat();   // zero-copy view into frame.Pixels
    // ... run CvInspect tools, update display ...
    // frame itself is GC-owned — keep it or hand it to another thread freely.
};

cam.Open();
cam.StartContinuous();

Frame lifetime

CamFrame is a GC-owned byte[] holder — there is no lifetime contract: keep it, queue it, or post it to a UI dispatcher as-is. AsMat() wraps the pixel buffer without copying (disposing the view only unpins; the pixels stay valid), so running CvInspect tools costs no conversion. Sources materialize one buffer per frame; frames already have CamOpt.Flip / Rotation applied.

Two more contract points implementers must honor: only complete frames are published (corrupt / partially received frames are dropped with a CvLog warning, never delivered), and Stride may exceed width × bytes-per-pixel on devices that pad rows — consumers must always walk rows by Stride (AsMat() handles this automatically).

USB webcams — a stable identity

OpenCV opens webcams by index, and the index is whatever order the OS enumerated the devices in this time. Re-plug a hub, reboot, add a capture card, and camera 0 and camera 1 swap without a warning. VideoCaptureCam therefore accepts an identity in CamOpt.SerialNumber:

new CamOpt { ComType = "VideoCapture", SerialNumber = "VID_046D&PID_082D" }

Accepted keys: VID_046D&PID_082D, 046D:082D, a full Windows instance id (USB\VID_046D&PID_082D\5&2C1F7A8&0&0001) or a Linux /dev/v4l/by-id name. When the key is not found, the exception lists every enumerated device so you can copy the right one into the settings; when two identical models match a VID/PID, it refuses to guess and lists their instance ids. UsbCamId.Enumerate() gives you the same list programmatically. UserSettings may carry backend=dshow|msmf|v4l2|any to pin the OpenCV backend.

OS How Verified
Windows SetupAPI enumeration of KSCATEGORY_VIDEO; the enumeration position is the OpenCV index Verified on a Windows 11 PC with two cameras of different models (built-in + external): the enumeration position matched the OpenCV index for the ANY, DSHOW and MSMF backends alike, and opening by VID/PID returned the right camera. The code it was ported from also ran on a two-webcam production line. Not yet exercised: identical models (instance-id path), hot re-plug
Linux /sys/class/video4linux + device/modalias for VID/PID, /dev/v4l/by-id for the instance; opens by /dev/videoN path, so ordering never matters Not run on hardware — only a synthetic-sysfs regression. net8.0 asset only (symlink resolution)
macOS Unsupported: Enumerate() throws; use VideoSource with an index

Vendor adapters

Implement ICam in your application (or an adapter package) against the vendor SDK — materialize SDK buffers into CamFrame directly (or via CamFrame.FromMat) — and register it once at startup:

CamFactory.Register("MyGigE", opt => new MyGigECam(opt));

Proprietary SDK assemblies stay out of this package by design.

Targets

netstandard2.1 and net8.0. Depends on CvInspect (managed OpenCvSharp4 flows transitively); the native OpenCV runtime is chosen by the consuming applicationVideoCaptureCam additionally needs the videoio backend for your source type (the Windows runtime bundles it).

License

Apache-2.0. Not affiliated with OpenCV or OpenCvSharp.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CvInspect.Imaging:

Package Downloads
CvInspect.Imaging.Gev

GigE camera acquisition for the CvInspect toolkit - an ICam backend that speaks the protocol directly, with no vendor SDK and no proprietary DLLs. Serial-number binding with actionable discovery diagnostics, user-set load, exposure control across SFNC generations, and PFNC pixel conversion including Bayer demosaic with phase diagnostics. Run against real hardware with no vendor SDK installed - a monochrome pair on a bench and a colour pair acquiring on an inspection line - but hours of run time, not months. Only a few models have been exercised, so treat other cameras as unproven.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.22.0 34 9/11/2026
0.21.0 46 9/10/2026
0.20.0 41 9/10/2026
0.19.0 45 9/9/2026
0.18.0 53 9/8/2026
0.17.0 51 9/8/2026