Skip to main content

ONVIF cameras

Products: Video Capture SDK .Net

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
var lst = await VideoCapture1.IP_Camera_ONVIF_ListSourcesAsync(null, null);
foreach (var uri in lst)
{
// add to some combobox
cbIPCameraURL.Items.Add(uri);
}

How to get camera capabilities and information

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

var onvifControl = new ONVIFControl();
var result = await onvifControl.ConnectAsync("http://IP/onvif/device_service", "username", "password");
if (!result)
{
onvifControl = null;
MessageBox.Show(this, "Unable to connect to 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:

// 0 - profile index
var url = await onvifControl.GetVideoURLAsync(0);

Get (optional) PTZ capabilities:

var onvifPtzRanges = await onvifControl.PTZ_GetRangesAsync();

Visit our GitHub page to get more code samples.