This project processes event-based camera data using contrast maximization optimization. The file reader is a modified version of the sample given in the Metavision SDK that decodes raw event data into arrays rather than CSV format.
This implementation is based on the contrast maximization framework described in:
Gallego, G., Rebecq, H., & Scaramuzza, D. (2018). A Unifying Contrast Maximization Framework for Event Cameras, with Applications to Motion, Depth, and Optical Flow Estimation. IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Salt Lake City, 2018. arXiv:1804.01306
The following libraries are required:
- Eigen 3.4 - Matrix operations
- OptimLib (Header-only, Eigen-based) - Optimization library
- nlohmann/json - JSON parsing
git clone https://github.com/nlohmann/json.git
cd json
cmake -B build -DCMAKE_INSTALL_PREFIX=/usr/local -DJSON_BuildTests=OFF
cmake --build build --target installEigen3 can typically be installed via your system's package manager:
macOS (Homebrew):
brew install eigenLinux (apt):
sudo apt-get install libeigen3-devLinux (yum):
sudo yum install eigen3-develIf you prefer to install dependencies locally:
-
Create a
packagesfolder in the project root:mkdir packages
-
For nlohmann/json:
cd packages git clone https://github.com/nlohmann/json.git cd json cmake -B build -DJSON_BuildTests=OFF cmake --build build cd ../..
-
For Eigen:
cd packages # Download and extract Eigen 3.4.0 wget https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz tar -xzf eigen-3.4.0.tar.gz cd ..
-
When building, specify the package path:
cmake -B build -DPACKAGE_PATH=$(pwd)/packages
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .The executable will be created at build/main.
If you installed dependencies locally in a packages folder:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DPACKAGE_PATH=../packages
cmake --build .You can use the provided build.bat script, or manually:
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .Before running the program, create a config.json file in the project root (you can copy config.example.json as a template):
{
"filepath": "../data/data.raw",
"blur": true,
"sliding_window": true,
"timeslice": 1000,
"generate_images": true
}filepath: Path to the raw event camera data file (.raw format)blur: Enable/disable Gaussian blur during optimization (true/false)sliding_window: Enable sliding window processing (true/false)timeslice: Time window size in microseconds for each optimization slicegenerate_images: Generate warped and previous images (true/false)
-
Prepare your configuration file:
cp config.example.json config.json # Edit config.json with your settings -
Run the program:
cd build ./mainOr from the build directory:
./build/main
-
Output:
- The program will display progress and optimization results
- If
generate_imagesis enabled, PGM images will be saved aswarped0.pgm,warped1.pgm, etc., andprev0.pgm,prev1.pgm, etc. - Event data files (
normal.txtandwarped.txt) will also be generated
src/main.cpp- Main entry pointlib/- Core libraries:filereader.cpp/hpp- Event data file readingcontrastmax.cpp/hpp- Contrast maximization optimizationoptim/- Optimization library (header-only)
data/- Sample event camera data filesbuild/- Build output directory (created during build)
- The program processes event camera data by maximizing contrast through spatial warping
- Multiple optimization algorithms are available (with/without Gaussian blur)
- Processing can be done on the entire dataset or using sliding windows for temporal analysis
Gallego, G., Rebecq, H., & Scaramuzza, D. (2018). A Unifying Contrast Maximization Framework for Event Cameras, with Applications to Motion, Depth, and Optical Flow Estimation. IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Salt Lake City, 2018. arXiv:1804.01306 | DOI: 10.1109/CVPR.2018.00407