Compiling code samples and applications¶

This section explains how to compile the C++ code samples provided with Metavision SDK.

As an example, we take the Metavision Filtering sample from SDK Core Module. However, all other SDK samples and applications can be compiled in the same way.

Based on this tutorial, you can compile any SDK’s code sample or your own software using Metavision SDK.

Setup & Prerequisites¶

This tutorial requires:

• A compatible camera or a RAW file with recorded data (for example, you can use a file from our Sample Recordings)

• Linux Ubuntu or Windows 10

• The Metavision SDK software installed on your computer (see the installation guide)

Compilation on Linux¶

Note

If you built Metavision from the source code without the deployment step, the following steps won’t apply. In that case, follow the main compilation instructions for Linux that allows you to compile the whole Metavision project, including the samples and applications. If you want to compile a single sample, add --target sample_name to the compilation command.

To compile the code sample, make sure you installed cmake, libboost-program-options-dev and libeigen3-dev libraries:

sudo apt -y install cmake libboost-program-options-dev libeigen3-dev


Then, follow these steps:

• make a working copy of the code sample, for example to your home directory:

cp -r /usr/share/metavision/sdk/core/samples/metavision_filtering/ ~/        # If you installed Metavision with Essentials packages
cp -r /usr/local/share/metavision/sdk/core/samples/metavision_filtering/ ~/  # If you built the source code with the deployment step

• go to the directory with the code sample:

cd ~/metavision_filtering

• compile the code:

mkdir build && cd build
cmake ..
cmake --build .

• run the sample:

./metavision_filtering


Compilation on Windows¶

Setup¶

Note

If you built Metavision from the source code without the deployment step, the following steps won’t apply. In that case, follow the main compilation instructions for Windows that allows you to compile the whole Metavision project, including the samples and applications. If you want to compile a single sample, add --target sample_name to the compilation command.

To compile the code sample, you will need to install some extra tools:

• cmake

• C++ compiler (64-bit). You can choose one of the following solutions:

Then, follow these steps:

• open a command prompt

• make a working copy of the code sample, for example to your home directory:

xcopy "C:\Program Files\Prophesee\share\metavision\sdk\analytics\samples\metavision_filtering" "%HOMEPATH%\metavision_filtering" /I

• go to the directory with the code sample:

cd %HOMEPATH%\metavision_filtering


From here you can either compile the code from the command line directly, or you can create a Visual Studio project.

Compile from the command line¶

• compile the code:

mkdir build && cd build
cmake ..
cmake --build . --config Release

• run the sample:

cd %HOMEPATH%\metavision_filtering\build\release
metavision_filtering.exe


Compile with Visual Studio¶

• create a Visual Studio project (note, that this line works for Visual Studio 16 2019; change the command to match your installed version):

mkdir build && cd build
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_BUILD_TYPE=Release ..

• This will create metavision_filtering.sln file in the build folder of your sample. Open this file with Visual Studio.

• You can build the sample with Build -> Build Solution, or by pressing F7

• You can then execute the software with Debug -> Start without debugging, or by pressing CTRL+F5

• Ensure that Release and x64 are the selected solution configurations

• Ensure that the selected sample is the startup project. You can do this by right-clicking on the project sample (metavision_filtering in this case, on the left under ALL_BUILD) and selecting Set as Startup Project

Execution¶

When running this code sample, you will see a window with the filtered CD events. If you use a live camera and you do not see any event, then make sure that the camera objective is open and move your hand in front of it to see events.