Getting Started with CVB.Net

Acquire from a Camera (Console)

In general this is similar to the things we have done so far:

You have two general options on how to open devices:

  1. DeviceFactory.Open and its related methods to open a vin-driver.
  2. DeviceFactory.Discover for GenICam GenTL based drivers (like GigE Vision or USB3 Vision)
Don't have a camera?

Then let’s simulate one with the :cvb: GigE Vision Server! (You need :cvb: full install – not CameraSuite for that.)

Depending on your operating system find the

GEVServer > C# GEVServer Example

This can be found either directly in the start menu (e.g. Windows 7) or via the Tutorials link (e.g. Windows 10).

When starting the app select one of the available IP addresses (best one not in your company network to keep your admins on your good side :wink:). Also select the Socket Driver instead of the Filter Driver as we want to do loop-back (communication on the same machine). Then hit Start and you have a camera.

If you have no available IP address (e.g. offline usage) or no private one you can install a virtual network adapter as described here.

Case 1: Load Vin-Driver

For configuration I just assume you use a GenICam based device (like GEV, U3V). For other vin-drivers please consult the driver’s documentation on how to configure them. You can use the :cvb: default way of configuring your devices via the GenICamBrowser or the Common Vision Blox Management Console.

Configure for local GEV Server

When you want to acquire images from a locally running GEV Server, you also need to set the used driver to Socket. This can currently only be done in the Common Vision Blox Management Console or the GEV Config Manager. For the Management Console you find this setting in the camera’s context menu.

To access these configured devices you can call simply call

Device firstDevice = DeviceFactory.Open("GenICam.vin");

to open the firstDevice. Depending on the driver you can also access other configured cameras like this:

Device secondDevice = DeviceFactory.OpenPort("GenICam.vin", 1);

(It is zero-based indexing.)

Case 2: Discover devices

This so far only works for GenICam GenTL based devices (like GEV, U3V). Here you don’t need the additional configuration step. Simply call

DiscoveryInformationList foundDevices = DeviceFactory.Discover();

to find all available devices in your environment (this is the same as the output in the Management Console).

Discover for local GEV Server

For this you need to change the default filter:

var foundDevices = DeviceFatory.Discover(DiscoverFlags.IgnoreVins | DiscoverFlags.IgnoreGevFD);

Let’s assume we found at least one device (foundDevices.Count > 0), we can open it like this:

Device device = DeviceFactory.Open(foundDevices[0]);

Streaming

As we have a Device again, we can do the streaming like with the video file. The only difference now is that we just have an (endless) Stream instead of an IndexedStream:

Stream stream = device.Stream;

stream.Start();
try
{
  for (int i = 0; i < 10; i++)
  {
    using (StreamImage image = stream.Wait())
    {
      // Processing...
    }
  }
}
finally
{
  stream.Stop();
}

Looks nearly the same except the Stream type and the loop over 10 images.

1 Like