Skip to content

Commit

Permalink
Alpha test before public (#4)
Browse files Browse the repository at this point in the history
* add python test in workflow and git clone in dockerfile (#1)

* Revise docs (#2)

* feat: add code coverage

* Add build_cpp in CI (#3)

* Revise email and url

* add python test in workflow and git clone in dockerfile (#1)

* Revise build_cpp

* feat(test):add catch2 support

* Use manylinux ci image for deployment

* Add major features

* python/test -> python/tests

* Update conan remote url

* Bump version to v0.6.0

Co-authored-by: LazyBusyYang <gaoyang_cn@outlook.com>
Co-authored-by: GaoYang <gaoyang3@sensetime.com>
Co-authored-by: GACLove <peng.gaoc@gmail.com>
  • Loading branch information
4 people authored Sep 1, 2022
1 parent 73dd259 commit 609261d
Show file tree
Hide file tree
Showing 47 changed files with 18,524 additions and 278 deletions.
107 changes: 74 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,56 +23,97 @@ concurrency:
cancel-in-progress: true

jobs:
build_cuda101:
build_cpp:
runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.7]
torch: [1.7.0, 1.8.0]
include:
- torch: 1.7.0
torchvision: 0.8.1
- torch: 1.8.0
torchvision: 0.9.0
defaults:
run:
shell: bash -l {0}

container:
image: openxrlab/xrprimer_runtime:ubuntu1804_x64_gcc7_py38_torch181_mmcv150
credentials:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_PWD}}
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: xrprimer_env
python-version: ${{matrix.python-version}}
auto-activate-base: false
- name: Prepare test data
- name: Show conda env
run: |
# TODO: prepare test data or remove this step
- name: Upgrade pip
run: pip install pip --upgrade
- name: Install ffmpeg
source /root/miniconda3/etc/profile.d/conda.sh && conda deactivate
conda info -e
conda activate openxrlab
conda list | grep -e torch -e mmcv
- name: Build and install
run: |
conda install ffmpeg
ffmpeg -version
- name: Install PyTorch
rm -rf xrprimer.egg-info
source /root/miniconda3/etc/profile.d/conda.sh && conda activate openxrlab
pip install conan
conan remote add openxrlab http://conan.openxrlab.org.cn/artifactory/api/conan/openxrlab
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DBUILD_EXTERNAL=ON -DENABLE_TEST=ON -DCODE_COVERAGE=ON
cmake --build build -j4 --target install
- name: Prepare test data
run: |
conda install pytorch==${{matrix.torch}} torchvision==${{matrix.torchvision}} cudatoolkit=10.1 -c pytorch
- name: Install MMCV
cd build
wget -q https://openxrlab-share.oss-cn-hongkong.aliyuncs.com/xrprimer/xrprimer.tar.gz
tar -xzf xrprimer.tar.gz && rm xrprimer.tar.gz
ln -sfn xrprimer/test test
- name: Run unittests and generate coverage report
run: |
source /root/miniconda3/etc/profile.d/conda.sh && conda activate openxrlab
cd build
./bin/test_calibrator
./bin/test_image
./bin/test_version
./bin/test_pose
./bin/test_camera
PYTHONPATH=./lib python ../cpp/tests/test_multi_camera_calibrator.py
PYTHONPATH=./lib python ../cpp/tests/test_pnpsolver.py
# pip install gcovr
# mkdir coverage_html
# coverage_filter="--filter ${CI_PROJECT_DIR}/cpp"
# gcovr ${coverage_filter} -r . --object-directory=${CI_PROJECT_DIR}/build
build_py38:
runs-on: ubuntu-18.04
defaults:
run:
shell: bash -l {0}
container:
image: openxrlab/xrprimer_runtime:ubuntu1804_x64_gcc7_py38_torch181_mmcv150
credentials:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_PWD}}
steps:
- uses: actions/checkout@v2
- name: Show conda env
run: |
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch${{matrix.torch}}/index.html
python -c 'import mmcv; print(mmcv.__version__)'
- name: Install other dependencies
run: pip install -r requirements.txt
source /root/miniconda3/etc/profile.d/conda.sh && conda deactivate
conda info -e
conda activate openxrlab
conda list | grep -e torch -e mmcv
- name: Build and install
run: rm -rf .eggs && pip install -e .
run: |
rm -rf xrprimer.egg-info
source /root/miniconda3/etc/profile.d/conda.sh && conda activate openxrlab
pip install conan
conan remote add openxrlab http://conan.openxrlab.org.cn/artifactory/api/conan/openxrlab
pip install -e .
- name: Prepare test data
run: |
cd python/tests
wget -q https://openxrlab-share.oss-cn-hongkong.aliyuncs.com/xrprimer/xrprimer.tar.gz
tar -xzf xrprimer.tar.gz && rm xrprimer.tar.gz
mv xrprimer/test/data ./
rm -rf xrprimer && cd ..
- name: Run unittests and generate coverage report
run: |
coverage run --source xrprimer -m pytest tests/
source /root/miniconda3/etc/profile.d/conda.sh && conda activate openxrlab
coverage run --source xrprimer -m pytest python/tests/
coverage xml
coverage report -m
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
- name: Check docstring coverage
run: |
pip install interrogate
interrogate -vinmMI --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" -f 60 xrprimer/
interrogate -vinmMI --ignore-init-method --ignore-module --ignore-nested-functions --ignore-regex "__repr__" -f 60 python/xrprimer/
18 changes: 13 additions & 5 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,27 @@ on: push

