Installation (CPP)

  • Requirements

  • Compilation

  • Test

  • How to link in C++ projects

Requirements

  • C++14 or later compiler

  • GCC 7.5+

  • CMake 3.15+

  • LAPACK & BLAS

    1. If using conda, conda install -c conda-forge lapack

    2. If sudo is available, apt update & apt -y install libatlas-base-dev

Optional:

  • Conan (for using pre-built 3rd-party libraries)

    # 0. install conan
    pip install conan
    
    # 1. first run
    conan profile new --detect --force default
    conan profile update settings.compiler.libcxx=libstdc++11 default
    
    # 2. add conan artifactory
    conan remote add openxrlab http://conan.openxrlab.org.cn/artifactory/api/conan/openxrlab
    
    # 3. check
    conan remote list
    

Compilation

git clone https://github.com/openxrlab/xrprimer.git
cd xrprimer/

cmake -S. -Bbuild [Compilation options]
cmake --build build --target install -j4

It is currently tested on Linux and iOS. Ideally it can be also compiled on macOS or Windows.

Compilation options

  • ENABLE_TEST Enable unit test. default: OFF

  • PYTHON_BINDING Enable Python binding. default: ON

  • BUILD_EXTERNAL Enable build external. default: OFF, download deps libraries from conan.

# build external from source
cmake -S. -Bbuild -DBUILD_EXTERNAL=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install
cmake --build build --target install

# use conan for external
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release
cmake --build build --target install

Compilation on iOS

Refer to build_ios.sh for more details.

Test

CPP library

# compile (Skip the following two lines if it has been compiled)
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DENABLE_TEST=ON
cmake --build build -j4

# run test
cd build
wget -q https://openxrlab-share-mainland.oss-cn-hangzhou.aliyuncs.com/xrprimer/xrprimer.tar.gz && tar -xzf xrprimer.tar.gz && rm xrprimer.tar.gz
ln -sfn xrprimer/test test
./bin/test_calibrator

Python library

# compile (Skip the following two lines if it has been compiled)
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DENABLE_TEST=ON
cmake --build build -j4

# run test
cd build
wget -q https://openxrlab-share-mainland.oss-cn-hangzhou.aliyuncs.com/xrprimer/xrprimer.tar.gz && tar -xzf xrprimer.tar.gz && rm xrprimer.tar.gz
PYTHONPATH=./lib/ python ../cpp/tests/test_multi_camera_calibrator.py