Skip to main content

ONVIF cameras

Products: Video Capture SDK .Net

Engines: VideoCaptureCore, VideoCaptureCoreX

ONVIF is a standard for physical IP cameras. Many cameras and NVRs support the ONVIF protocol. It is a good idea if you need to support many cameras.

How to enumerate ONVIF cameras

Enumerate ONVIF sources and add them to a combo box.

var uris = await VideoCapture1.IP_Camera_ONVIF_ListSourcesAsync(null, null);
foreach (var uri in uris)
{
cbIPCameraURL.Items.Add(uri);
}

How can I get camera capabilities and information?

Create a new camera object and connect it to the camera:

var onvifControl = new ONVIFControl();
var result = await onvifControl.ConnectAsync("http://192.168.1.2/onvif/device_service", "username", "password");
if (!result)
{
onvifControl = null;
Debug.WriteLine("Unable to connect to the ONVIF camera.");
return;
}

Get camera information:

var deviceInfo = await onvifControl.GetDeviceInformationAsync();
if (deviceInfo != null)
{
Debug.WriteLine($"Model {deviceInfo.Model}, Firmware {deviceInfo.Firmware}");
}

Get profiles:

var profiles = await onvifControl.GetProfilesAsync();
foreach (var profile in profiles)
{
Debug.WriteLine($"{profile.Name}");
}

Get video RTSP URL to connect:

// Get URL using the profile index
var url = await onvifControl.GetVideoURLAsync(0);

Retrieve PTZ ranges (optional):

var ranges = await onvifControl.PTZ_GetRangesAsync();

Visit our GitHub page to get more code samples.