跳转到内容

Synchronous Free Run (blaze)#

Synchronous Free Run 功能使您可以同时操作多台 blaze 相机(即使它们不在同一网络中),而它们的光源不会相互干扰。

该功能的使用#

为什么使用 Synchronous Free Run#

如果要使用多台 blaze 相机拍摄同一场景,您必须错开各台相机的曝光,以免它们的光源相互干扰。与环境光一样,各台相机的光源也会导致图像质量下降。

使用 PTP,您可以让一组相机以同步自由运行的方式捕获图像,但是曝光以精确的时间间隔和时间顺序连续开始。这样,一台相机的光源不会干扰其他相机的测量。

运作原理#

有两种配置 Synchronous Free Run 的方法。为了帮助您确定最适合您的选择,在涉及图像采集时,您必须了解 blaze 相机的一般工作原理。

采集图像时,每个帧由八个子帧组成(如果 Fast Mode 已启用,则为 4 个子帧)。可以将每个子帧视为单独的曝光,因为在暴露每个子帧后,照明将关闭并且传感器将重置。

帧曝光阶段#

曝光期间分为以下几个阶段:

  • Startup: 这发生在第一个和第五个子帧之前。
  • 重置:传感器重置。在采集每个子帧时重置。
  • 曝光:快门打开,传感器曝光。针对每帧。
  • 读出:从传感器中读取子帧期间收集的数据。

相机仅在曝光阶段发光。

下图显示了帧曝光的不同阶段(仅显示了子帧 1、2 和 8)。

帧曝光阶段

Synchronous Free Run#

在自由运行模式下操作相机意味着相机使用内部周期性触发定时器来触发自身。

在同步自由运行模式下,相机时钟使用 PTP 进行同步。同步时钟也会促使内部触发定时器同步。

When setting up cameras for synchronous free run, the cameras' acquisitions can be aligned by specifying individual acquisition start times for the cameras. Once a camera's acquisition start time (specified by the SyncFreeRunTimerStartTimeHigh and SyncFreeRunTimerStartTimeLow parameters) is reached, the internal trigger timer is started and the camera acquires data with a fixed frame rate.

信息

可以设置过去的开始时间。这种情况被视为过去已启动内部计时器。

信息

A camera doesn't start acquisition until the AcquisitionStart command is issued.

Synchronizing blaze and ace/ace 2 Cameras

  • If your application setup contains an ace camera, the start time must be in the near future.
  • If your application setup contains an ace 2 camera, the start time of the blaze camera must be 0.

有两种使用 Synchronous Free Run 的方法:

交错模式#

如果要同时操作两个 blaze 相机,请选择 interleaved 模式。在这种模式下,一个相机会发光,而另一个相机会执行传感器读出。

交错式 Synchronous Free Run

信息

The sensor timing for the cameras must be identical, i.e., you have to set the same values for the ExposureTime, FastMode, and HDRMode parameters.

传感器时序也由传感器读出时间决定,因为这是传感器的属性,所以不能更改。但是,传感器读出时间可能会因相机的硬件版本而异。如果是这种情况,请改用 consecutive 模式。

连续模式#

在大多数情况下,以交错模式操作两个以上的相机是不切实际的。由于网络数据包的紧密连续性,您很可能会遇到网络数据包丢失的情况,因此无法完全采集数据。为了获得更好的效果,请使用连续模式,在这种模式下,相机一个接一个地连续采集帧。

如果您想同时操作具有不同传感器时序的多个相机,也必须使用此模式。

连续式 Synchronous Free Run

如果要最大限度地提高可实现的帧速率,则可以将相机的采集开始时间设置为前一个相机的读出阶段的时间。

配置相机#

信息

pylon blaze 补充软件包含有 MultiCamHelper C++ 库。此库是 C++ 示例集合的一部分,位于 MultiCam/MultiCamHelper 文件夹中。

The library provides the BlazeSynchronousFreeRunHelper class, which Basler recommends for setting up several blaze cameras for synchronous free run, for capturing data, and matching frames that belong together chronologically. How to use this class is shown in the SynchronousFreeRun C++ sample.

MultiCamHelper 库还提供了 GenericSynchronousFreeRunHelper 类,如果您想同步 blaze 和 2D GigE 相机,这个类很有用。Multicam/ColorAndDepth 文件夹中的示例演示了如何使用这个类。

如果您使用 C++ 以外的编程语言,或者您不想使用 MultiCamHelper 库提供的类,本节将介绍配置相机以实现同步自由运行的过程。此过程可用于配置交错和连续模式。

使用的变量#
  • t_startup[i]: Duration of the frame startup time of the ith camera.
  • t_reset[i]: Duration of the ith camera's reset time (reset takes place at the beginning of each subframe).
  • t_exp[i]: Duration of the ith camera's exposure time for a single subframe.
  • t_read[i]: Duration of the ith camera's readout time for a single subframe.
  • t_frame[i]: Total time required for the ith camera to acquire all subframes of a frame.

