• Stars
    star
    142
  • Rank 258,495 (Top 6 %)
  • Language
    C#
  • License
    BSD 3-Clause "New...
  • Created about 3 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple C# camera library.

SeeShark

Simple C# camera and display library.

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!

Vignette

This library was previously hosted on https://github.com/vignetteapp/SeeShark. It was first made to be used in Vignette's vtuber application. Now, it is its own self-contained library!

License

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

More Repositories

1

cve-rs

Blazingly πŸ”₯ fast πŸš€ memory vulnerabilities, written in 100% safe Rust. πŸ¦€
Rust
3,840
star
2

snaek

a snake game in Rust almost from scratch
Rust
17
star
3

OwOverlay

A very simple configurable key overlay written in Rust.
Rust
8
star
4

NativeFileDialogs.NET

Full .NET wrapper for NativeFileDialogs (Extended).
C#
7
star
5

clipbox

A (eventually) cross-platform clipboard library.
Rust
6
star
6

read-last-lines-ts

Efficiently reads the last lines of a file, written in TypeScript for intellisense
TypeScript
4
star
7

oSUS

Some osu! utilities written in Rust.
Rust
4
star
8

hardcore-rust

Doing some stuff in Rust from scratch (no_std)
Rust
3
star
9

zapf

ZAP file format.
Rust
3
star
10

arch-chan

An archival fork of RavioliMavioli's Arch-chan Live2D and Inochi2D models
3
star
11

loki

God of Chaotic Chat Apps.
2
star
12

sorbot

Le Bot Discord de vΓ©rification pour le serveur Sorbonne Jussieu ! (GitHub mirror from GitLab)
CoffeeScript
2
star
13

ye

yes, but faster, and written in Rust.
Rust
2
star
14

strnth

strnth^strnth^strnth
Haskell
2
star
15

TicTacToe

A TicTacToe in C# that is designed to be extensible.
C#
1
star
16

yt-music

Download songs from YouTube in mp3 format, thumbnail included
Python
1
star
17

parsers-ts

Making simple parsers in typescript.
TypeScript
1
star
18

yui

Rust GUI framework from scratch with OpenGL
Rust
1
star
19

c4

A rhythm game from absolute scratch in C (if I stop procrastinating)
C
1
star
20

mysql-leak

MySQL is eating too much RAM! D:
Java
1
star
21

arcsquared

Rewrite of Arcthird in Typescript, which is a rewrite of Arcsecond in Coffeescript.
TypeScript
1
star
22

single-rotation-gpu

Program that lets you observe the evolution of a grid state in a cellular automaton called Single Rotation.
C++
1
star
23

single-rotation-cpu

Program that lets you observe the evolution of a grid state in a cellular automaton called Single Rotation.
C++
1
star
24

arcthird

The arcsecond library from LLJS only works for strings and array types. I am trying to make it more abstract by rewriting it to work on any abstract custom stream, using Coffeescript! (GitHub mirror from GitLab)
CoffeeScript
1
star
25

simple-tga-reader

Simple TGA image reader
Rust
1
star
26

V4l2.AutoGen

Auto-generated C# bindings for V4l2 (Video4Linux2).
C#
1
star