Table of Contents

Getting Started with WINKOnvif.Core

This guide will help you get started with using the WINKOnvif.Core library in your .NET applications.

Installation

Install the WINKOnvif.Core package via NuGet:

dotnet add package WINKOnvif.Core

Basic Usage

Connect to an ONVIF Camera

using WINKOnvif.Core;
using WINKOnvif.Core.Authentication;
using WINKOnvif.Core.Models.Authentication;

// Create credentials for the camera
var credentials = new OnvifCredentials
{
    Username = "admin",
    Password = "password",
    CameraAddress = "http://192.168.1.100"
};

// Create an authenticator (Basic, Digest, or WSSE)
var authenticator = new BasicAuthenticator();

// Create a media service
var mediaService = new OnvifMediaService(credentials, authenticator);

// Get all profiles
var profiles = await mediaService.GetProfilesAsync();

// Get stream URI for the first profile
var streamUri = await mediaService.GetStreamUriAsync(profiles[0].Token);

Console.WriteLine($"Stream URI: {streamUri}");

PTZ Control

using WINKOnvif.Core.PTZ;
using WINKOnvif.Core.Models.PTZ;

// Create a PTZ service
var ptzService = new PtzService(credentials, authenticator);

// Check if camera supports PTZ
var capabilities = await ptzService.GetCapabilitiesAsync();
if (capabilities.PtzSupported)
{
    // Move the camera
    await ptzService.ContinuousMoveAsync(profiles[0].Token, new PtzVector
    {
        PanTilt = new Vector2D { X = 0.5, Y = 0.0 },
        Zoom = new Vector1D { X = 0.0 }
    });
    
    // Stop movement after 2 seconds
    await Task.Delay(2000);
    await ptzService.StopAsync(profiles[0].Token);
}

Advanced Configuration

For more advanced configuration and details on all available services, please refer to the API documentation.

Troubleshooting

If you encounter issues connecting to your camera, try the following:

  1. Verify camera credentials
  2. Check network connectivity
  3. Try different authentication methods
  4. Enable logging for detailed diagnostic information
// Enable detailed logging
services.AddLogging(configure => 
{
    configure.AddConsole();
    configure.SetMinimumLevel(LogLevel.Debug);
});