Skip to content

Spatial Correction#

The Spatical Correction camera feature allows you to combine the color information of a line scan sensor where more than one pixel line is exposed simultaneously.

The feature is only available on Basler racer 2 color cameras.

Using the Feature#

How It Works#

Basler racer 2 color cameras are equipped with two different sensor types: a color dual line or a color triple line sensor.

Info

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.

Color Camera Sensor Faces

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.

Field of View of 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.

Object Passing Line Scan Color Camera

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#

The 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.

Object Passing Line Scan Color Camera 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]

The 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.

Info

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.

Halo Effect

Info

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.

The 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 parameter to one of the following values:

  • Off: Direction reversal is disabled. The spatial correction direction is determined by the positive or negative value set for the BslSpatialCorrectionStride 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:

  1. Set the BslSpatialCorrectionStride parameter, e.g., to 2.
  2. If required, set the BslSpatialCorrectionDirectionReversal parameter, e.g., to EncoderReverse1.

Sample Code#

// Set the stride for spatial correction to 2
camera.BslSpatialCorrectionStride.SetValue(BslSpatialCorrectionStride_2);
// Set the spatial correction direction reversal to Encoder Reverse 1
camera.BslSpatialCorrectionDirectionReversal.SetValue(BslSpatialCorrectionDirectionReversal_EncoderReverse1);
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);
# Set the stride for spatial correction to 2
camera.BslSpatialCorrectionStride.Value = ""
# Set the spatial correction direction reversal to Encoder Reverse 1
camera.BslSpatialCorrectionDirectionReversal.Value = "EncoderReverse1"

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

Select camera