jobs:
build-n-publish:
runs-on: ubuntu-latest
runs-on: ubuntu-18.04
if: startsWith(github.event.ref, 'refs/tags')
container:
image: openxrlab/xrprimer_ci:manylinux2014_x86_64_torch180_mmcv150
credentials:
username: ${{secrets.DOCKERHUB_USERNAME}}
password: ${{secrets.DOCKERHUB_PWD}}
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, 3.10]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: ${{ matrix.python-version }}
- name: Build XRPrimer
run: |
pip install wheel
python setup.py sdist bdist_wheel
- name: Publish distribution to PyPI
run: |
pip install twine
twine upload dist/* -u __token__ -p ${{ secrets.pypi_password }}
twine upload dist/* -u __token__ -p ${{ secrets.PYPI_PASSWORD }}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exclude: .*/test/data/|.clang-format
exclude: .*/test/data/|.clang-format|(tests/catch.hpp)
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.1
Expand Down
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ get_revison_from_vcs(${CMAKE_SOURCE_DIR} GIT_REV)
# meta info
#
set(META_PROJECT_NAME "xrprimer")
set(META_PROJECT_DESCRIPTION "OpenXRLab base library")
set(META_PROJECT_DESCRIPTION "OpenXRLab foundational library")
set(META_AUTHOR_ORGANIZATION "OpenXRLab")
set(META_AUTHOR_DOMAIN "OpenXRLab")
set(META_AUTHOR_MAINTAINER "openxrlab@sensetime.com")
set(META_AUTHOR_MAINTAINER "openxrlab@pjlab.org.cn")

#
# parse version number
Expand Down Expand Up @@ -69,7 +69,7 @@ else()

conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE ${CMAKE_SOURCE_DIR}
REMOTE xrlab
REMOTE openxrlab
SETTINGS ${settings})
conan_load_buildinfo()

Expand All @@ -81,7 +81,6 @@ else()
set(spdlog_DIR "${CONAN_SPDLOG_ROOT}/lib/cmake/spdlog")
set(GTest_DIR "${CONAN_GTEST_ROOT}/lib/cmake/GTest")
set(PnpSolver_DIR "${CONAN_PNPSOLVER_ROOT}/lib/cmake")

find_package(Eigen3 REQUIRED CONFIG)
find_package(Ceres REQUIRED CONFIG)
find_package(OpenCV REQUIRED CONFIG)
Expand All @@ -100,6 +99,9 @@ endif()
option(BUILD_SHARED_LIBS "Build shared instead of static libraries." OFF)
option(ENABLE_TEST "Build unit test case." OFF)
option(PYTHON_BINDING "Enable Python binding." ON)
option(CODE_COVERAGE "code coverage" OFF)

include(${CMAKE_SOURCE_DIR}/cmake/code-coverage.cmake)

#
# Set policies
Expand Down
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ RUN . /root/miniconda3/etc/profile.d/conda.sh && \
pip install torch==1.8.1 torchvision==0.9.1 -i https://pypi.tuna.tsinghua.edu.cn/simple && \
pip install mmcv==1.5.0 && \
pip install conan && \
conan remote add xrlab \
http://conan.kestrel.sensetime.com/artifactory/api/conan/xrlab && \
conan remote add openxrlab \
http://conan.openxrlab.org.cn/artifactory/api/conan/openxrlab && \
pip cache purge

# Clone xrprimer and install
RUN . /root/miniconda3/etc/profile.d/conda.sh && \
conda activate openxrlab && \
mkdir /workspace && cd /workspace && \
git clone https://github.com/openxrlab/xrprimer.git && \
cd xrprimer && pip install -e . && \
pip cache purge
109 changes: 105 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,118 @@
# XRPrimer

<div align="left">

