Skip to content

Gain Auto (dart E)#

The Gain Auto camera feature automatically adjusts the gain within specified limits until a target brightness value has been reached.

If you want to use Gain Auto and Exposure Auto at the same time, use the Auto Function Profile feature to specify how the effects of both are balanced.

To adjust the gain manually, use the Gain feature.

Using the Feature#

Enabling or Disabling Gain Auto#

To enable or disable the Gain Auto auto function, set the GainAuto parameter to one of the following operating modes:

  • Continuous: The camera adjusts the gain continuously while images are being acquired.
  • Off: Disables the Gain Auto auto function. The gain remains at the value resulting from the last automatic or manual adjustment.

Info

  • On daA2500-60mc cameras, enabling or disabling Gain Auto also enables or disables Exposure Auto.
  • When the camera is capturing images continuously, the auto function takes effect with a short delay. The first few images may not be affected by the auto function.

Specifying an Upper Limit#

Info

This functionality is available for daA…mci cameras only.

The auto function adjusts the Gain parameter value within specified limits.

To change the upper limit, set the AutoGainUpperLimit parameters to the desired value (in µs).

During the automatic adjustment process, the gain will never be higher than the specified limit.

Specifying the Target Brightness Value#

Info

This functionality is available for daA…mci cameras only.

The auto function adjusts the gain until a target brightness value, i.e., an average gray value, has been reached.

To specify the target value, use the AutoTargetBrightness parameter.

Info

  • The target value calculation does not include other image optimizations, e.g., Gamma. Depending on the image optimizations set, images output by the camera may have a significantly lower or higher average gray value than indicated by the target value.
  • The camera also uses the AutoTargetBrightness parameter to control the Exposure Auto auto function. If you want to use Gain Auto and Exposure Auto at the same time, use the Auto Function Profile feature to specify how the effects of both are balanced.

Sample Code#

// Set the the Gain Auto auto function to its maximum upper limit
double maxUpperLimit = camera.AutoGainUpperLimit.GetMax();
camera.AutoGainUpperLimit.SetValue(maxUpperLimit);
// Specify the target value
camera.AutoTargetBrightness.SetValue(0.6);
// Enable Gain Auto by setting the operating mode to Continuous
camera.GainAuto.SetValue(GainAuto_Continuous);
INodeMap& nodemap = camera.GetNodeMap();
// Set the the Gain Auto auto function to its maximum upper limit
double maxUpperLimit = CFloatParameter(nodemap, "AutoGainUpperLimit").GetMax();
CFloatParameter(nodemap, "AutoGainUpperLimit").SetValue(maxUpperLimit);
// Specify the target value
CFloatParameter(nodemap, "AutoTargetBrightness").SetValue(0.6);
// Enable Gain Auto by setting the operating mode to Continuous
CEnumParameter(nodemap, "GainAuto").SetValue("Continuous");
// Set the the Gain Auto auto function to its maximum upper limit
double maxUpperLimit = camera.Parameters[PLCamera.AutoGainUpperLimit].GetMaximum();
camera.Parameters[PLCamera.AutoGainUpperLimit].SetValue(maxUpperLimit);
// Specify the target value
camera.Parameters[PLCamera.AutoTargetBrightness].SetValue(0.6);
// Enable Gain Auto by setting the operating mode to Continuous
camera.Parameters[PLCamera.GainAuto].SetValue(PLCamera.GainAuto.Continuous);
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK;  /* Return value of pylon methods */
double maxUpperLimit = 0;
/* Set the the Gain Auto auto function to its maximum upper limit */
errRes = PylonDeviceGetFloatFeatureMax(hdev, "AutoGainUpperLimit", &maxUpperLimit);
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "AutoGainUpperLimit", maxUpperLimit);
CHECK(errRes);
/* Specify the target value */
errRes = PylonDeviceSetFloatFeature(hdev, "AutoTargetBrightness", 0.6);
CHECK(errRes);
/* Enable Gain Auto by setting the operating mode to Continuous */
errRes = PylonDeviceFeatureFromString(hdev, "GainAuto", "Continuous");
CHECK(errRes);
# Set the the Gain Auto auto function to its maximum upper limit
maxUpperLimit = camera.AutoGainUpperLimit.Max
camera.AutoGainUpperLimit.Value = maxUpperLimit
# Specify the target value
camera.AutoTargetBrightness.Value = 0.6
# Enable Gain Auto by setting the operating mode to Continuous
camera.GainAuto.Value = "Continuous"

You can also use the pylon Viewer to easily set the parameters.