Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/openeb updates #123

Merged
merged 17 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ if(NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)

option(BUILD_TESTING "Build OpenEB's test suite" OFF)

cmake_minimum_required(VERSION 3.5)

project(metavision VERSION 4.6.2)
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ 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
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.
Expand Down Expand Up @@ -191,7 +191,7 @@ or you can deploy the OpenEB files in the system path (`/usr/local/lib`, `/usr/l
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](https://docs.prophesee.ai/stable/datasets.html)
To get started with OpenEB, you can download some [sample recordings](https://docs.prophesee.ai/stable/datasets.html)
and visualize them with [metavision_viewer](https://docs.prophesee.ai/stable/samples/modules/driver/viewer.html)
or you can stream data from your Prophesee-compatible event-based camera.

Expand All @@ -202,7 +202,7 @@ Running the test suite is a sure-fire way to ensure you did everything well with
* Download [the files](https://kdrive.infomaniak.com/app/share/975517/cddcc78a-3480-420f-bc19-17d5b0535ca4) necessary to run the tests.
Click `Download` on the top right folder. Beware of the size of the obtained archive which weighs around 1.2 Gb.

* Extract and put the content of this archive to `<OPENEB_SRC_DIR>/datasets`.
* Extract and put the content of this archive to `<OPENEB_SRC_DIR>/datasets`.
For instance, the correct path of sequence `gen31_timer.raw` should be `<OPENEB_SRC_DIR>/datasets/openeb/gen31_timer.raw`.

* Regenerate the makefiles with the test options enabled:
Expand All @@ -218,7 +218,7 @@ Running the test suite is a sure-fire way to ensure you did everything well with

## Compiling on Windows

Currently, we support only Windows 10.
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.

Expand Down Expand Up @@ -250,7 +250,7 @@ To compile OpenEB, you will need to install some extra tools:
* For building only, you can install MS Build Tools (free, part of Windows 10 SDK package)
* Download and run ["Build tools for Visual Studio 2022" installer](https://visualstudio.microsoft.com/visual-cpp-build-tools/)
* Select "C++ build tools", make sure Windows 10 SDK is checked, and add English Language Pack
* For development, you can also download and run [Visual Studio Installer](https://visualstudio.microsoft.com/downloads/)
* For development, you can also download and run [Visual Studio Installer](https://visualstudio.microsoft.com/downloads/)
* install [vcpkg](https://github.com/microsoft/vcpkg) that will be used for installing dependencies:
* download and extract [vcpkg version 2023.11.20](https://github.com/microsoft/vcpkg/archive/refs/tags/2023.11.20.zip)
* `cd <VCPKG_SRC_DIR>`
Expand Down Expand Up @@ -278,7 +278,7 @@ Those can be found in the [vcpkg repository](https://github.com/microsoft/vcpkg/
* Add Python install and script directories in your `PATH` and make sure they are listed before
the `WindowsApps` folder which contains a Python alias launching the Microsoft Store. So, if you installed
Python 3.8 in the default path, your user `PATH` should contain those three lines in that order:

```bash
%USERPROFILE%\AppData\Local\Programs\Python\Python38
%USERPROFILE%\AppData\Local\Programs\Python\Python38\Scripts
Expand Down Expand Up @@ -339,9 +339,9 @@ Open a command prompt inside the `openeb` folder (absolute path to this director

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.
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.

Expand All @@ -353,13 +353,13 @@ or you can deploy the OpenEB files (applications, samples, libraries etc.) in a
```bash
utils\scripts\setup_env.bat
```

* Option 2 - deploying in a directory of your choice

* To deploy OpenEB in the default folder (`C:\Program Files\Prophesee`), execute this command
* To deploy OpenEB in the default folder (`C:\Program Files\Prophesee`), execute this command
(your console should be launched as an administrator):

```bash
```bash
cmake --build . --config Release --target install
```

Expand All @@ -370,12 +370,12 @@ or you can deploy the OpenEB files (applications, samples, libraries etc.) in a
the `PYTHON3_SITE_PACKAGES` variable.

Here is an example of a command customizing those two folders:

```bash
cmake .. -A x64 -DCMAKE_TOOLCHAIN_FILE=<OPENEB_SRC_DIR>\cmake\toolchains\vcpkg.cmake -DVCPKG_DIRECTORY=<VCPKG_SRC_DIR> -DCMAKE_INSTALL_PREFIX=<OPENEB_INSTALL_DIR> -DPYTHON3_SITE_PACKAGES=<PYTHON3_PACKAGES_INSTALL_DIR> -DBUILD_TESTING=OFF
```
After this command, you should launch the actual compilation and installation of OpenEB

After this command, you should launch the actual compilation and installation of OpenEB
(your console should be launched as an administrator):

```bash
Expand All @@ -389,7 +389,7 @@ or you can deploy the OpenEB files (applications, samples, libraries etc.) in a
* append `<OPENEB_INSTALL_DIR>\lib\metavision\hal\plugins` to `MV_HAL_PLUGIN_PATH` (`C:\Program Files\Prophesee\lib\metavision\hal\plugins` if you used default configuration)
* append `<OPENEB_INSTALL_DIR>\lib\hdf5\plugin` to `HDF5_PLUGIN_PATH` (`C:\Program Files\Prophesee\lib\hdf5\plugin` if you used default configuration)
* append `<PYTHON3_PACKAGES_INSTALL_DIR>` to `PYTHONPATH` (not needed if you used default configuration)


#### Compilation using MS Visual Studio

Expand Down Expand Up @@ -438,7 +438,7 @@ the `MV_HAL_PLUGIN_PATH` environment variable.

#### Getting Started

To get started with OpenEB, you can download some [sample recordings](https://docs.prophesee.ai/stable/datasets.html)
To get started with OpenEB, you can download some [sample recordings](https://docs.prophesee.ai/stable/datasets.html)
and visualize them with [metavision_viewer](https://docs.prophesee.ai/stable/samples/modules/driver/viewer.html)
or you can stream data from your Prophesee-compatible event-based camera.

Expand All @@ -449,8 +449,8 @@ Running the test suite is a sure-fire way to ensure you did everything well with

* Download [the files](https://kdrive.infomaniak.com/app/share/975517/cddcc78a-3480-420f-bc19-17d5b0535ca4) necessary to run the tests.
Click `Download` on the top right folder. Beware of the size of the obtained archive which weighs around 1.2 Gb.
* Extract and put the content of this archive to `<OPENEB_SRC_DIR>/datasets`.

* Extract and put the content of this archive to `<OPENEB_SRC_DIR>/datasets`.
For instance, the correct path of sequence `gen31_timer.raw` should be `<OPENEB_SRC_DIR>/datasets/openeb/gen31_timer.raw`.

* To run the test suite you need to reconfigure your build environment using CMake and to recompile
Expand Down
6 changes: 3 additions & 3 deletions sdk/modules/core/cpp/samples/metavision_player/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ bool parse_command_line(int argc, const char *argv[], Parameters &app_params) {
}

// Check extension of provided output files
if (boost::filesystem::extension(app_params.out_bias_file) != ".bias") {
if (boost::filesystem::path(app_params.out_bias_file).extension() != ".bias") {
MV_LOG_ERROR() << "Wrong extension for provided output bias file: supported extension is '.bias'";
return false;
}
if (boost::filesystem::extension(app_params.out_png_file) != ".png") {
if (boost::filesystem::path(app_params.out_png_file).extension() != ".png") {
MV_LOG_ERROR() << "Wrong extension for provided output PNG file: supported extension is '.png'";
return false;
}
if (boost::filesystem::extension(app_params.out_avi_file) != ".avi") {
if (boost::filesystem::path(app_params.out_avi_file).extension() != ".avi") {
MV_LOG_ERROR() << "Wrong extension for provided output AVI file: supported extension is '.avi'";
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions sdk/modules/driver/cpp/src/biases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ Biases::~Biases() {}

void Biases::set_from_file(const std::string &biases_filename) {
// Check extension
const auto extension = boost::filesystem::extension(biases_filename);
if (extension != ".bias") {
const boost::filesystem::path biases_file_path = biases_filename;
if (biases_file_path.extension() != ".bias") {
throw CameraException(CameraErrorCode::WrongExtension,
"For bias file '" + biases_filename +
"' : expected '.bias' extension to set the bias from this file but got '." +
extension + "'");
biases_file_path.extension().generic_string() + "'");
}

// open file
Expand Down Expand Up @@ -106,12 +106,12 @@ void Biases::set_from_file(const std::string &biases_filename) {
}

void Biases::save_to_file(const std::string &dest_file) const {
const auto extension = boost::filesystem::extension(dest_file);
if (extension != ".bias") {
const boost::filesystem::path biases_file_path = dest_file;
if (biases_file_path.extension() != ".bias") {
throw CameraException(CameraErrorCode::WrongExtension,
"For bias file '" + dest_file +
"' : expected '.bias' extension to set the bias from this file but got '." +
extension + "'");
biases_file_path.extension().generic_string() + "'");
}

std::ofstream output_file(dest_file);
Expand Down
25 changes: 13 additions & 12 deletions sdk/modules/driver/cpp/src/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,18 @@ bool Camera::Private::process_impl() {
}

bool Camera::Private::start_recording_impl(const std::string &file_path) {
std::string ext = boost::filesystem::extension(file_path);
boost::filesystem::path path_obj(file_path);
std::shared_ptr<Metavision::EventFileWriter> writer;
if (ext == ".raw") {
if (path_obj.extension() == ".raw") {
writer = std::make_shared<Metavision::RAWEventFileWriter>(file_path);
} else if (ext == ".hdf5") {
} else if (path_obj.extension() == ".hdf5") {
writer = std::make_shared<Metavision::HDF5EventFileWriter>(file_path);
} else {
throw CameraException(CameraErrorCode::WrongExtension,
"Unsupported extension for the recording destination " + file_path + ".");
"Unsupported extension for the recording destination " + path_obj.string() + ".");
}
writer->add_metadata_map_from_camera(*pub_ptr_);
if (ext == ".raw") {
if (path_obj.extension() == ".raw") {
if (!raw_data_) {
throw CameraException(UnsupportedFeatureErrors::RawRecordingUnavailable,
"Cannot record to a RAW file from this type of camera.");
Expand Down Expand Up @@ -570,24 +570,25 @@ Camera Camera::from_serial(const std::string &serial, const DeviceConfig &config
}

Camera Camera::from_file(const std::string &file_path, const FileConfigHints &hints) {
if (boost::filesystem::extension(file_path) != "") {
if (!boost::filesystem::exists(file_path)) {
boost::filesystem::path path_obj(file_path);
if (path_obj.has_extension()) {
if (!boost::filesystem::exists(path_obj)) {
throw CameraException(CameraErrorCode::FileDoesNotExist,
"Opening file at " + file_path + ": not an existing file.");
"Opening file at " + path_obj.string() + ": not an existing file.");
}

if (!boost::filesystem::is_regular_file(file_path)) {
if (!boost::filesystem::is_regular_file(path_obj)) {
throw CameraException(CameraErrorCode::NotARegularFile);
}
}

if (boost::filesystem::extension(file_path) == ".raw") {
if (path_obj.extension() == ".raw") {
return Camera(new detail::OfflineRawPrivate(file_path, hints));
} else if (boost::filesystem::extension(file_path) == ".hdf5") {
} else if (path_obj.extension() == ".hdf5") {
#if defined HAS_HDF5
return Camera(new detail::OfflineGenericPrivate(file_path, hints));
#endif
} else if (boost::filesystem::extension(file_path) == ".dat" || boost::filesystem::extension(file_path) == "") {
} else if (path_obj.extension() == ".dat" || path_obj.extension() == "") {
return Camera(new detail::OfflineGenericPrivate(file_path, hints));
}

Expand Down
6 changes: 3 additions & 3 deletions sdk/modules/driver/cpp/src/camera_live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ bool LivePrivate::process_impl(TimingProfilerType *profiler) {
}

bool LivePrivate::start_recording_impl(const std::string &file_path) {
std::string base_path = boost::filesystem::change_extension(file_path, "").string();
boost::filesystem::path path_obj(file_path);
if (biases_) {
biases_->save_to_file(base_path + ".bias");
biases_->save_to_file(path_obj.filename().string() + ".bias");
}
return Camera::Private::start_recording_impl(file_path);
return Camera::Private::start_recording_impl(path_obj.filename().string());
}

void LivePrivate::save(std::ostream &os) const {
Expand Down
3 changes: 2 additions & 1 deletion sdk/modules/driver/cpp/src/camera_offline_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ OfflineGenericPrivate::OfflineGenericPrivate(const std::string &file_path, const
Private(detail::Config()) {
// clang-format off
try {
if (boost::filesystem::extension(file_path) == ".hdf5") {
boost::filesystem::path path_obj(file_path);
if (path_obj.extension() == ".hdf5") {
file_reader_ = std::make_unique<HDF5EventFileReader>(file_path, hints.time_shift());
} else {
file_reader_ = std::make_unique<DATEventFileReader>(file_path);
Expand Down
4 changes: 4 additions & 0 deletions sdk/modules/driver/cpp/src/camera_serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,11 @@ std::ostream &save_device(const Device &d, std::ostream &os) {

google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
#if (GOOGLE_PROTOBUF_VERSION >= 5026000)
options.always_print_fields_with_no_presence = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any documentation on this?
I don't see this field being part of the JsonPrintOptions:
https://protobuf.dev/reference/cpp/api-docs/google.protobuf.util.json_util/#JsonPrintOptions

I see the field mentionned here:
https://protobuf.dev/news/v26/#JSON
But it states that it is replacing always_print_default_values which is not the field we are using (always_print_primitive_fields)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In regards to this change, I faced two issues while trying to build on Mac.

  1. I couldn't easily come up with a package formula that allowed me to install a compatible version of Protobuf. If I can figure this out, I would remove the code changes and keep everything to < v26.
  2. Once I decided to keep the newer package version, replacing the deprecated function was not straightforward. The best clues I found were from looking at the blame for PrintOptions definition (protobuf/src/google/protobuf/json/json.h) in the latest release version. In particular, these two commits (2699579 and 7d43131 in the protobuf repo.

TBH, I didn't love making this change, since the Protobuf documentation around it wasn't the best IMO. However, I figured it'd start a discussion as how to best resolve. I didn't spend time trying to test the implications of the new struct field, BUT I did test that the version flag worked properly.

Again would love to make this change better. Perhaps just forcing a specific version of protobuf would be best? but that also doesn't seem ideal as time goes on (right?) Just thinking out loud (please don't read anything negative in my comments!)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay on this topic, it looks like you are right. I opened a issue on protobuf side so they would update the documentation:
protocolbuffers/protobuf#17437

So your change seems ok. However, the renaming of the field seems to have taken place in v26.0 of protobuf, so the version number to check should be 5026000

#else
options.always_print_primitive_fields = true;
#endif
options.preserve_proto_field_names = true;

std::string json;
Expand Down
21 changes: 15 additions & 6 deletions sdk/modules/ui/cpp/include/metavision/sdk/ui/utils/opengl_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,27 @@

#ifdef _USE_OPENGL_ES3_
#include <GLES3/gl3.h>
#elif defined(__APPLE__) && !defined(__linux__)
#define GL_SILENCE_DEPRECATION
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily an action request, but do you remember what is the deprecated thing we are using?

#include <OpenGL/gl3.h>
#else
#if defined(WIN32)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: #elif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe I can change the logic here. I would end up having to write a separate case for linux and including #include <GL/glew.h> and #include <GL/gl.h> in both logic branches for WIN32 and linux.

I was able to collapse the first #else to and #elif.

#include <Windows.h>
#endif
#include <GL/glew.h>
#include <GL/gl.h>
#endif

// GLFW needs to be included after OpenGL
#include <GLFW/glfw3.h>

// While we keep support for OpenGL, we need to provide a
// dummy implementation for Glew init function
#ifndef GLEW_OK
#define GLEW_OK 0
inline int glewInit(void) {
return GLEW_OK;
}
#else // OpenGL
#include <GL/glew.h>
#include <GL/gl.h>
#endif

// GLFW need to be included after OpenGL
#include <GLFW/glfw3.h>

#endif // METAVISION_SDK_UI_UTILS_OPENGL_API
Loading