[![actions](https://github.com/openxrlab/xrprimer/workflows/build/badge.svg)](https://github.com/openxrlab/xrprimer/actions)
[![codecov](https://codecov.io/gh/openxrlab/xrprimer/branch/main/graph/badge.svg)](https://codecov.io/gh/openxrlab/xrprimer)
[![PyPI](https://img.shields.io/pypi/v/xrprimer)](https://pypi.org/project/xrprimer/)
[![LICENSE](https://img.shields.io/github/license/openxrlab/xrprimer.svg)](https://github.com/openxrlab/xrprimer/blob/main/LICENSE)

</div>

## Introduction

English | [简体中文](README_CN.md)

XRPrimer is a fundational library for XR-related algorithms.
The XRPrimer provides reusable data structures, efficient operaters and extensible interfaces both in C++ and Python.

### Major Features

## Getting Started
- [x] Various camera models and conversion tools (Pinhole, Fisheye, Omni etc.)
- [x] Basic 3D operations (Triangulation, Projection etc.)
- [x] Multi-camera extrinsic calibration tools
- [ ] Rendering and visualization tools

### C++
### Operation Systems

Please see [C++ README](cpp/README.md) for the C++ usage
It currently supports the following systems.

- Linux
- iOS

## Installation

### Python

Please see [Python README](python/README.md) for the Python usage
If using xrprimer in a Python project, it can be installed by:

```bash
pip install xrprimer
```

If you want to use the latest updates of xrprimer, please refer to [Python Installation](docs/en/installation/python.md) for detailed installation.

### C++

If using xrprimer in a C++ project, please refer to [C++ Installation](docs/en/installation/cpp.md) for compilation and test.


## Getting started

### Use XRPrimer in Python projects

The below code is supposed to run successfully upon you finish the installation.

```bash
python -c "import xrprimer; print(xrprimer.__version__)"
```

### Use XRPrimer in C++ projects

An example is given below to show how to link xrprimer in C++ projects. More details can be found [here](docs/en/installation/cpp.md#how-to-link-in-c-projects).

```js
cmake_minimum_required(VERSION 3.16)

project(sample)

# set path for find XRPrimer package (config mode)
set(XRPrimer_DIR "<package_path>/lib/cmake")
find_package(XRPrimer REQUIRED)

add_executable(sample sample.cpp)

target_link_libraries(sample XRPrimer::xrprimer)
```

## FAQ

If you face some installation issues, you may first refer to this [Frequently Asked Questions](docs/en/faq.md).


## License

This project is released under the [Apache 2.0 license](LICENSE).

## Citation

If you find this project useful in your research, please consider cite:

```bibtex
@misc{xrprimer,
title={OpenXRLab Foundational Library for XR-related Algorithms},
author={XRPrimer Contributors},
howpublished = {\url{https://github.com/openxrlab/xrprimer}},
year={2022}
}
```

## Contributing

We appreciate all contributions to improve XRPrimer. Please refer to [CONTRIBUTING.md](.github/CONTRIBUTING.md) for the contributing guideline.

## Acknowledgement

XRPrimer is an open source project that is contributed by researchers and engineers from both the academia and the industry.
We appreciate all the contributors who implement their methods or add new features, as well as users who give valuable feedbacks.
We wish that the toolbox and benchmark could serve the growing research community by providing a flexible toolkit to reimplement existing methods and develop their own new models.

## Projects in OpenXRLab

- [XRPrimer](https://github.com/openxrlab/xrprimer): OpenXRLab foundational library for XR-related algorithms.
- [XRSLAM](https://github.com/openxrlab/xrslam): OpenXRLab Visual-inertial SLAM Toolbox and Benchmark.
- [XRSfM](https://github.com/openxrlab/xrsfm): OpenXRLab Structure-from-Motion Toolbox and Benchmark.
- [XRLocalization](https://github.com/openxrlab/xrlocalization): OpenXRLab Visual Localization Toolbox and Server.
- [XRMoCap](https://github.com/openxrlab/xrmocap): OpenXRLab Multi-view Motion Capture Toolbox and Benchmark.
- [XRMoGen](https://github.com/openxrlab/xrmogen): OpenXRLab Human Motion Generation Toolbox and Benchmark.
- [XRNeRF](https://github.com/openxrlab/xrnerf): OpenXRLab Neural Radiance Field (NeRF) Toolbox and Benchmark.
26 changes: 26 additions & 0 deletions cmake/code-coverage.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
if(CODE_COVERAGE)
if(CMAKE_BUILD_TYPE)
string(TOUPPER ${CMAKE_BUILD_TYPE} upper_build_type)
if(NOT ${upper_build_type} STREQUAL "DEBUG")
message(
STATUS
"**WARNING** Code coverage need CMAKE_BUILD_TYPE=Debug, FORCE use Debug"
)
endif()
endif()

set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)

if((CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
AND
(CMAKE_C_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
set(_GCOV_FLAGS "-fprofile-instr-generate -fcoverage-mapping")
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(_GCOV_FLAGS "-fprofile-arcs -ftest-coverage")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${_GCOV_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${_GCOV_FLAGS}")
endif()
8 changes: 8 additions & 0 deletions cmake/unit_test_dep.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,11 @@ function(xr_add_test target)
endif()
set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endfunction()

function(xr_add_test_catch2 target)
set(options)
set(multiValueArgs LINKS SRCS)
cmake_parse_arguments(_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
add_executable(${target} ${_TEST_SRCS})
set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endfunction()
Loading

0 comments on commit 609261d

Please sign in to comment.