SeeShark 2.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package SeeShark --version 2.0.1                
NuGet\Install-Package SeeShark -Version 2.0.1                
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="SeeShark" Version="2.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SeeShark --version 2.0.1                
#r "nuget: SeeShark, 2.0.1"                
#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.
// Install SeeShark as a Cake Addin
#addin nuget:?package=SeeShark&version=2.0.1

// Install SeeShark as a Cake Tool
#tool nuget:?package=SeeShark&version=2.0.1                

SeeShark

Simple C# camera library.

Discord NuGet

When you SeeShark, you C#!

SeeShark is a simple cross-platform .NET library for handling camera inputs on Linux, Windows and MacOS.

Using FFmpeg, it allows you to enumerate camera devices and decode raw frames in 199 different pixel formats (because that's how powerful FFmpeg is!).

Features include:

  • Zero-copy.
  • Memory-safe.
  • Cross platform (Tested on Windows and Linux, might work on more platforms like MacOS).
  • Managing camera devices.
  • Notifies the application if devices get connected/disconnected.
  • Event-driven code flow.
  • Supports 199 different pixel formats.
  • Conversion of a frame from a pixel format to another.
  • Scaling frames.
  • Access to raw pixel data.

Features don't include:

  • Saving a frame as an image (here's a wiki page on how to do it using ImageSharp).
  • Recording a camera stream to a video file.
  • Manage audio devices.

Example code

using System;
using System.Threading;
using SeeShark;
using SeeShark.FFmpeg;

namespace YourProgram
{
    // This program will display camera frames info for 10 seconds.
    class Program
    {
        static void Main(string[] args)
        {
            // Create a CameraManager to manage camera devices
            using var manager = new CameraManager();

            // Get the first camera available
            using var camera = manager.GetCamera(0);

            // Attach your callback to the camera's frame event handler
            camera.OnFrame += FrameEventHandler;

            // Start decoding frames
            camera.StartCapture();

            // The camera decodes frames asynchronously.
            Thread.Sleep(TimeSpan.FromSeconds(10));

            // Stop decoding frames
            camera.StopCapture();
        }

        // Create a callback for decoded camera frames
        public static void FrameEventHandler(object? _sender, FrameEventArgs e)
        {
            // Only care about new frames
            if (e.Status != DecodeStatus.NewFrame)
                return;

            Frame frame = e.Frame;

            // Get information and raw data from a frame
            Console.WriteLine($"New frame ({frame.Width}x{frame.Height} | {frame.PixelFormat})");
            Console.WriteLine($"Length of raw data: {frame.RawData.Length} bytes");
        }
    }
}

You can also look at our overcommented SeeShark.Example.Ascii program which displays your camera input with ASCII characters.

See demo of the example below.

ASCII output of OBS virtual camera, feat. Bad Apple!!


Contribute

You can request a feature or fix a bug by reporting an issue.

If you feel like fixing a bug or implementing a feature, you can fork this repository and make a pull request at any time!

You can also join our discord server where we talk about our different projects. This one has a particular #Project SeeShark thread that can be found under the #main channel.

License

This library is licensed under the BSD 3-Clause License. See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 was computed.  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. 
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
4.0.0 970 10/30/2022
3.1.0 652 2/23/2022
3.0.0 898 2/19/2022
2.2.0 353 12/15/2021
2.0.1 308 12/5/2021
2.0.0 303 12/5/2021
1.0.0 1,842 11/26/2021