Balance White Auto#
自动功能的像素数据可以来自一个或多个自动功能 ROI。
要手动纠正色彩偏移,请使用 Balance White 功能。
该功能的使用#
启用或禁用 Balance White Auto#
要启用或禁用 Balance White Auto 自动功能:
- 将至少一个自动功能 ROI 分配给 Balance White Auto 自动功能。
确保自动功能 ROI 部分或完全与图像 ROI 重叠。 - 设置
BalanceWhiteAuto
参数设置为以下工作模式之一:Once
: The camera adjusts the white balance until the average gray values for red, green, and blue are identical. When this has been achieved, or after several calculation cycles, the camera sets the auto function toOff
and applies the balance ratios resulting from the last calculation to all following images.Continuous
:相机在采集图像时连续调节白平衡。调节过程将连续进行,直到将工作模式设置为Once
或Off
。Off
:禁用Balance White Auto自动功能。BalanceRatio
参数保持上一次自动或手动调整后得到的值。
信息
On the following camera models, the Continuous operating mode is not available: acA1600-20gc, acA1920-25gc, acA2500-14gc, racer 2 S color cameras
运作原理#
Automatic white balancing is a two-step process.
Depending on the camera model, the BalanceRatio
parameter is set in the following way:
For Basler ace, MED ace, boost V, dart Classic, and Basler pulse camera models:
- The camera compares the average gray values of the red, green, and blue pixels. It determines the color with the highest average gray value (i.e., the brightest color) and sets the
BalanceRatio
parameter value for this color to 1. -
相机会自动调节其他两种颜色的
BalanceRatio
参数值,直到红、绿和蓝的平均灰度值相同为止。一种颜色的
BalanceRatio
参数设置为 1,其他两种颜色的该参数设置为 1 到 ≈15.98 之间。示例:假设图像中的绿色像素具有最高的平均灰度值。如果启用Balance White Auto自动功能,相机将绿色的
BalanceRatio
参数值设置为 1。然后,相机自动调整红色和蓝色的BalanceRatio
参数值,直到红色、绿色和蓝色的平均灰度值相同为止。比如,新的白平衡参数分量可以是:绿色 = 1、红色 = 1.08789、蓝色 = 2.19678。
For Basler ace 2, boost R, dart R, and dart M camera models:
- The camera compares the average gray values of the red, green, and blue pixels. It determines the color with the median average gray value and sets the
BalanceRatio
parameter value for this color to 1. -
相机会自动调节其他两种颜色的
BalanceRatio
参数值,直到红、绿和蓝的平均灰度值相同为止。As a result, the BalanceRatio parameter is set to 1 for the color with the median gray value. For the color with a higher gray value compared to the median value, the BalanceRatio parameter is set to a value between 0 and 1, and for the color with a lower gray value compared to the median gray value the parameter is set between 1 and ≈15.98.
Example: Assume the green pixels in your image have the median gray value, the red pixels have a higher gray value, and the blue pixels have a lower gray value than the green pixels.
If you enable the Balance White Auto auto function, the camera sets theBalanceRatio
parameter value for green to 1, for red to a value between 0 and 1, and the value for blue to a value between 1 and ≈15.98. The new balance ratios could be, e.g., green = 1, red = 0.568, and blue = 3.1986.
信息
- 要查看红、绿或蓝的
BalanceRatio
参数值,请使用BalanceRatioSelector
切换到相应的颜色通道。 - 当相机连续拍摄图像时,自动功能会在经过较短的延迟后生效。前几张图像可能不受自动功能的影响。
- On boost V color cameras, the auto function ROIs which are assigned to the Balance White Auto auto function, must not contain any color pixels with 100 % saturation. Otherwise, undesirable false-color effects will occur.
示例代码#
ace Classic/U/L GigE 相机#
// Select auto function ROI 2
camera.AutoFunctionAOISelector.SetValue(AutoFunctionAOISelector_AOI2);
// Enable the Balance White Auto auto function
// for the auto function ROI selected
camera.AutoFunctionAOIUsageWhiteBalance.SetValue(true);
// Enable Balance White Auto by setting the operating mode to Continuous
camera.BalanceWhiteAuto.SetValue(BalanceWhiteAuto_Continuous);
INodeMap& nodemap = camera.GetNodeMap();
// Select auto function ROI 2
CEnumParameter(nodemap, "AutoFunctionAOISelector").SetValue("AOI2");
// Enable the Balance White Auto auto function
// for the auto function ROI selected
CBooleanParameter(nodemap, "AutoFunctionAOIUsageWhiteBalance").SetValue(true);
// Enable Balance White Auto by setting the operating mode to Continuous
CEnumParameter(nodemap, "BalanceWhiteAuto").SetValue("Continuous");
// Select auto function ROI 2
camera.Parameters[PLCamera.AutoFunctionAOISelector].SetValue(PLCamera.AutoFunctionAOISelector.AOI2);
// Enable the Balance White Auto auto function
// for the auto function ROI selected
camera.Parameters[PLCamera.AutoFunctionAOIUsageWhiteBalance].SetValue(true);
// Enable Balance White Auto by setting the operating mode to Continuous
camera.Parameters[PLCamera.BalanceWhiteAuto].SetValue(PLCamera.BalanceWhiteAuto.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 */
/* Select auto function ROI 2 */
errRes = PylonDeviceFeatureFromString(hdev, "AutoFunctionAOISelector", "AOI2");
CHECK(errRes);
/* Enable the Balance White Auto auto function */
/* for the auto function ROI selected */
errRes = PylonDeviceSetBooleanFeature(hdev, "AutoFunctionAOIUsageWhiteBalance", 1);
CHECK(errRes);
/* Enable Balance White Auto by setting the operating mode to Continuous */
errRes = PylonDeviceFeatureFromString(hdev, "BalanceWhiteAuto", "Continuous");
CHECK(errRes);
# Select auto function ROI 2
camera.AutoFunctionAOISelector.Value = "AOI2"
# Enable the Balance White Auto auto function
# for the auto function ROI selected
camera.AutoFunctionAOIUsageWhiteBalance.Value = True
# Enable Balance White Auto by setting the operating mode to Continuous
camera.BalanceWhiteAuto.Value = "Continuous"
其他相机#
// Select auto function ROI 2
camera.AutoFunctionROISelector.SetValue(AutoFunctionROISelector_ROI2);
// Enable the Balance White Auto auto function
// for the auto function ROI selected
camera.AutoFunctionROIUseWhiteBalance.SetValue(true);
// Enable Balance White Auto by setting the operating mode to Continuous
camera.BalanceWhiteAuto.SetValue(BalanceWhiteAuto_Continuous);
INodeMap& nodemap = camera.GetNodeMap();
// Select auto function ROI 2
CEnumParameter(nodemap, "AutoFunctionROISelector").SetValue("ROI2");
// Enable the Balance White Auto auto function
// for the auto function ROI selected
CBooleanParameter(nodemap, "AutoFunctionROIUseWhiteBalance").SetValue(true);
// Enable Balance White Auto by setting the operating mode to Continuous
CEnumParameter(nodemap, "BalanceWhiteAuto").SetValue("Continuous");
// Select auto function ROI 2
camera.Parameters[PLCamera.AutoFunctionROISelector].SetValue(PLCamera.AutoFunctionROISelector.ROI2);
// Enable the Balance White Auto auto function
// for the auto function ROI selected
camera.Parameters[PLCamera.AutoFunctionROIUseWhiteBalance].SetValue(true);
// Enable Balance White Auto by setting the operating mode to Continuous
camera.Parameters[PLCamera.BalanceWhiteAuto].SetValue(PLCamera.BalanceWhiteAuto.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 */
/* Select auto function ROI 2 */
errRes = PylonDeviceFeatureFromString(hdev, "AutoFunctionROISelector", "ROI2");
CHECK(errRes);
/* Enable the Balance White Auto auto function */
/* for the auto function ROI selected */
errRes = PylonDeviceSetBooleanFeature(hdev, "AutoFunctionROIUseWhiteBalance", 1);
CHECK(errRes);
/* Enable Balance White Auto by setting the operating mode to Continuous */
errRes = PylonDeviceFeatureFromString(hdev, "BalanceWhiteAuto", "Continuous");
CHECK(errRes);
# Select auto function ROI 2
camera.AutoFunctionROISelector.Value = "ROI2"
# Enable the Balance White Auto auto function
# for the auto function ROI selected
camera.AutoFunctionROIUseWhiteBalance.Value = True
# Enable Balance White Auto by setting the operating mode to Continuous
camera.BalanceWhiteAuto.Value = "Continuous"
您也可以使用 pylon Viewer 轻松设置参数。