Compiling code samples and applications

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

As an example, we take the Metavision Tracking code sample from SDK Analytics Module. However, all other SDK samples can be compiled in the same way. The Metavision Tracking code sample shows how to use Metavision SDK Analytics API to track moving objects and visualize them on a screen.

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 Metavision dataset)

  • Linux Ubuntu or Windows 10

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

Compilation on Linux

To compile the code sample, you will need to install libboost-program-options-dev and libeigen3-dev libraries:

sudo apt install libboost-program-options-dev
sudo apt install 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/analytics/samples/metavision_generic_tracking/ ~/
    
  • go to the directory with the code sample:

    cd ~/metavision_generic_tracking
    
  • compile the code:

    mkdir build && cd build
    cmake ..
    cmake --build .
    
  • run the sample:

    • If you are using a live camera, you can run the sample as follows:

    ./metavision_generic_tracking
    
    • If you want to run the sample with a RAW file as input, then you must provide the full path to the RAW file (here, we use a file from Metavision Dataset)

    ./metavision_generic_tracking -i traffic_monitoring.raw
    

When running this particular code sample, you will see a window with the CD events and bounding boxes around the tracked objects. 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.

Metavision Tracking Sample

Compilation on Windows

Setup

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

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_generic_tracking" "%HOMEPATH%\metavision_generic_tracking" /I
    
  • go to the directory with the code sample:

    cd %HOMEPATH%\metavision_generic_tracking
    

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_generic_tracking\build\release
    
    • If you are using a live camera, you can run the sample as follows:

    metavision_generic_tracking.exe
    
    • If you want to run the sample with a RAW file as input, then you must provide the full path to the RAW file (here, we use a file from Metavision Dataset)

    metavision_generic_tracking.exe -i traffic_monitoring.raw
    

Compile with Visual Studio

Follow these steps:

  • 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_generic_tracking.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_generic_tracking in this case, on the left under ALL_BUILD) and selecting Set as Startup Project

Execution

When running this particular code sample, you will see a window with the CD events and bounding boxes around the tracked objects. 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.

Metavision Tracking Sample