Nodes mit CVGenApi.dll

Hi,

im trying to access the settings of my camera by accessing to the nodes in the XML-GenICam file. Unfortunately I ame having some difficulties with the documentation. I am programming in C# with Visual Studio and imported the CVGenApi. My first goal is to compile the sample code from the CVB Manual (“Introduction GenICam Library”), but even that is being a challenge:

[DllImport("CVGenApi.dll")]
public static extern int SetForegroundWindow(IntPtr point);
// Check if INodemap interface is available
Cvb.Image.IMG m_cvImage = new Cvb.Image.IMG(1024,448);
if (Cvb.Driver.INodeMapHandle.CanNodeMapHandle((Cvb.Image.IMG)m_cvImage.Image))
if (Cvb.Driver.INodeMapHandle.CanNodeMapHandle(image))
{
  // Get NodeMap from Camera
  Cvb.Driver.INodeMapHandle.NMHGetNodeMap((Cvb.Image.IMG)m_cvImage.Image, out Cvb.GenApi.NODEMAP NodeMap);}
  // Set the Exposuretime to 20ms

  // Get ExposureTimeNode (e.g. With the Standard feature name "ExposureTimeAbs")
  Cvb.GenApi.NODE ExposureTimeNode = 0;

  Cvb.GenApi.NMGetNode(Cvb.GenApi.NODEMAP nodeMap, "ExposureTimeAbs", out  ExposureTimeNode);

  // Set the Exposuretime
  Cvb.GenApi.NSetAsInteger(ExposureTimeNode, 20000);

Where in the documentation can I find the IMG class (not Image) and the Cvb Namespace with all ist classes? I didn’t finde them either in Cvb.Net.chm nor in GenApiDLLReference.chm

Another issue is how to create (using my own source code) a list of all avaliable Nodes in my camera.

Thanks for your help,
Pep

In the mean time I got the code compiled with a couple of changes (initialising the NODEMAPs and IMGs out of the methods) but still have the problem of the missing documentation (or my lacking ability to find it) and an AccessViolationException from Compiler. Funnily enought the exception doesn’t appear when trying to Change the ExposureTimeNode but already when calling the NMHGetNodeMap method.

What am I doing wrong? Is it possible to access to the single nodes individually using another way (an easier one, I pressume).

First,

I strongly advise to use Cvb .Net (which will also be installed with our upcoming release 13.2):

https://forum.commonvisionblox.com/t/getting-started-with-cvb-net

Regarding the API you used: this is a procedural API (a direct mapping of our C interface). If you want object oriented programming use the API described in the link above. Thus the documentation of the procedural .Net wrappers is the same as the C API. The documentation of the object oriented one can currently be easily found online (under .Net API):

http://help.commonvisionblox.com/Reference/

Why your code is crashing in the way you described at runtime I cannot tell from this short snippet. First

var image = new Cvb.Image.IMG(1024, 448);

does not compile, as the IMG is a handle (single integer/pointer value) and thus cannot take two arguments. Also then the .CanNodeMapHandle would return false with such a manually assigned value.

Last, the GenApi.dll doesn’t export a SetForegroundWindow (it is defined in Microsoft’s User32.dll). Thus calling this function will result in an exception.

2 Likes

Understood, thanks for the answer. I didn’t know that the Stemmer.Cvb.GenApi gives the same options that CVGenApi, since in the CVB Manual and GenICam UserGuide I mainly found references to the second one, I’m sorry then, if my question was too superficial. My problem then changes a little bit: what I would like to achieve is to get a list of all avaliable nodes: are the INodes and INodeMaps interfaces the right approach?

If you want to get all nodes of a Device, you can simply access them this way:

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

var allNodes = deviceNodeMap.Values;

But normally this is not what one wants: you normally want only the public nodes intended for configuring the device (not the helper ones):

var allFeatures = deviceNodeMap.Values
                               .Where(node => node.IsFeature);

If you want to print out the node hierarchy you can do something like this:

void PrintHierarchy(INodeMap nodeMap)
{
  PrintHierarchy(nodeMap["Std::Root"] as ICategoryNode, 0);
}

void PrintHierarchy(ICategoryNode parent, int level)
{
  foreach (var child in parent.Nodes)
  {
    Console.Write(new String(' ', level * 2));
    Console.WriteLine(child.Name);
    if (child is ICategoryNode)
      PrintHierarchy(child as ICategoryNode, level + 1);
  }
}
1 Like

Hey @M_Esc_San!

No problem at all - after all the CVB.Net API has not been released yet so whatevery you downloaded and installed will not yet include the documentation for the bits that @parsd mentioned.

1 Like