Skip to content

Getting Started

Speykious edited this page Dec 5, 2021 · 6 revisions

First of all, install the SeeShark NuGet package:

On the Visual Studio Package Manager Console:

PM> Install-Package SeeShark

or on the .NET CLI:

dotnet add package SeeShark

Start by adding a reference to SeeShark at the top of the file, like so:

using SeeShark;

In order to enumerate all the cameras plugged into the PC you use the CameraManager class.

var manager = new CameraManager();

The devices will be listed under manager.Devices.

After you have chosen your device, you can instantiate it using

Camera camera = manager.GetCamera(/* int or CameraInfo object */);

Note: both CameraManager and Camera implement IDisposable, so remember to dispose them after use by calling Dispose().

Then, you can listen to the OnFrame event that will be called whenever a frame is available, creating the OnFrameEventHandler() method.

camera.OnFrame += OnFrameEventHandler;

void OnFrameEventHandler(object sender, FrameEventArgs e)
{
    // Here you will be using your camera frames.
}

You will get access to the frame in e.Frame, as well as the status of the frame in e.Status. It can either be:

  • NewFrame: it is a new frame.
  • NoFrameAvailable: no new frame available, e.Frame is the previous frame.
  • EndOfStream: stream of frames ended. Will probably never happen for a camera.

After you start listening to the event, you can start the capture with

camera.StartCapture();

After you got the frames, you might want to actually use them. For that, you can look into Saving images.