Synchronizing IDS GigE Vision cameras with PTP

Clock comparison

When applications involve the processing of image material from multiple cameras, the precise time or the correct chronological sequence of the image recordings is often important for subsequent processing. If a time stamp is provided, a time reference to the different image data can be established. However, it is important that the time base of the cameras matches precisely. Using the "Precision Time Protocol" (PTP), IDS GigE Vision cameras can be synchronized easily with firmware 2.2 and higher.

Synchronizing IDS GigE Vision cameras with PTP

Precision Time Protocol (PTP) is a time synchronization standard ( IEEE1588) which allows time synchronization of devices connected via network. Cameras supporting this standard exchange synchronization messages with a time master in defined cycles. With the timestamp information at the respective send and receive time, the internal counters of the cameras can be calibrated very accurately and kept in tune. With camera firmware version 2.2 all IDS GigE Vision cameras become PTP-compatible!

PTP is not defined for USB connections, so this application note only refers to IDS GigE Vision cameras.

The IEEE1588 time stamp is an epoch timer with the 1 January 1970, 00:00 hours, set as zero time, and provides a resolution of 1 ns (1 GHz). Whereas the accuracy of time synchronization between network devices is rather in the microsecond range due to inaccuracies in latencies and signal runtimes!

PTP use cases

PTP is a base technology which forms the fundament for various applications with temporal reference of the image contents. This can be produced differently depending on the requirements of an application and the complexity of the network infrastructure:

1. Relative timestamp synchronization

In this case, all cameras are in the same network. One camera is the master, the others are slaves. The timestamps of all slave cameras are synchronized with the master camera. The cameras do not provide absolute timestamps (real time), nor can they be triggered synchronously without additional effort.

Advantages:

  • Relative timestamps establish a temporal assignment of the image recordings of all cameras in the application. Which image was first, and how big is the time difference between the images of different cameras.
  • relative timestamps can be generated without additional effort and costs for special network infrastructure.

2. Timestamp synchronization with absolute time

In this case, the network cameras are synchronized with an external master. This PTP master can be a network card that supports the so-called "hardware timestamping" - without hardware support the accuracy of synchronization suffers considerably. In addition to the necessary hardware, also software that supports PTP is required (not part of IDS peak!).

Advantages:

  • Image contents with global (real) timestamps can be associated with any other information with real time reference beyond the limits of the application.
  • Image contents can be reused for other applications or evaluations with global time reference.

Use PTP: "Relative synchronization"

The following section describes an example of how to establish a "relative synchronization" of timestamps between two PTP-capable network cameras.

Hardware Setup

Two different IDS GigE Vision cameras (GV-526xFA-C, GV-504xCP-M) with firmware 2.2 ("PTP capable") are connected to the same network switch. An additional host PC only serves to control and configure the cameras. It is not involved in the PTP synchronization of the cameras.

Software Setup

All PTP configuration functions can be found in the cameras' feature nodemap under the category "PtpControl". These functions are available since firmware version 2.2. To set up the PTP synchronization we use the Vision Cockpit of the IDS peak installation on the host PC.

Configure a camera as PTP master

The GV-526xFA-C camera should be configured as PTP master device. Open the camera in the Vision Cockpit and activate PTP by setting "PtpEnable" to "True". In addition, the camera receives permission to assume the master role by setting "PtpSlaveOnly" to "False".

# Configure master camera
PtpEnable = True
PtpSlaveOnly = False

Configure the other camera as PTP slave

The GV-504xCP-M shall be configured as PTP slave device. PTP is also activated here by setting "PtpEnable" to "True". But this time the camera is only limited to working as a slave device. For this purpose "PtpSlaveOnly" remains set to "True".

# Configure slave camera
PtpEnable = True
PtpSlaveOnly = True

Establishment of the master-slave hierarchy

As soon as a master and a slave device are configured, the master-slave hierarchy is automatically established. For the master camera, this can be determined by changing "PtpStatus" from "Listening" to "Master". For the slave camera, you can recognize this by checking the "PtpStatus" changes from "Listening" to "Uncalibrated" first and then to "Slave" after the synchronization with the master camera is completed.

Once the master-slave hierarchy of the cameras has been established using their new PTP capabilities, "relative synchronization" is complete.

Enable timestamps

If you want to use timestamps of the now synchronized cameras with the image data in your application, you have to activate the transmission of the timestamps as metadata (with chunk data).
First activate the transfer of chunk data with the image buffer by setting "ChunkModeActive" to "True". Then select "Timestamp" via the "ChunkSelector" and activate it via the "ChunkEnable" switch.

# activate chunk data creation
ChunkModeActive = True
 
# enable "ChunkTimestamp"
ChunkSelector = Timestamp
ChunkEnable = True

From now on, the camera generates a timestamp with each image acquisition and transfers it with the image buffer (in the chunk data) to the host PC. The chunk data and thus the timestamps can be read out with any Vision Standard software.

# image acquisition configuration for both cameras
LineSelector = Line2
LineMode = Output
LineSource = PPS
TriggerSelector = ExposureStart
TriggerMode = On
TriggerSource = Line2
 
# Limit bandwidth on both cameras
DeviceLinkThroughputLimit = 60000000
 
# Start acquisition on both cameras
Execute AcquisitionStart
Due to the synchronized PPS trigger signals, the image acquisition of the cameras takes place at the same time
Due to the synchronized PPS trigger signals, the image acquisition of the cameras takes place at the same time

Read timestamps

To process the timestamps in your application together with the image contents, you have to read the chunk data of the current image buffer. Since the chunk data is a manufacturer-specific payload buffer with usually unknown memory layout, the individual metadata is read out via the nodemap. For this purpose, all existing metadata is transferred from the GenTL with its standardized node names to the nodemap, so that they are accessible via the standard API.

With the upcoming IDS peak 1.1 update in early April, you can retrieve and process timestamps and all other chunk data very conveniently via the IDS peak API. The following source code snippet shows an example of how to extract timestamps from an image buffer. A complete source code example demonstrating the handling of chunk data can also be found in the installation package of your IDS peak SDK (from version 1.1).

// Get buffer from device's datastream
const auto buffer = m_dataStream->WaitForFinishedBuffer(5000);
 
// check buffer for chunks
if (buffer->HasChunks())
{
    // update nodemap with current chunk data
    m_nodemapRemoteDevice->UpdateChunkNodes(buffer);
 
    // Get the value of the timestamp chunk
    const auto chunktimestamp = m_nodemapRemoteDevice->FindNode<peak::core::nodes::FloatNode>("ChunkTimestamp")->Value();
}