跳转到内容

Gain Auto#

相机的 Gain Auto 功能会在指定的限值内自动调整增益,直到达到目标亮度值为止。

自动功能的像素数据可以来自一个或多个自动功能 ROI

如果要同时使用 Gain Auto 和 Exposure Auto,使用 Auto Function Profile 功能可以指定如何平衡两者效果。

要手动调整增益,请使用 Gain 功能。

该功能的使用#

启用或禁用 Gain Auto#

要启用或禁用 Gain Auto 自动功能:

  1. 至少一个自动功能 ROI 分配给 Gain Auto 自动功能。
    确保自动功能 ROI 部分或完全与图像 ROI 重叠。
  2. 设置 GainAuto 参数设置为以下工作模式之一:
    • Once:相机调整 gain,直到达到指定的目标亮度值。完成此操作后,或最多经过 30 个计算周期后,相机会将自动功能设置为 [Off`,并将最后一次计算所得的增益应用于所有后续图像。
    • Continuous:相机在采集图像时连续调节增益。
    • Off:禁用自动功能 Gain Auto。增益保持为上次自动或手动调整后的值。

信息

当相机连续拍摄图像时,自动功能会在经过较短的延迟后生效。前几张图像可能不受自动功能的影响。

指定下限和上限#

自动功能会在您指定的限值范围内调整 Gain 参数值。

要更改限值,请将 AutoGainLowerLimitAutoGainUpperLimit 参数设置为所需值。

示例:假设您已将 AutoGainLowerLimit 参数设置为 2,并将 AutoGainUpperLimit 参数设置为 6。在自动调节过程中,增益将永远不会低于 2 且不会高于 6。

指定目标亮度值#

自动功能会调整增益,直至达到目标亮度值(即平均灰度值)为止。

要指定目标值,请使用 AutoTargetBrightness 参数。

信息

  • 目标值计算不包括其他图像优化,例如 Gamma。根据设置的图像优化,相机输出的图像平均灰度值可能会明显低于或高于目标值。
  • 相机还使用 AutoTargetBrightness 参数来控制 Exposure Auto 自动功能。如果要同时使用 Gain Auto 和 Exposure Auto 功能,使用 Auto Function Profile 功能可以指定如何平衡两者效果。
  • 在部分相机机型上,您可以使用 Remove Parameter Limits 功能提高目标值参数的上限。

在 Basler ace GigE 相机型号上,您还可以指定一个 Gray Value Adjustment Damping 系数。在 Basler dart 和 pulse 相机型号上,您可以指定 Brightness Adjustment Damping 系数。

如果使用阻尼系数,则达到目标值的速度会更慢。

示例代码#

ace Classic/U/L GigE 相机#
// Set the the Gain Auto auto function to its minimum lower limit
// and its maximum upper limit
double minLowerLimit = camera.AutoGainRawLowerLimit.GetMin();
double maxUpperLimit = camera.AutoGainRawUpperLimit.GetMax();
camera.AutoGainRawLowerLimit.SetValue(minLowerLimit);
camera.AutoGainRawUpperLimit.SetValue(maxUpperLimit);
// Specify the target value
camera.AutoTargetValue.SetValue(150);
// Select auto function ROI 1
camera.AutoFunctionAOISelector.SetValue(AutoFunctionAOISelector_AOI1);
// Enable the 'Intensity' auto function (Gain Auto + Exposure Auto)
// for the auto function ROI selected
camera.AutoFunctionAOIUsageIntensity.SetValue(true);
// 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 minimum lower limit
// and its maximum upper limit
double minLowerLimit = CFloatParameter(nodemap, "AutoGainRawLowerLimit").GetMin();
double maxUpperLimit = CFloatParameter(nodemap, "AutoGainRawUpperLimit").GetMax();
CFloatParameter(nodemap, "AutoGainRawLowerLimit").SetValue(minLowerLimit);
CFloatParameter(nodemap, "AutoGainRawUpperLimit").SetValue(maxUpperLimit);
// Specify the target value
CIntegerParameter(nodemap, "AutoTargetValue").SetValue(150);
// Select auto function ROI 1
CEnumParameter(nodemap, "AutoFunctionAOISelector").SetValue("AOI1");
// Enable the 'Intensity' auto function (Gain Auto + Exposure Auto)
// for the auto function ROI selected
CBooleanParameter(nodemap, "AutoFunctionAOIUsageIntensity").SetValue(true);
// Enable Gain Auto by setting the operating mode to Continuous
CEnumParameter(nodemap, "GainAuto").SetValue("Continuous");
// Set the the Gain Auto auto function to its minimum lower limit
// and its maximum upper limit
double minLowerLimit = camera.Parameters[PLCamera.AutoGainRawLowerLimit].GetMinimum();
double maxUpperLimit = camera.Parameters[PLCamera.AutoGainRawUpperLimit].GetMaximum();
camera.Parameters[PLCamera.AutoGainRawLowerLimit].SetValue(minLowerLimit);
camera.Parameters[PLCamera.AutoGainRawUpperLimit].SetValue(maxUpperLimit);
// Specify the target value
camera.Parameters[PLCamera.AutoTargetValue].SetValue(150);
// Select auto function ROI 1
camera.Parameters[PLCamera.AutoFunctionAOISelector].SetValue(PLCamera.AutoFunctionAOISelector.AOI1);
// Enable the 'Intensity' auto function (Gain Auto + Exposure Auto)
// for the auto function ROI selected
camera.Parameters[PLCamera.AutoFunctionAOIUsageIntensity].SetValue(true);
// 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 minLowerLimit = 0;
double maxUpperLimit = 0;
/* Set the the Gain Auto auto function to its minimum lower limit */
/* and its maximum upper limit */
errRes = PylonDeviceGetFloatFeatureMin(hdev, "AutoGainRawLowerLimit", &minLowerLimit);
CHECK(errRes);
errRes = PylonDeviceGetFloatFeatureMax(hdev, "AutoGainRawUpperLimit", &maxUpperLimit);
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "AutoGainRawLowerLimit", minLowerLimit);
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "AutoGainRawUpperLimit", maxUpperLimit);
CHECK(errRes);
/* Specify the target value */
errRes = PylonDeviceSetIntegerFeature(hdev, "AutoTargetValue", 150);
CHECK(errRes);
/* Select auto function ROI 1 */
errRes = PylonDeviceFeatureFromString(hdev, "AutoFunctionAOISelector", "AOI1");
CHECK(errRes);
/* Enable the 'Intensity' auto function (Gain Auto + Exposure Auto) */
/* for the auto function ROI selected */
errRes = PylonDeviceSetBooleanFeature(hdev, "AutoFunctionAOIUsageIntensity", 1);
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 minimum lower limit
# and its maximum upper limit
minLowerLimit = camera.AutoGainRawLowerLimit.Min
maxUpperLimit = camera.AutoGainRawUpperLimit.Max
camera.AutoGainRawLowerLimit.Value = minLowerLimit
camera.AutoGainRawUpperLimit.Value = maxUpperLimit
# Specify the target value
camera.AutoTargetValue.Value = 150
# Select auto function ROI 1
camera.AutoFunctionAOISelector.Value = "AOI1"
# Enable the 'Intensity' auto function (Gain Auto + Exposure Auto)
# for the auto function ROI selected
camera.AutoFunctionAOIUsageIntensity.Value = True
# Enable Gain Auto by setting the operating mode to Continuous
camera.GainAuto.Value = "Continuous"
其他相机#
// Set the the Gain Auto auto function to its minimum lower limit
// and its maximum upper limit
double minLowerLimit = camera.AutoGainLowerLimit.GetMin();
double maxUpperLimit = camera.AutoGainUpperLimit.GetMax();
camera.AutoGainLowerLimit.SetValue(minLowerLimit);
camera.AutoGainUpperLimit.SetValue(maxUpperLimit);
// Specify the target value
camera.AutoTargetBrightness.SetValue(0.6);
// Select auto function ROI 1
camera.AutoFunctionROISelector.SetValue(AutoFunctionROISelector_ROI1);
// Enable the 'Brightness' auto function (Gain Auto + Exposure Auto)
// for the auto function ROI selected
camera.AutoFunctionROIUseBrightness.SetValue(true);
// 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 minimum lower limit
// and its maximum upper limit
double minLowerLimit = CFloatParameter(nodemap, "AutoGainLowerLimit").GetMin();
double maxUpperLimit = CFloatParameter(nodemap, "AutoGainUpperLimit").GetMax();
CFloatParameter(nodemap, "AutoGainLowerLimit").SetValue(minLowerLimit);
CFloatParameter(nodemap, "AutoGainUpperLimit").SetValue(maxUpperLimit);
// Specify the target value
CFloatParameter(nodemap, "AutoTargetBrightness").SetValue(0.6);
// Select auto function ROI 1
CEnumParameter(nodemap, "AutoFunctionROISelector").SetValue("ROI1");
// Enable the 'Brightness' auto function (Gain Auto + Exposure Auto)
// for the auto function ROI selected
CBooleanParameter(nodemap, "AutoFunctionROIUseBrightness").SetValue(true);
// Enable Gain Auto by setting the operating mode to Continuous
CEnumParameter(nodemap, "GainAuto").SetValue("Continuous");
// Set the the Gain Auto auto function to its minimum lower limit
// and its maximum upper limit
double minLowerLimit = camera.Parameters[PLCamera.AutoGainLowerLimit].GetMinimum();
double maxUpperLimit = camera.Parameters[PLCamera.AutoGainUpperLimit].GetMaximum();
camera.Parameters[PLCamera.AutoGainLowerLimit].SetValue(minLowerLimit);
camera.Parameters[PLCamera.AutoGainUpperLimit].SetValue(maxUpperLimit);
// Specify the target value
camera.Parameters[PLCamera.AutoTargetBrightness].SetValue(0.6);
// Select auto function ROI 1
camera.Parameters[PLCamera.AutoFunctionROISelector].SetValue(PLCamera.AutoFunctionROISelector.ROI1);
// Enable the 'Brightness' auto function (Gain Auto + Exposure Auto)
// for the auto function ROI selected
camera.Parameters[PLCamera.AutoFunctionROIUseBrightness].SetValue(true);
// 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 minLowerLimit = 0;
double maxUpperLimit = 0;
/* Set the the Gain Auto auto function to its minimum lower limit */
/* and its maximum upper limit */
errRes = PylonDeviceGetFloatFeatureMin(hdev, "AutoGainLowerLimit", &minLowerLimit);
CHECK(errRes);
errRes = PylonDeviceGetFloatFeatureMax(hdev, "AutoGainUpperLimit", &maxUpperLimit);
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "AutoGainLowerLimit", minLowerLimit);
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "AutoGainUpperLimit", maxUpperLimit);
CHECK(errRes);
/* Specify the target value */
errRes = PylonDeviceSetFloatFeature(hdev, "AutoTargetBrightness", 0.6);
CHECK(errRes);
/* Select auto function ROI 1 */
errRes = PylonDeviceFeatureFromString(hdev, "AutoFunctionROISelector", "ROI1");
CHECK(errRes);
/* Enable the 'Brightness' auto function (Gain Auto + Exposure Auto) */
/* for the auto function ROI selected */
errRes = PylonDeviceSetBooleanFeature(hdev, "AutoFunctionROIUseBrightness", 1);
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 minimum lower limit
# and its maximum upper limit
minLowerLimit = camera.AutoGainLowerLimit.Min
maxUpperLimit = camera.AutoGainUpperLimit.Max
camera.AutoGainLowerLimit.Value = minLowerLimit
camera.AutoGainUpperLimit.Value = maxUpperLimit
# Specify the target value
camera.AutoTargetBrightness.Value = 0.6
# Select auto function ROI 1
camera.AutoFunctionROISelector.Value = "ROI1"
# Enable the 'Brightness' auto function (Gain Auto + Exposure Auto)
# for the auto function ROI selected
camera.AutoFunctionROIUseBrightness.Value = True
# Enable Gain Auto by setting the operating mode to Continuous
camera.GainAuto.Value = "Continuous"

您也可以使用 pylon Viewer 轻松设置参数。