The Gain Auto camera feature automatically adjusts the gain within specified limits until a target brightness value has been reached.
The pixel data for the auto function can come from one or multiple auto function ROIs.
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.
Assign at least one auto function ROI to the Gain Auto auto function. Make sure the auto function ROI overlaps the image ROI, either partially or completely.
Set the GainAuto parameter to one of the following operating modes:
Once: The camera adjusts the gain until the specified target brightness value has been reached. When this has been achieved, or after a maximum of 30 calculation cycles, the camera sets the auto function to [Off` and applies the gain resulting from the last calculation to all following images.
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
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.
The auto function adjusts the GainRaw parameter value within limits specified by you.
To change the limits, set the AutoGainRawLowerLimit and the AutoGainRawUpperLimit parameters to the desired values.
Example: Assume you have set the AutoGainRawLowerLimit parameter to 2 and the AutoGainRawUpperLimit parameter to 6. During the automatic adjustment process, the gain will never be lower than 2 and never higher than 6.
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 AutoTargetValue 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 AutoTargetValue 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.
On some camera models, you can use the Remove Parameter Limits feature to increase the target value parameter limits.
// Set the the Gain Auto auto function to its minimum lower limit// and its maximum upper limitdoubleminLowerLimit=camera.AutoGainRawLowerLimit.GetMin();doublemaxUpperLimit=camera.AutoGainRawUpperLimit.GetMax();camera.AutoGainRawLowerLimit.SetValue(minLowerLimit);camera.AutoGainRawUpperLimit.SetValue(maxUpperLimit);// Specify the target valuecamera.AutoTargetValue.SetValue(150);// Select auto function ROI 1camera.AutoFunctionAOISelector.SetValue(AutoFunctionAOISelector_AOI1);// Enable the 'Intensity' auto function (Gain Auto + Exposure Auto)// for the auto function ROI selectedcamera.AutoFunctionAOIUsageIntensity.SetValue(true);// Enable Gain Auto by setting the operating mode to Continuouscamera.GainAuto.SetValue(GainAuto_Continuous);
INodeMap&nodemap=camera.GetNodeMap();// Set the the Gain Auto auto function to its minimum lower limit// and its maximum upper limitdoubleminLowerLimit=CFloatParameter(nodemap,"AutoGainRawLowerLimit").GetMin();doublemaxUpperLimit=CFloatParameter(nodemap,"AutoGainRawUpperLimit").GetMax();CFloatParameter(nodemap,"AutoGainRawLowerLimit").SetValue(minLowerLimit);CFloatParameter(nodemap,"AutoGainRawUpperLimit").SetValue(maxUpperLimit);// Specify the target valueCIntegerParameter(nodemap,"AutoTargetValue").SetValue(150);// Select auto function ROI 1CEnumParameter(nodemap,"AutoFunctionAOISelector").SetValue("AOI1");// Enable the 'Intensity' auto function (Gain Auto + Exposure Auto)// for the auto function ROI selectedCBooleanParameter(nodemap,"AutoFunctionAOIUsageIntensity").SetValue(true);// Enable Gain Auto by setting the operating mode to ContinuousCEnumParameter(nodemap,"GainAuto").SetValue("Continuous");
// Set the the Gain Auto auto function to its minimum lower limit// and its maximum upper limitdoubleminLowerLimit=camera.Parameters[PLCamera.AutoGainRawLowerLimit].GetMinimum();doublemaxUpperLimit=camera.Parameters[PLCamera.AutoGainRawUpperLimit].GetMaximum();camera.Parameters[PLCamera.AutoGainRawLowerLimit].SetValue(minLowerLimit);camera.Parameters[PLCamera.AutoGainRawUpperLimit].SetValue(maxUpperLimit);// Specify the target valuecamera.Parameters[PLCamera.AutoTargetValue].SetValue(150);// Select auto function ROI 1camera.Parameters[PLCamera.AutoFunctionAOISelector].SetValue(PLCamera.AutoFunctionAOISelector.AOI1);// Enable the 'Intensity' auto function (Gain Auto + Exposure Auto)// for the auto function ROI selectedcamera.Parameters[PLCamera.AutoFunctionAOIUsageIntensity].SetValue(true);// Enable Gain Auto by setting the operating mode to Continuouscamera.Parameters[PLCamera.GainAuto].SetValue(PLCamera.GainAuto.Continuous);
/* Macro to check for errors */#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)GENAPIC_RESULTerrRes=GENAPI_E_OK;/* Return value of pylon methods */doubleminLowerLimit=0;doublemaxUpperLimit=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 limitminLowerLimit=camera.AutoGainRawLowerLimit.MinmaxUpperLimit=camera.AutoGainRawUpperLimit.Maxcamera.AutoGainRawLowerLimit.Value=minLowerLimitcamera.AutoGainRawUpperLimit.Value=maxUpperLimit# Specify the target valuecamera.AutoTargetValue.Value=150# Select auto function ROI 1camera.AutoFunctionAOISelector.Value="AOI1"# Enable the 'Intensity' auto function (Gain Auto + Exposure Auto)# for the auto function ROI selectedcamera.AutoFunctionAOIUsageIntensity.Value=True# Enable Gain Auto by setting the operating mode to Continuouscamera.GainAuto.Value="Continuous"
// Set the the Gain Auto auto function to its minimum lower limit// and its maximum upper limitdoubleminLowerLimit=camera.AutoGainLowerLimit.GetMin();doublemaxUpperLimit=camera.AutoGainUpperLimit.GetMax();camera.AutoGainLowerLimit.SetValue(minLowerLimit);camera.AutoGainUpperLimit.SetValue(maxUpperLimit);// Specify the target valuecamera.AutoTargetBrightness.SetValue(0.6);// Select auto function ROI 1camera.AutoFunctionROISelector.SetValue(AutoFunctionROISelector_ROI1);// Enable the 'Brightness' auto function (Gain Auto + Exposure Auto)// for the auto function ROI selectedcamera.AutoFunctionROIUseBrightness.SetValue(true);// Enable Gain Auto by setting the operating mode to Continuouscamera.GainAuto.SetValue(GainAuto_Continuous);
INodeMap&nodemap=camera.GetNodeMap();// Set the the Gain Auto auto function to its minimum lower limit// and its maximum upper limitdoubleminLowerLimit=CFloatParameter(nodemap,"AutoGainLowerLimit").GetMin();doublemaxUpperLimit=CFloatParameter(nodemap,"AutoGainUpperLimit").GetMax();CFloatParameter(nodemap,"AutoGainLowerLimit").SetValue(minLowerLimit);CFloatParameter(nodemap,"AutoGainUpperLimit").SetValue(maxUpperLimit);// Specify the target valueCFloatParameter(nodemap,"AutoTargetBrightness").SetValue(0.6);// Select auto function ROI 1CEnumParameter(nodemap,"AutoFunctionROISelector").SetValue("ROI1");// Enable the 'Brightness' auto function (Gain Auto + Exposure Auto)// for the auto function ROI selectedCBooleanParameter(nodemap,"AutoFunctionROIUseBrightness").SetValue(true);// Enable Gain Auto by setting the operating mode to ContinuousCEnumParameter(nodemap,"GainAuto").SetValue("Continuous");
// Set the the Gain Auto auto function to its minimum lower limit// and its maximum upper limitdoubleminLowerLimit=camera.Parameters[PLCamera.AutoGainLowerLimit].GetMinimum();doublemaxUpperLimit=camera.Parameters[PLCamera.AutoGainUpperLimit].GetMaximum();camera.Parameters[PLCamera.AutoGainLowerLimit].SetValue(minLowerLimit);camera.Parameters[PLCamera.AutoGainUpperLimit].SetValue(maxUpperLimit);// Specify the target valuecamera.Parameters[PLCamera.AutoTargetBrightness].SetValue(0.6);// Select auto function ROI 1camera.Parameters[PLCamera.AutoFunctionROISelector].SetValue(PLCamera.AutoFunctionROISelector.ROI1);// Enable the 'Brightness' auto function (Gain Auto + Exposure Auto)// for the auto function ROI selectedcamera.Parameters[PLCamera.AutoFunctionROIUseBrightness].SetValue(true);// Enable Gain Auto by setting the operating mode to Continuouscamera.Parameters[PLCamera.GainAuto].SetValue(PLCamera.GainAuto.Continuous);
/* Macro to check for errors */#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)GENAPIC_RESULTerrRes=GENAPI_E_OK;/* Return value of pylon methods */doubleminLowerLimit=0;doublemaxUpperLimit=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 limitminLowerLimit=camera.AutoGainLowerLimit.MinmaxUpperLimit=camera.AutoGainUpperLimit.Maxcamera.AutoGainLowerLimit.Value=minLowerLimitcamera.AutoGainUpperLimit.Value=maxUpperLimit# Specify the target valuecamera.AutoTargetBrightness.Value=0.6# Select auto function ROI 1camera.AutoFunctionROISelector.Value="ROI1"# Enable the 'Brightness' auto function (Gain Auto + Exposure Auto)# for the auto function ROI selectedcamera.AutoFunctionROIUseBrightness.Value=True# Enable Gain Auto by setting the operating mode to Continuouscamera.GainAuto.Value="Continuous"