prophesee-ai / openeb

Open source SDK to create applications leveraging event-based vision hardware equipment
https://www.prophesee.ai/metavision-intelligence/
169 stars 41 forks source link
camera-api computer-vision event-based event-based-camera event-camera neuromorphic neuromorphic-computing neuromorphic-engineering sdk

OpenEB

OpenEB is the open source project associated with Metavision SDK

It enables anyone to get a better understanding of event-based vision, directly interact with events and build their own applications or camera plugins. As a camera manufacturer, ensure your customers benefit from the most advanced event-based software suite available by building your own plugin. As a creator, scientist, academic, join and contribute to the fast-growing event-based vision community.

OpenEB is composed of the Open modules of Metavision SDK:

OpenEB also contains the source code of Prophesee camera plugins, enabling to stream data from our event-based cameras and to read recordings of event-based data. The supported cameras are:

This document describes how to compile and install the OpenEB codebase. For further information, refer to our online documentation where you will find some tutorials to get you started in C++ or Python, some samples to discover how to use our API and a more detailed description of our modules and packaging.

Compiling on Linux

Compilation and execution were tested on platforms that meet the following requirements:

Compilation on other platforms (alternate Linux distributions, different versions of Ubuntu, ARM processor architecture etc.) was not tested. For those platforms some adjustments to this guide or to the code itself may be required.

Upgrading OpenEB

If you are upgrading OpenEB from a previous version, you should first read carefully the Release Notes as some changes may impact your usage of our SDK (e.g. API updates) and cameras (e.g. firmware update might be necessary).

Then, you need to clean your system from previously installed Prophesee software. If after a previous compilation, you chose to deploy the Metavision files in your system path, then go to the build folder in the source code directory and launch the following command to remove those files:

sudo make uninstall

In addition, make a global check in your system paths (/usr/lib, /usr/local/lib, /usr/include, /usr/local/include) and in your environment variables (PATH, PYTHONPATH and LD_LIBRARY_PATH) to remove occurrences of Prophesee or Metavision files.

Retrieving OpenEB source code

To retrieve OpenEB source code, you can just clone the GitHub repository:

git clone https://github.com/prophesee-ai/openeb.git --branch 5.0.0

In the following sections, absolute path to this directory is called OPENEB_SRC_DIR

If you choose to download an archive of OpenEB from GitHub rather than cloning the repository, you need to ensure that you select a Full.Source.Code.* archive instead of using the automatically generated Source.Code.* archives. This is because the latter do not include a necessary submodule.

Prerequisites

Install the following dependencies:

sudo apt update
sudo apt -y install apt-utils build-essential software-properties-common wget unzip curl git cmake
sudo apt -y install libopencv-dev libboost-all-dev libusb-1.0-0-dev libprotobuf-dev protobuf-compiler
sudo apt -y install libhdf5-dev hdf5-tools libglew-dev libglfw3-dev libcanberra-gtk-module ffmpeg 

Optionally, if you want to run the tests, you need to install Google Gtest and Gmock packages. For more details, see Google Test User Guide:

sudo apt -y install libgtest-dev libgmock-dev

For the Python API, you will need Python and some additional libraries. We support Python 3.9 and 3.10 on Ubuntu 22.04 and Python 3.11 and 3.12 on Ubuntu 24.04.

We recommend using Python with virtualenv to avoid conflicts with other installed Python packages. So, first install it along with some Python development tools:

sudo apt -y install python3.x-venv python3.x-dev
# where "x" is 9, 10, 11 or 12 depending on your Python version

Next, create a virtual environment and install the necessary dependencies:

python3 -m venv /tmp/prophesee/py3venv --system-site-packages
/tmp/prophesee/py3venv/bin/python -m pip install pip --upgrade
/tmp/prophesee/py3venv/bin/python -m pip install -r OPENEB_SRC_DIR/utils/python/python_requirements/requirements_openeb.txt

Note that when creating the virtual environment, it is necessary to use the --system-site-packages option to ensure that the SDK packages installed in the system directories are accessible. However, this option also makes your local user site-packages (typically found in ~/.local/lib/pythonX.Y/site-packages) visible by default. To prevent this and maintain a cleaner virtual environment, you can set the environment variable PYTHONNOUSERSITE to true.

