C# CVB Changing Camera Brightness or Shutter

Hello!
I would like to know how to change the camera brightness or shutter with C# code.
Thank you very much!

Hi @George

namespace GenApiNodeAccess 
{ 
  class Program 
  { 
    static void Main(string[] args) 
    { 
      // Load driver 
      using (Device device = DeviceFactory.Open("GenICam.vin")) 
      { 
        // Load NodeMap for the device 
        var dev_node_map = device.NodeMaps["Device"];   

        using (var camModel = dev_node_map["DeviceModelName"] as StringNode) 
        { 
          Console.WriteLine("Loaded device: " + camModel.Value); 
        }   

        using (var camFirmWare = dev_node_map["DeviceFirmwareVersion"] as StringNode) 
        { 
          Console.WriteLine("Current Firmwareversion : " + camFirmWare.Value); 
        }   

        using (var exposureTime = dev_node_map["ExposureTime"] as FloatNode) 
        { 
          Console.WriteLine("Current exposure time : " + exposureTime.Value); 
          var exposureTimeOld = exposureTime.Value; 
          exposureTime.Value = 32; 
          Console.WriteLine("Small exposure time : " + exposureTime.Value); 
          exposureTime.Value = exposureTimeOld; 
          Console.WriteLine("Resetted to old exposure time : " + exposureTime.Value); 
        } 
      } 
    } 
  } 
} 

Cheers
Chris

The code snipped does not use any Foundation functionality, only Image Manager.

What do you mean by “AX tools”?

You can also check out the example application at %CVB%Tutorial\Image Manager\Cvb.Net\GenICam. There the GenAPIGrid is used to change camera parameters.

Hi @George

you really should not use this old activeX controls… like really really dont do it :wink:

If you still want to, rightclick into your toolbox in VisualStudio and add the GenApiGrid Control:

However if you only want to change 2 parameters, use the code I suggested to you already.
If this code does not work, consider updating to the latest CVB Version and switching from the old api to the modern .Net Api.

Hello Chris, thank you for your quick response!
We have to use those old tools because our dongles do not allow Foundations! arrghh!
What is the problem with those controls? At the moment they are doing their job correctly (detecting edges) but I am afraid now :sweat_smile:

1 Like

Hello Chris,
I am having problems to access Trigger Mode. I have tried as StringNode and as BoolenNode, but my variable triggerMode is always “null”
Exposure Time is working good:

using (var exposureTime = nodeMap["ExposureTime"] as FloatNode)
                {
                    //exposureTime.Value = Convert.ToDouble(Program.MainForm.ReadItemOneMethod("[Camera Settings]", "FrontTop Camera Exposure", "VIS-Setup.ini", "1000"));
                    TxtBxExposureDisplay.Text = exposureTime.Value.ToString();
                    SpnNewExposureDisplay.Value = Convert.ToDecimal(TxtBxExposureDisplay.Text);
                }

But Trigger Mode is not:

using (var triggerMode = nodeMap["TriggerMode"] as StringNode)
                {
                    if (triggerMode.Value == "On")
                    {
                        OptTriggerON.Checked = true;
                    }
                    else { OptTriggerOFF.Checked = true; }
                }

Am I missing something?
Thank you in advance!

Hi @George

Try to go with the „Command Node“ Type.
You can always check which type a node ist when having a look at the node in the GenICam browser.
There once highlighted a node you get all information like the Name to access it and the type in a box below the nodemap.

Cheers
Chris

Oh, I see. Thank you Chris.
I did it as well through the CVB Management Console: Select the camera you want, in properties you select the one you are interested on (Trigger Mode in my case) then right button on the property and select “Properties”. It will open a little window with the node information.
In this case Trigger Mode is a EnumerationNode, so this code is working now:

using (var triggerMode = nodeMap["TriggerMode"] as EnumerationNode)
                {
                    if (triggerMode.Value == "On")
                    {
                        OptTriggerON.Checked = true;
                    }
                    else { OptTriggerOFF.Checked = true; }
                }

Thank you

Ah I see, there is another Node I thought you were talking about, which actually executes the trigger when TriggerMode is set to Software. This node is usually a CommandNode. All nodes that have a dropdown menu in the nodemap are usually Enumeration nodes.

Nice to hear, that you are making progress!

Thank you Chris,
Yes I am starting to feel comfortable with the new Stemmer.Cvb tools!
Thank you for you help

1 Like