Skip to main content
net8.0net9.0

a small package that has a Camera Interface.

Published
Oct 18, 2025
1y ago
Total Downloads
2.0K
1,996

Install

dotnet add package CameraInterface --version 2.0.0
ProductVersions
.NET
net8.0net9.0

README

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.


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.
  • 🧩 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);
    }
}

Supported Image Formats

  • Mono8 – 8-bit grayscale
  • Mono16 – 16-bit grayscale
  • Rgb24 – 24-bit RGB
  • Rgb32 – 32-bit RGB (with alpha or padding)

License

MIT License β€” free to use, modify, and distribute.

Changes from Previous Version

v1.6.0v2.0.0
Added Dependencies
ImageData(net8.0)
ImageData(net9.0)

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.