CameraInterface 1.4.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package CameraInterface --version 1.4.0
NuGet\Install-Package CameraInterface -Version 1.4.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="CameraInterface" Version="1.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CameraInterface" Version="1.4.0" />
<PackageReference Include="CameraInterface" />
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 CameraInterface --version 1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CameraInterface, 1.4.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 CameraInterface@1.4.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=CameraInterface&version=1.4.0
#tool nuget:?package=CameraInterface&version=1.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CameraInterface
A lightweight .NET library providing a clean abstraction for working with camera devices and image data. It defines common camera properties, supported pixel formats, and efficient serialization/deserialization of image buffers.
Features
- 🎥 Camera Abstraction — Provides the
ICamera
interface with common properties (resolution, offsets, ranges, exposure, and image format). - 🖼 Image Data Handling — Encapsulates pixel buffers in the
ImageData
struct with width, height, stride, and format metadata. - 🔄 Serialization Support — Convert images to and from byte arrays or streams for efficient storage and transfer.
- 🧩 Supported Formats — Multiple pixel formats such as Mono8, Mono16, Rgb24, Rgb32, Raw8, Raw16.
- ⚡ Zero-Copy Parsing — Optimized APIs like
TryFromMemory
avoid unnecessary allocations when possible. - ⏱ Units Integration — Exposure times use UnitsNet for type-safe duration handling.
Installation
Add the project or library to your solution. If published as a NuGet package, install via:
dotnet add package CameraInterface
Usage
Implementing a Camera
using CameraInterface;
using UnitsNet;
public class DummyCamera : ICamera
{
public int Width { get; set; } = 640;
public int Height { get; set; } = 480;
public int XOffset { get; set; } = 0;
public int YOffset { get; set; } = 0;
public (int Min, int Max) WidthRange { get; set; } = (320, 1920);
public (int Min, int Max) HeightRange { get; set; } = (240, 1080);
public (int Min, int Max) XOffsetRange { get; set; } = (0, 100);
public (int Min, int Max) YOffsetRange { get; set; } = (0, 100);
public CameraImageFormat ImageFormat { get; set; } = CameraImageFormat.Rgb24;
public Duration Exposure { get; set; } = Duration.FromMilliseconds(10);
public ImageData GetImage()
{
// Provide pixel data from the camera here
var pixels = new byte[Width * Height * 3]; // Rgb24 = 3 bytes per pixel
return new ImageData(pixels, Width, Height, Width * 3, ImageFormat);
}
}
Working with ImageData
Serialize to Array
var camera = new DummyCamera();
ImageData img = camera.GetImage();
byte[] serialized = img.ToArray();
Deserialize from Array
ImageData img2 = ImageData.FromArray(serialized);
Zero-Copy Parse from Memory
if (ImageData.TryFromMemory(serialized, out var img3))
{
Console.WriteLine($"Image parsed: {img3.Width}x{img3.Height}, {img3.Format}");
}
Read/Write from Stream
using var ms = new MemoryStream();
img.WriteTo(ms);
ms.Position = 0;
ImageData img4 = ImageData.ReadFrom(ms);
Supported Image Formats
- Mono8 – 8-bit grayscale
- Mono16 – 16-bit grayscale
- Rgb24 – 24-bit RGB
- Rgb32 – 32-bit RGB (with alpha or padding)
- Raw8 / Raw16 – Raw image buffers
License
MIT License — free to use, modify, and distribute.
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 is compatible. 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. |
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 CameraInterface:
Package | Downloads |
---|---|
Ximea.NET.ObjectOriented
an OO implementation of the Ximea Camera. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Added Trigger Setup