Spatial Correction#
The feature is only available on Basler racer 2 color cameras.
该功能的使用#
运作原理#
Basler racer 2 color cameras are equipped with two different sensor types: a color dual line or a color triple line sensor.
信息
To find out the sensor type of your camera model, check the camera topic of your camera model. You can find your camera topic in the Area and Line Scan Cameras section under "Models".
The color dual line sensor has two pixel lines and the color triple line sensor has three pixel lines arranged next to each other. The lines of the dual line sensor are directly adjacent to each other, whereas the lines of the triple line sensor are separated from each other by a gap.
Each line has a different field of view on any object passing the camera. Whenever an acquisition is triggered, all lines of the sensor are exposed simultaneously. This means that for a single exposure, each line in the sensor acquires a different area on the object.
The following illustration shows the field of view of a color triple line sensor.
In the folowing example, a single small area "A" on an object passes the camera. As the object passes the camera, area A falls into the line of view of the blue line, of the green line, and of the red line at three different times. This means that the blue information for area A, the green information for area A, and the red information for area A are collected during three different image acquisitions.
To get the full RGB information for area A, the data from three different acquisitions must be combined. This need to combine data from different acquisitions to get the full color information is known as spatial correction. In other words, spatial correction aligns color information of the image. The data of the red line of the current exposure is combined with the data of the green and blue lines, taken from exposures in the past.
Spatial Correction Stride#
即: BslSpatialCorrectionStride
parameter is used to enable and disable spatial correction and to set two aspects of spatial correction: the starting line and the stride.
Starting Line#
The spatial correction starting line relates to the direction in which the object is passing the camera. The following illustration shows the starting line on a triple line sensor depending on the direction of motion.
Setting the BslSpatialCorrectionStride
parameter to a positive or a negative value determines the starting line and thus the direction of spatial correction.
Color triple line sensor:
- Positive parameter value: The starting line is the blue line.
- Negative parameter value: The starting line is the red line.
Color dual line sensor:
- Positive parameter value: The starting line is the blue/red line.
- Negative parameter value: The starting line is the green line.
Stride#
The spatial correction stride determines the number of acquisitions that have to be buffered in order to combine the correct line data and to obtain the full RGB data for an area on the image.
The following tables show the relation between the stride value and the number of acquisitions needed to get the full RGB information.
Color Triple Line Sensor | |
---|---|
Stride = 1 | Full RGB = blue[n-2] + green[n-1] + red[n] |
Stride = 2 | Full RGB = blue[n-4] + green[n-2] + red[n] |
Stride = -1 | Full RGB = blue[n] + green[n-1] + red[n-2] |
Stride = -2 | Full RGB = blue[n] + green[n-2] + red[n-4] |
Color Dual Line Sensor | |
---|---|
Stride = 1 | Full RGB = blue/red[n-1] + green[n] |
Stride = -1 | Full RGB = blue/red[n] + green[n-1] |
即: BslSpatialCorrectionStride
parameter can be set in a range from -2 to 2, depending on your camera model.
Specifying a stride value of 0 effectively disables spatial correction.
信息
The line acquisition is usually triggered by the signals from an incremental encoder. The relation between the movement of the object from line to line and the triggered acquisitions must be set in such a way that it matches the pixel width of the lines.
Avoiding Halo Effects#
If the alignment of the color information is being done correctly, the acquired images will be sharp and clear as shown in the right side of the image below. If there are variations in the positioning of the image when it is acquired by the different lines, color “halos” will occur as shown in the left side of the image below.
For a given area on the object to be acquired correctly, its image must fall precisely on the color pixel lines in the sensor.
信息
To avoid color halos, make sure that your system design requirements are met correctly.
Reversal of Spatial Correction Direction#
The direction in which the object is passing the camera may alternate in your application environment. Or, the camera may move back and forth above the object. In both cases, the direction of motion changes. The information about a change of the direction of motion is essential for achieving proper spatial correction.
This information can be obtained through an I/O line or the Encoder Reverse 1 signal output by the camera's encoder control can be used.
即: BslSpatialCorrectionDirectionReversal
parameter allows you to determine which signal source should be used to trigger a reversal of the spatial correction direction.
You can set the BslSpatialCorrectionDirectionReversal
参数设置为以下值:
熄灭
: Direction reversal is disabled. The spatial correction direction is determined by the positive or negative value set for theBslSpatialCorrectionStride
parameter.Line1
,Line2
,Line3
: The spatial correction direction is reversed if the signal level of I/O line 1, 2, or 3 is high.EncoderReverse1
: The spatial correction direction is reversed if the Encoder Reverse 1 signal is high.
Configuring Spatial Correction#
To configure spatial correction:
- 设置
BslSpatialCorrectionStride
parameter, e.g., to 2. - If required, set the
BslSpatialCorrectionDirectionReversal
parameter, e.g., toEncoderReverse1
.
示例代码#
INodeMap& nodemap = camera.GetNodeMap();
// Set the stride for spatial correction to 2
CEnumParameter(nodemap, "BslSpatialCorrectionStride").SetValue("");
// Set the spatial correction direction reversal to Encoder Reverse 1
CEnumParameter(nodemap, "BslSpatialCorrectionDirectionReversal").SetValue("EncoderReverse1");
// Set the stride for spatial correction to 2
camera.Parameters[PLCamera.BslSpatialCorrectionStride].SetValue(PLCamera.BslSpatialCorrectionStride.);
// Set the spatial correction direction reversal to Encoder Reverse 1
camera.Parameters[PLCamera.BslSpatialCorrectionDirectionReversal].SetValue(PLCamera.BslSpatialCorrectionDirectionReversal.EncoderReverse1);
/* 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 */
/* Set the stride for spatial correction to 2 */
errRes = PylonDeviceFeatureFromString(hdev, "BslSpatialCorrectionStride", "");
CHECK(errRes);
/* Set the spatial correction direction reversal to Encoder Reverse 1 */
errRes = PylonDeviceFeatureFromString(hdev, "BslSpatialCorrectionDirectionReversal", "EncoderReverse1");
CHECK(errRes);
您也可以使用 pylon Viewer 轻松设置参数。