Periphery.Camera.OpenCvSharp
5.0.0
dotnet add package Periphery.Camera.OpenCvSharp --version 5.0.0
NuGet\Install-Package Periphery.Camera.OpenCvSharp -Version 5.0.0
<PackageReference Include="Periphery.Camera.OpenCvSharp" Version="5.0.0" />
<PackageVersion Include="Periphery.Camera.OpenCvSharp" Version="5.0.0" />
<PackageReference Include="Periphery.Camera.OpenCvSharp" />
paket add Periphery.Camera.OpenCvSharp --version 5.0.0
#r "nuget: Periphery.Camera.OpenCvSharp, 5.0.0"
#:package Periphery.Camera.OpenCvSharp@5.0.0
#addin nuget:?package=Periphery.Camera.OpenCvSharp&version=5.0.0
#tool nuget:?package=Periphery.Camera.OpenCvSharp&version=5.0.0
Periphery.Camera.OpenCvSharp
Hand OpenCV frames from a camera you chose by identity, instead of by VideoCapture(0).
dotnet add package Periphery.Camera.OpenCvSharp --prerelease
dotnet add package OpenCvSharp4.runtime.win # Linux: OpenCvSharp4.official.runtime.linux-x64
This package does not bring OpenCV's native binaries. Without a runtime package, the first OpenCV call throws DllNotFoundException. Capture supports Windows and Linux.
VideoCapture(0) is a position in the OS enumeration order. It changes when a device is replugged or a virtual camera installs, and it cannot tell two identical cameras apart. Periphery selects the camera by VID/PID, serial number, name, or port.
using OpenCvSharp;
using Periphery;
using Periphery.Camera;
using Periphery.Camera.OpenCvSharp;
var device = await Devices.Enumerate()
.OfCategory(DeviceCategory.Camera)
.WithUsbId("046D", "0825") // or .WithSerialNumber("A1B2C3D4") for one of two identical cameras
.FirstOrDefaultAsync()
?? throw new InvalidOperationException("That camera is not attached.");
await using var session = await CameraSession.For(device)
.MaxResolution(1280, 720)
.OpenAsync();
await foreach (var frame in session.CaptureAsync())
{
using (frame)
using (var bgr = frame.ToBgr()) // every format except Gray16 -> CV_8UC3 BGR
{
Cv2.ImShow("preview", bgr);
Cv2.WaitKey(1);
}
}
Converting frames
| Call | Copies | Use it when |
|---|---|---|
frame.AsMat() |
no | You convert or measure inside the capture loop. The Mat borrows the frame's pooled buffer, so do not keep it past the returned scope: the buffer is reused for a later frame. |
frame.ToMat() |
yes | You need the raw capture format after the frame is released. |
frame.ToBgr() |
yes | You want a BGR image. This is the only one that accepts MJPEG. |
Convert inside the using (frame) block, and run slow work such as inference after it. A frame you hold keeps a buffer from the camera's pool.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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 is compatible. 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. |
-
net10.0
- OpenCvSharp4 (>= 4.13.0.20260627)
- Periphery (>= 5.0.0)
- Periphery.Camera (>= 5.0.0)
-
net8.0
- OpenCvSharp4 (>= 4.13.0.20260627)
- Periphery (>= 5.0.0)
- Periphery.Camera (>= 5.0.0)
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 |
|---|---|---|
| 5.0.0 | 92 | 10/2/2026 |
| 4.3.0 | 118 | 9/23/2026 |
| 4.2.0 | 104 | 9/16/2026 |
| 4.2.0-alpha.1 | 82 | 9/9/2026 |
| 4.1.0-alpha.2 | 82 | 8/30/2026 |