Giter Club home page Giter Club logo

seeshark's Introduction

SeeShark

Simple C# camera and display library.

Discord NuGet

When you SeeShark, you C#!

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

Using FFmpeg, it allows you to enumerate camera and display devices and decode raw frames in 206 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 and display devices.
  • Control framerate, resolution and input format.
  • Notifies the application if devices get connected/disconnected.
  • Provides synchronous (method-driven) and asynchronous (event-driven) code flow.
  • Supports 206 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 video stream to a video file.
  • Managing 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 asynchronously
        camera.StartCapture();

        // Just wait a bit
        Thread.Sleep(TimeSpan.FromSeconds(10));

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

    // Create a callback for decoded camera frames
    private 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. We have a dedicated #tracking channel where we talk about SeeShark, MediaPipe.NET and other related repositories.

License

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

seeshark's People

Contributors

speykious avatar adryzz avatar sr229 avatar christophei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.