Optionally, you can run the activate command (source /tmp/prophesee/py3venv/bin/activate) to modify your shell's environment variables, setting the virtual environment's Python interpreter and scripts as the default for your current session. This allows you to use simple commands like python without needing to specify the full path each time.

The Python bindings of the C++ API rely on the pybind11 library, specifically version 2.11.0.

Note that pybind11 is required only if you want to use the Python bindings of the C++ API . You can opt out of creating these bindings by passing the argument -DCOMPILE_PYTHON3_BINDINGS=OFF at step 3 during compilation (see below). In that case, you will not need to install pybind11, but you won't be able to use our Python interface to the C++ API.

Unfortunately, there is no pre-compiled version of pybind11 available, so you need to install it manually:

wget https://github.com/pybind/pybind11/archive/v2.11.0.zip
unzip v2.11.0.zip
cd pybind11-2.11.0/
mkdir build && cd build
cmake .. -DPYBIND11_TEST=OFF
cmake --build .
sudo cmake --build . --target install

To use Machine Learning features, you need to install some additional dependencies.

First, if you have some Nvidia hardware with GPUs, you can optionally install CUDA (11.6 or 11.7) and cuDNN to leverage them with pytorch and libtorch.

Make sure that you install a version of CUDA that is compatible with your GPUs by checking Nvidia compatibility page.

Note that, at the moment, we don't support OpenCL and AMD GPUs.

Compilation

  1. Create and open the build directory OPENEB_SRC_DIR: mkdir build && cd build
  2. Generate the makefiles using CMake: cmake .. -DBUILD_TESTING=OFF. If you want to specify to cmake which version of Python to consider, you should use the option -DPython3_EXECUTABLE=<path_to_python_to_use>. This is useful, for example, when you have a more recent version of Python than the ones we support installed on your system. In that case, cmake would select it and compilation might fail.
  3. Compile: cmake --build . --config Release -- -j 4

Once the compilation is finished, you have two options: you can choose to work directly from the build folder or you can deploy the OpenEB files in the system path (/usr/local/lib, /usr/local/include...).

Note that if you are using a third-party camera, you need to install the plugin provided by the camera vendor and specify the location of the plugin using the MV_HAL_PLUGIN_PATH environment variable.

To get started with OpenEB, you can download some sample recordings and visualize them with metavision_viewer or you can stream data from your Prophesee-compatible event-based camera.

Running the test suite (Optional)

Running the test suite is a sure-fire way to ensure you did everything well with your compilation and installation process.

Compiling on Windows

Currently, we support only Windows 10. Compilation on other versions of Windows was not tested. For those platforms some adjustments to this guide or to the code itself may be required.

Upgrading OpenEB

If you are upgrading OpenEB from a previous version, you should first read carefully the Release Notes as some changes may impact your usage of our SDK (e.g. API updates) and cameras (e.g. firmware update might be necessary).

Then, if you have previously installed any Prophesee's software, you will need to uninstall it first. Remove the folders where you installed Metavision artifacts (check both the build folder of the source code and C:\Program Files\Prophesee which is the default install path of the deployment step).

Retrieving OpenEB source code

To retrieve OpenEB source code, you can just clone the GitHub repository:

git clone https://github.com/prophesee-ai/openeb.git --branch 5.0.0

In the following sections, absolute path to this directory is called OPENEB_SRC_DIR

If you choose to download an archive of OpenEB from GitHub rather than cloning the repository, you need to ensure that you select a Full.Source.Code.* archive instead of using the automatically generated Source.Code.* archives. This is because the latter do not include a necessary submodule.

Prerequisites

Some steps of this procedure don't work on FAT32 and exFAT file system. Hence, make sure that you are using a NTFS file system before going further.

You must enable the support for long paths:

To compile OpenEB, you will need to install some extra tools:

Note that if you're using vcpkg across multiple projects or versions of OpenEB, it’s beneficial to streamline the number of vcpkg installations you manage. To achieve this, you'll need the specific versions of the libraries required. You can find these versions by cross-referencing our vcpkg.json file with the official vcpkg repository, but for your convenience, we’ve listed them below:

Installing Python and libraries

