Getting Started with CVB.Net

Configure a Device with the GenApi

Often, before acquiring images from a Device, you want to configure it. So we open a Device as described in the previous post:

If the Device supports GenICam GenApi, then there will be NodeMaps:

device.NodeMaps.Count > 0

Most of the time we are interested in the features of the camera (remote device):

NodeMap deviceNodeMap = device.NodeMaps[NodeMapNames.Device];

For remote Devices we will always have at least the NodeMapNames.Device NodeMap.

With this NodeMap we can access the camera’s features. Let’s start with some reporting:

Console.WriteLine("Vendor:  " + deviceNodeMap["DeviceVendorName"]);
Console.WriteLine("Model:   " + deviceNodeMap["DeviceModelName"]);
Console.WriteLine("Version: " + deviceNodeMap["DeviceVersion"]);

This results in something like this:

Vendor:  STEMMERIMAGING
Model:   CVGevServer
Version: 3.4.0.797_C#-Example

What happened here? The indexer of the NodeMap returns a Node object. Console.WriteLine then calls .ToString() on these which is mapped to the derived types’ Value property:

// for StringNode you need: using Stemmer.Cvb.GenApi

var vendorName = deviceNodeMap["DeviceVendorName"] as StringNode;
Console.WriteLine("Vendor:  " + vendorName.Value);

In case of a StringNode the .Value property is a string.

In case of ExposureTime this would be a FloatNode (this is according to the GenICam Standard Features Namimg ConventionSFNC):

var exposure = deviceNodeMap["ExposureTime"] as FloatNode;
exposure.Value = 40000.0; // unit is micro-seconds

You can also get other feature/type specific information like

  • .Max: current maximal allowed value
  • .Min: current minimal allowed value
  • .Increment: the step-size: feature.Min + x * feature.Inrement

Common to all Nodes is also the AccessMode which shows whether this feature is readable and/or writeable or currently not available at all. For better readability you can also use the .IsAvailable, .IsReadable or .IsWritable properties before trying to access Nodes.

How to find the Node's type?

You can do it

  1. Programatically
    By getting the Node and look up its type in the debugger (or calling .GetType().Name). This gives you its most derived type, of course. Normally you don’t want the RegisterNode interfaces, so you can simply use a StringRegNode as a StringNode as a StringRegNode derives from StringNode.

  2. Use the GenApi Grid. For the Windows control (e.g. in the Management Console or as in Stemmer.Cvb.Forms.Controls.GenApiGrid) you can use the context menu on a feature and open Properties…:

    grafik

    You can see its basic type in the second category name: String. This this is a StringNode.

1 Like