可以从相机中检索出实际值。下表列出了必须读出的参数名称:

变量 相机参数
t_startup StartupTime
t_reset ResetTime
t_exp ExposureTime
t_read ReadoutTime
t_frame FrameDuration

上面列出的所有相机参数返回的值均以微秒 (µs) 为单位。

要配置相机并开始同步自由运行:

  1. 在每个相机上,启用 PTP 等待,直到执行了主时钟选择并且时钟充分同步。
    有关详细信息,请参阅 Precision Time Protocol (blaze)

  2. On each camera, configure the desired settings for ExposureTime, FastMode, and HDRMode.

    信息

    When setting up the cameras for interleaved synchronous free run mode, you have to set the same values for ExposureTime, FastMode, and HDRMode.

  3. Calculate the maximum possible frame rate fps_max as described below.

  4. On each camera, set the AcquisitionFrameRateEnable parameter to true specify the desired frame rate by setting the AcquisitionFrameRate parameter to a value equal to or less than fps_max.

    信息

    您必须在所有相机上指定相同的帧速率。

  5. 对于每个相机,计算所需的触发偏移并按照下文所述设置生成的采集开始时间。

  6. 准备应用程序的采集循环。

  7. On each camera, issue the StartAcquisition command.

  8. 采集每台相机的图像。

确定最大帧速率#

当使用连续式 Synchronous Free Run 时,每台相机的最大帧速率受相机数量和每台相机的帧时长限制。

使用交错同步自由运行时,相机能以最大的可能帧速率运行。

In the following, fps_max[i] denotes the maximum allowed value for the ith camera's AcquisitionFrameRate parameter. To read out fps_max[i] for camera i using the APIs of the pylon SDK, you can use the following code snippets:

C++

auto max = camera[i].AcquisitionFrameRate.GetMax();

C#

var max = camera[i].Parameters[PLBlaze.AcquisitionFrameRate].GetMaximum();

交错模式#

Since in interleaved mode the sensor timings must be identical for all cameras, set fps_max to the maximum frame rate value from either of the cameras.

连续模式#

You can calculate the maximum frame rate fps_max in consecutive mode as illustrated in the following pseudo code snippet:

    fmax_min = min(fps_max[0], ... ,fps_max[n-1])
    t_total = 0
    for i = 0 to n-1
       t_total = t_total + t_frame[i] - t_startup[i] - t_reset[i] - t_read[i]
    endif
    t_total = t_total + t_startup[0] + t_reset[0]
    fps = 1e6 / t_total
    fps_max = min(fps, fmax_min)

计算触发偏移和设置采集开始时间#

各个采集开始时间必须交错的时间量取决于传感器时序,以及使用的是交错还是连续同步自由运行模式。

The acquisition start times t_acq_start[i] should be set to some point in the future to ensure that no camera starts acquisition before your application has configured all cameras and set up a grab loop. You should factor in about 400 ms for configuring one camera.

以下伪代码片段说明了如何计算相机的触发偏移以及如何设置采集开始时间。

所用变量的含义:

  • n : Number of cameras.
  • camera[]: Array of cameras.
  • t_0: Current PTP timestamp [ns]. If only cameras are connected, the timestamp counts the number of ticks since the master device has been powered on. This means the timescale is arbitrary, relative, and only valid in this network. For an absolute timescale, connect a device that is synchronized to a coordinated world time (e.g., TAI or UTC).
  • fps_max: Maximum possible frame rate [Hz].
  • trigger_offset: Amount of time by which a camera's triggers are delayed compared to the previous camera.
  • t_acq_start[]: Acquisition start times [ns].
  • t_safety: Additional amount of time that the acquisition should be delayed by in order to compensate for jitter [µs]. Recommended value: 250 µs.
    camera[0].TimestampLatch.Execute()
    t_0 = camera[0].TimestampLatchValue.GetValue()
    t_acq_start[0] = t_0 + n * 400 * 1000000
    for i = 0 to n-1
        camera[i].SyncFreeRunTimerStartTimeLow.SetValue(t_acq_start[i] & 0xffffffff)
        camera[i].SyncFreeRunTimerStartTimeHigh.SetValue(t_acq_start[i] >> 32)
        camera[i].SyncFreeRunTimerUpdate.Execute()
        camera[i].SyncFreeRunEnable.SetValue(true)
        if i < n-1
            if interleaved_mode
                trigger_offset = 1000 * (t_safety + t_exp[i])
            else
                trigger_offset =
                    1000 * (t_safety + t_frame[i] - t_read[i] - t_startup[i+1] - t_reset[i+1]
            endif
            t_acq_start[i+1] = t_acq_start[i] + trigger_offset
        endif
    endfor