Getting Started with CVB.Net

Stream Statistics

When streaming from a camera you can query statitistics to monitor your acquisition health.

A good point in time to query these statistics is right after your Stream.Wait call (or any (async) variant of it – also inside the NewImage event which is fired right after the Wait call). You can do this via

device.Stream.Statistics

The reason behind querying the statistics right after the wait is because acquisition is asynchronous. The Wait method is your only way to sync to that process. The statistic values are also only valid while the acquisition IsRunning (between Start and Stop/Abort).

There are several measurement points defined of which every driver implements its own sub-set. You can print the available ones with the following snippet:

foreach (var info in device.Stream.Statistics)
{
  Console.WriteLine(info.Key);
}

If you only work with one special driver (e.g. evaluation) you can directly query a value:

double numLostRBOverflow = device.Stream.Statistics[StreamInfo.NumBuffersLostLocked];

It is safer, though, to to query the statistic without throwing an exception if it isn’t available:

double numLostRBOverflow = .0;
bool isPresent = device.Stream.Statistics.TryGetValue(StreamInfo.NumBuffersLostLocked, out numLostRBOverflow);

In later posts I will describe two typical monitoring use cases.

1 Like