跳转到内容
暂存服务器
开发服务器

Spatial Correction#

相机功能允许您组合在多个像素行同时曝光的线扫描传感器的颜色信息。

信息

该功能的使用#

运作原理#

Basler racer 2 彩色相机配备了两种不同的传感器类型:彩色双行传感器或彩色三行传感器。

信息

要查明相机模型的传感器类型,请查看相机模型对应的相机主题。您可以在面阵和线阵相机部分找到您的相机主题。

彩色双行传感器具有两行像素,彩色三行传感器具有并排排列的三行像素。双行传感器的各行彼此直接相邻,而三行传感器的各行之间存在间隙。

彩色相机传感器表面

对于经过相机的任何物体,每一行都有不同的视场。每当触发采集时,传感器的所有行都会同时曝光。这意味着对于单次曝光,传感器中的每一行都会采集物体上的不同区域。

下图显示了彩色三行传感器的视场。

三行传感器的视场

在以下示例中,物体上的单个小区域“A”经过相机。随着物体经过相机,区域 A 在三个不同的时间分别落入蓝色行、绿色行和红色行的视场中。这意味着区域 A 的蓝色信息、区域 A 的绿色信息和区域 A 的红色信息是在三次不同的图像采集过程中收集的。

物体经过线扫描彩色相机

为了获取区域 A 的完整 RGB 信息,必须组合来自三次不同采集的数据。这种需要组合来自不同采集的数据以获取完整颜色信息的过程称为 Spatial Correction。换句话说,Spatial Correction 对齐了图像的颜色信息。当前曝光的红色行数据与过去曝光中获取的绿色和蓝色行数据相结合。

Spatial Correction 跨距#

即: BslSpatialCorrectionStride 参数用于启用和禁用 Spatial Correction,并设置 Spatial Correction 的两个方面:起始行和跨距。

起始行#

Spatial Correction 起始行与物体经过相机的方向有关。

手动设置 BslSpatialCorrectionStride 参数设置为正值或负值可确定起始行,从而确定 Spatial Correction 的方向。

线扫描彩色相机#

下图显示了根据运动方向在彩色三行传感器上的起始行。

物体经过线扫描彩色相机运动方向

彩色三线传感器:

  • 正参数值:起始行为蓝色行。
  • 负参数值:起始行为红色行。

彩色双线传感器:

  • 正参数值:起始行为蓝/红行。
  • 负参数值:起始行为绿色行。
线扫描黑白相机#

下图展示了根据运动方向确定的 黑白 四线传感器上的起始行。

物体通过线扫描黑白相机的运动方向

黑白四线传感器:

  • 正参数值:起始行为第 4 行。
  • 负参数值:起始行为第 1 行。

黑白双线传感器:

  • 正参数值:起始行为第 2 行。
  • 负参数值:起始行为第 1 行。

跨距#

Spatial Correction 跨度决定了必须缓冲的采集次数,以便组合正确的行数据,并为图像上的区域获取完整的 RGB 或完整的 HDR 数据。

即: BslSpatialCorrectionStride 参数的设置范围为 -4 到 4,具体取决于您的相机型号。将跨度值指定为 0 可有效禁用 Spatial Correction。

下表显示了跨度值与获取完整 RGB/HDR 信息所需的采集次数之间的关系。

线扫描彩色相机#
彩色双线传感器
Stride = 1 Full RGB = blue/red[n-1] + green[n]
Stride = -1 Full RGB = blue/red[n] + green[n-1]
彩色三线传感器
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]
线扫描黑白相机#
Mono Dual Line Sensor
Stride = 1 Full HDR = line 2[n-1] + line 1[n]
Stride = 2 Full HDR = line 2[n-2] + line 1[n]
Stride = -1 Full HDR = line 2[n] + line 1[n-1]
Stride = -2 Fuss HDR = line 2[n] + line 1[n-2]
Mono Quad Line Sensor
Stride = 1 Full HDR = line 4[n-3] + line 3[n-2] + line 2[n-1] + line 1[n]
Stride = 2 Full HDR = line 4[n-6] + line 3[n-4] + line 2[n-2] + line 1[n]
Stride = 3 Full HDR = line 4[n-9] + line 3[n-6] + line 2[n-3] + line 1[n]
Stride = 4 Full HDR = line 4[n-12] + line 3[n-8] + line 2[n-4] + line 1[n]
Stride = -1 Full HDR = line 4[n] + line 3[n-1] + line 2[n-2] + line 1[n-3]
Stride = -2 Full HDR = line 4[n] + line 3[n-2] + line 2[n-4] + line 1[n-6]
Stride = -3 Full HDR = line 4[n] + line 3[n-3] + line 2[n-6] + line 1[n-9]
Stride = -4 Full HDR = line 4[n] + line 3[n-4] + line 2[n-8] + line 1[n-12]

信息

行采集通常由来自增量编码器的信号触发。物体从一行移动到另一行的距离与触发采集之间的关系必须进行设置,使其与行的像素宽度相匹配。

避免光晕效应#

如果色彩信息的对齐正确,所采集的图像将清晰锐利,如以下图像右侧所示。如果在不同行采集图像时其位置存在偏差,则会出现颜色“光晕”,如以下图像左侧所示。

为了正确采集物体上的特定区域,其图像必须精准落在传感器中的彩色像素行上。

光晕效应

信息

为避免出现彩色光晕,请确保正确满足您的系统设计要求。

反转 Spatial Correction 方向#

在您的应用环境中,物体通过相机的方向可能会交替变化,或者相机可能会在物体上方来回移动。在这两种情况下,运动方向都会发生改变。有关运动方向改变的信息对于实现正确的 Spatial Correction 至关重要。

可以从 I/O 线路获取此信息,或者可以使用相机 Encoder Control 输出的 Encoder Reverse 1 信号。

即: BslSpatialCorrectionDirectionReversal 参数允许您确定应使用哪个信号源来触发 Spatial Correction 方向的反转。

如果可用,您可以将 BslSpatialCorrectionDirectionReversal 参数设置为以下值:

  • Off:禁用方向反转。Spatial Correction 方向由为以下项设置的正值或负值决定: BslSpatialCorrectionStride 参数。
  • Line1, Line2, Line3:如果 I/O 线路 1、2 或 3 的信号电平为高电平,则 Spatial Correction 方向反转。
  • EncoderReverse1:如果 Encoder Reverse 1 信号为高电平,则 Spatial Correction 方向反转。

配置 Spatial Correction#

若要配置 Spatial Correction:

  1. 设置 BslSpatialCorrectionStride 参数,例如设置为 2。
  2. 如果需要,请设置 BslSpatialCorrectionDirectionReversal 参数,例如设置为 EncoderReverse1.

示例代码#

// 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"

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