Note

This C++ sample has a corresponding Python sample.

HAL Sync Sample

The sample metavision_hal_sync.cpp shows how to use Metavision HAL API for synchronizing two event-based cameras.

The source code of this sample can be found in <install-prefix>/share/metavision/hal/samples/metavision_hal_sync when installing Metavision SDK from installer or packages. For other deployment methods, check the page Path of Samples.

Prerequisites

You need two event-based cameras connected using a synchronization cable. One of the camera will be the master camera, while the other will be the slave camera. Specifically, the TRIGGER_OUT/EXT_SYNC_CLK_OUT signal of the master camera needs to be connected to the EXT_SYNC_CLK_IN signal of the slave camera.

See also

See the external triggers page for more information about Prophesee’s cameras Trigger In and Trigger Out.

You will need to start the slave camera first, followed by the master camera. You can connect both cameras to the same PC or to two different PCs. When using the same PC, make sure to specify the serial number of the camera you want to use.

Note

To identify the master and slave cameras, you should use the Serial Number (SERIAL_NUMBER is the commands below) that can be retrieved using Metavision Platform Info Application (the Serial Number it the Serial from the output, e.g. 00ca0009).

Expected Output

The sample visualizes CD events on the screen. Note that the slave camera will not visualize any events until the master camera is started.

Expected Output from Metavision HAL Sync Sample

How to start

First, compile the sample as described in this tutorial.

To start the sample, first run the slave camera:

Linux

./metavision_hal_sync --slave -s SERIAL_NUMBER

Windows

metavision_hal_sync.exe --slave -s SERIAL_NUMBER

Then start the master camera:

Linux

./metavision_hal_sync --master -s SERIAL_NUMBER

Windows

metavision_hal_sync.exe --master -s SERIAL_NUMBER

Warning

When starting the second camera (the master), you may get an error message similar to [HAL][ERROR] Camera is busy (r=-6). This error message can be safely ignored. It is only an symptom of the sample trying to connect to all the connected cameras to retrieve their serial number, and randomly trying the slave first which is already connected (i.e. “busy”).

To check for additional options:

Linux

./metavision_hal_sync -h

Windows

metavision_hal_sync.exe -h

Note

You cannot run this sample from a pre-recorded RAW file, as the synchronization only works with live camera. RAW files recorded with synchronized cameras will have synchronized timestamps, but can be played separately using any available RAW player.

Code Notes

The code of this sample is very similar to the one of the Metavision HAL Viewer. Essentially, the synchronization is done using the two functions Metavision::I_DeviceControl::set_mode_master() and Metavision::I_DeviceControl::set_mode_slave().

Note

If you are interested in multi-cameras synchronization, check our Knowledge Center with more information on that topic.