-
Notifications
You must be signed in to change notification settings - Fork 18
Handling device notifications
If you want to get notified whenever a new camera is connected or disconnected, you can use the CameraManager class.
var manager = new CameraManager();Note: you can specify an alternative device input format if the default one doesn't fit your use-case.
By default, it is
DShowfor Windows,V4l2for Linux (and the only one available),AVFoundationfor MacOS.using SeeShark.FFmpeg; var manager = new CameraManager(DeviceInputFormat.VfWCap);
From your instance of CameraManager that you created to instantiate cameras, you'll find two events: OnNewDevice and OnLostDevice.
In order to properly get notified though, you will need to perform a sync operation.
There are two ways to perform sync operations:
-
The automatic way, updating every second, only requires you to call
StartWatching()once (andStopWatching()to stop updating). -
The manual way, requires you to call the blocking method
SyncDevices()every time.
Note:
SyncDevices()is immediately called once upon creating a newCameraManager, so you don't need to call it again if you only want to get camera devices once.