Inference Pipeline of Detection using C++

This sample allows you to quickly set up an inference pipeline for object detection. You can use our pre-trained TorchScript model for detection and tracking of vehicles and pedestrians. Check our pre-trained models page to find out how to retrieve the model depending on your Metavision SDK Package.

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

Expected Output

The pipeline takes events as input and outputs detected objects with bounding boxes and their corresponding confidence level.

Note

This sample is highly sensitive to the scene and settings. Please review and keep the following items in mind:

  • the network was trained on a dataset recorded by a camera positioned on top of a car facing forward. Its performance might be quite degraded in other settings.

  • light conditions play an important role in performance, as latency is lower in high-light conditions than in low-light conditions. Beware also of flickering lights that can cause surge in event rate (you can use AFK and/or tune biases to mitigate such a situation)

  • make sure your camera is properly focussed and check the minimum working distance of your lens (for example with the standard lens of the EVK4, the minimum working distance is 10 cm. So you won’t achieve good focus when tracking objects at distances less than 10 cm using the standard lens)

  • you should also adjust the parameters of the algorithm to improve the detection and/or processing time (“Data Association options” is a good start)

Setup & requirements

To run the sample, you will need:

  • a pre-trained TorchScript model with a JSON file of hyperparameters. Check our pre-trained models

  • an event-based camera or an event file (RAW, DAT or HDF5). We suggest you to start with driving_sample.raw, downloadable from our Sample Recordings

How to start

First, you need to compile the sample. Here, we assume you followed the Machine Learning Module Dependencies in the installation guide that requires to deploy libtorch in a LIBTORCH_DIR_PATH directory. If so, use those cmake commands to compile:

cmake .. -DCMAKE_PREFIX_PATH=`LIBTORCH_DIR_PATH` -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release

To start the sample based on recorded data, you need to provide the full path to an event file and the path to the pre-trained model. Here, we use the file driving_sample.raw and the model red_event_cube_05_2020:

Linux

metavision_detection --record-file driving_sample.raw --detector-model red_event_cube_05_2020/model.ptjit --display

Windows

metavision_detection.exe --record-file driving_sample.raw --detector-model red_event_cube_05_2020/model.ptjit --display

To find the full list of options, run:

Linux

metavision_detection -h

Windows

metavision_detection.exe -h