Synchronous Free Run (blaze)#
Using the Feature#
Why Use Synchronous Free Run#
If you want use multiple blaze cameras to capture the same scene, you have to stagger the exposures on the individual cameras so that their light sources don't interfere with each other. Similar to ambient light, the light sources of the individual cameras also cause a reduction in image quality.
Using PTP, you can let a group of cameras capture images in synchronous free run but with the exposures starting consecutively in precisely time-aligned intervals and in chronological order. That way, the light of one camera doesn't interfere with the other cameras' measurements.
How It Works#
There are two ways to configure synchronous free run. To help you decide which option is best for you, you have to understand the general operating principle of the blaze camera when it comes to image acquisition.
When acquiring images, each frame is composed of eight subframes (4 subframes if Fast Mode is enabled). Each subframe can be viewed as a separate exposure because after exposing each subframe the illumination is switched off and the sensor is reset.
Frame Exposure Phases#
During an exposure, the following phases take place:
- Startup: This happens before the first and fifth subframe.
- Reset: The sensor is reset. This happens before each subframe is acquired.
- Exposure: The shutter opens and the sensor is exposed. This happens for each subframe.
- Readout: The data collected during the subframe is read out of the sensor.
The camera emits light only during the exposure phase.
The following figure shows the different phases of a frame exposure (only subframes 1, 2, and 8 are shown).
Synchronous Free Run#
Operating a camera in free run mode means that the camera triggers itself using an internal periodic trigger timer.
In synchronous free run mode, the camera clocks are synchronized using PTP. The synchronized clocks cause the internal trigger timers to be synchronized as well.
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 is reached, the internal trigger timer is started and the camera acquires data with a fixed frame rate.
Info
It is possible to set a start time that lies in the past. This case is treated as if the internal timer had been started in the past.
Info
A camera doesn't start acquisition until the AcquisitionStart
command is issued.
There are two ways to use synchronous free run:
Interleaved Mode#
If you want to operate two blaze cameras simultaneously, choose the interleaved mode. In this mode, a camera emits light while the other camera performs the sensor readout.
Info
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.
The sensor timing is also determined by the sensor readout time, which you can't change because it is a property of the sensor. However, the sensor readout time may differ depending on the cameras' hardware revisions. If this is the case, use the consecutive mode instead.
Consecutive Mode#
In most situations, operating more than two cameras in interleaved mode is not practical. Due to the close succession of the network packets you will most likely face dropped network packets and therefore incompletely grabbed data. For better results, use the consecutive mode, where the cameras acquire frames consecutively one after another.
This mode also has to be used if you want to operate several cameras with different sensor timings simultaneously.
To maximize the achievable frame rate, a camera's acquisition start time can be set to a time in the readout phase of the preceding camera.
Configuring the Cameras#
Info
The pylon Supplementary Package for blaze contains the MultiCamHelper C++ library. This library is part of the C++ sample collection and is located in the MultiCam/MultiCamHelper folder.
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.
The MultiCamHelper library also provides the GenericSynchronousFreeRunHelper class, which is useful if you want to synchronize blaze and 2D GigE cameras. How to use this class is demonstrated by the samples in the Multicam/ColorAndDepth folder.
If you use a programming language other than C++ or if you don't want to use the classes provided by the MultiCamHelper library, this section describes the procedure for configuring the cameras for synchronous free run. This procedure can be used for configuring the interleaved and the consecutive mode.
Variables Used#
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.
The actual values can be retrieved from the camera. The following table lists the parameter names that you have to read out:
Variable | Camera Parameter |
---|---|
t_startup | StartupTime |
t_reset | ResetTime |
t_exp | ExposureTime |
t_read | ReadoutTime |
t_frame | FrameDuration |
All the camera parameters listed above return values in microseconds (µs).
To configure the cameras and to start synchronous free run:
-
On each camera, enable PTP wait until the master clock selection has been performed and the clocks are sufficiently synchronized.
For details, see Precision Time Protocol (blaze). -
On each camera, configure the desired settings for
ExposureTime
,FastMode
, andHDRMode
.Info
When setting up the cameras for interleaved synchronous free run mode, you have to set the same values for
ExposureTime
,FastMode
, andHDRMode
. -
Calculate the maximum possible frame rate
fps_max
as described below. -
On each camera, set the
AcquisitionFrameRateEnable
parameter totrue
specify the desired frame rate by setting theAcquisitionFrameRate
parameter to a value equal to or less thanfps_max
.Info
You have to specify the same frame rate on all cameras.
-
For each camera, calculate the required trigger offset and set the resulting acquisition start times as described below.
-
Prepare the application's grab loop.
-
On each camera, issue the
StartAcquisition
command. -
Grab images from each camera.
Determining the Maximum Frame Rate#
When using consecutive synchronous free run, the maximum frame rate per camera is limited by the number of cameras and the frame duration of each camera.
When using interleaved synchronous free run, the cameras can be operated with the maximum possible frame rate.
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();
Interleaved Mode#
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.
Consecutive Mode#
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)
Calculating Trigger Offsets and Setting Acquisition Start Times#
The amount of time by which the individual acquisition start times have to be staggered depends on the sensor timings and whether interleaved or consecutive synchronous free run mode is used.
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.
The following pseudo code snippet illustrates how to calculate the trigger offsets for the cameras and how to set the acquisition start times.
Meaning of the variables used:
n
: Number of cameras.camera[]
: Array of cameras.t_0
: Current PTP timestamp [ns].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