%USERPROFILE%\AppData\Local\Programs\Python\Python39
%USERPROFILE%\AppData\Local\Programs\Python\Python39\Scripts
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps

We recommend using Python with virtualenv to avoid conflicts with other installed Python packages.

Create a virtual environment and install the necessary dependencies:

python -m venv C:\tmp\prophesee\py3venv --system-site-packages
C:\tmp\prophesee\py3venv\Scripts\python -m pip install pip --upgrade
C:\tmp\prophesee\py3venv\Scripts\python -m pip install -r OPENEB_SRC_DIR\utils\python\python_requirements\requirements_openeb.txt

When creating the virtual environment, it is necessary to use the --system-site-packages option to ensure that the SDK packages installed in the system directories are accessible. However, this option also makes your local user site-packages visible by default. To prevent this and maintain a cleaner virtual environment, you can set the environment variable PYTHONNOUSERSITE to true.

Optionally, you can run the activate command (C:\tmp\prophesee\py3venv\Scripts\activate) to modify your shell's environment variables, setting the virtual environment's Python interpreter and scripts as the default for your current session. This allows you to use simple commands like python without needing to specify the full path each time.

Prerequisites for the ML module

To use Machine Learning features, you need to install some additional dependencies.

First, if you have some Nvidia hardware with GPUs, you can optionally install CUDA (11.6 or 11.7) and cuDNN to leverage them with pytorch and libtorch.

Compilation

Compilation using CMake

Open a command prompt inside the OPENEB_SRC_DIR folder :

  1. Create and open the build directory, where temporary files will be created: mkdir build && cd build
  2. Generate the makefiles using CMake: cmake .. -A x64 -DCMAKE_TOOLCHAIN_FILE=<OPENEB_SRC_DIR>\cmake\toolchains\vcpkg.cmake -DVCPKG_DIRECTORY=<VCPKG_SRC_DIR>. Note that the value passed to the parameter -DCMAKE_TOOLCHAIN_FILE must be an absolute path, not a relative one.
  3. Compile: cmake --build . --config Release --parallel 4

Once the compilation is done, you have two options: you can choose to work directly from the build folder or you can deploy the OpenEB files (applications, samples, libraries etc.) in a directory of your choice.

Compilation using MS Visual Studio

Open a command prompt inside the OPENEB_SRC_DIR folder:

  1. Create and open the build directory, where temporary files will be created: mkdir build && cd build
  2. Generate the Visual Studio files using CMake: cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_TOOLCHAIN_FILE=<OPENEB_SRC_DIR>\cmake\toolchains\vcpkg.cmake -DVCPKG_DIRECTORY=<VCPKG_SRC_DIR> (adapt to your Visual Studio version). Note that the value passed to the parameter -DCMAKE_TOOLCHAIN_FILE must be an absolute path, not a relative one.
  3. Open the solution file metavision.sln, select the Release configuration and build the ALL_BUILD project.

Once the compilation is done, you can choose to work directly from the build folder or you can deploy the OpenEB files (applications, samples, libraries etc.) in a directory of your choice.

Camera Plugins

Prophesee camera plugins are included in OpenEB, but you need to install the drivers for the cameras to be available on Windows. To do so, follow this procedure:

  1. download wdi-simple.exe from our file server
  2. execute the following commands in a Command Prompt launched as an administrator:
wdi-simple.exe -n "EVK" -m "Prophesee" -v 0x04b4 -p 0x00f4
wdi-simple.exe -n "EVK" -m "Prophesee" -v 0x04b4 -p 0x00f5
wdi-simple.exe -n "EVK" -m "Prophesee" -v 0x04b4 -p 0x00f3

If you own an EVK2 or an RDK2, there are a few additional steps to complete that are detailed in our online documentation in the Camera Plugin section of the OpenEB install guide.

If you are using a third-party camera, you need to follow the instructions provided by the camera vendor to install the driver and the camera plugin. Make sure that you reference the location of the plugin in the MV_HAL_PLUGIN_PATH environment variable.

Getting Started

To get started with OpenEB, you can download some sample recordings and visualize them with metavision_viewer or you can stream data from your Prophesee-compatible event-based camera.

Running the test suite (Optional)

Running the test suite is a sure-fire way to ensure you did everything well with your compilation and installation process.