Skip to content

Latest commit

 

History

History
100 lines (74 loc) · 2.9 KB

README.md

File metadata and controls

100 lines (74 loc) · 2.9 KB

Python Bundle Adjustment

Conda envorinment

Use the ESFM environment.

conda activate ESFM
export PYBIND11_PYTHON_VERSION="3.8"
export PYTHON_VERSION="3.8"

Folders

After set up, the order of the folders would be:

Equivariant-SFM
├── bundle_adjustment
│   ├── ceres-solver
│   │   ├── ceres-bin
│   │   |   └── lib
│   │   |       └── PyCeres.cpython-38-x86_64-linux-gnu.so
│   │   ├── ceres_python_bindings
│   │   |   └── python_bindings
│   │   |       └── custom_cpp_cost_functions.cpp
│   │   └── CMakeLists.txt
│   └── custom_cpp_cost_functions.cpp
├── code
├── datasets
├── results

Set up

  1. Download the Ceres-Solver package to the bundle_adjustment folder:
cd bundle_adjustment
git clone https://ceres-solver.googlesource.com/ceres-solver
  1. Clone the ceres_python_bindings package inside the ceres-solver folder:
cd ceres-solver
git clone https://github.com/Edwinem/ceres_python_bindings
  1. Copy the file "custom_cpp_cost_functions.cpp" and replace the file "ceres-solver/ceres_python_bindings/python_bindings/custom_cpp_cost_functions.cpp". This file contains our projective and euclidean custom bundle adjustment functions.
cp ../custom_cpp_cost_functions.cpp ceres_python_bindings/python_bindings/custom_cpp_cost_functions.cpp

Next, you need to build ceres_python_bindings and ceres-solver and create a shared object file that python can call. You can either continue with the instructions here or follow the instructions at the ceres_python_bindings repository.

  1. run:
cd ceres_python_bindings
git submodule init
git submodule update
  1. Add to the end of the file ceres-solver/CMakeLists.txt the line: "include(ceres_python_bindings/AddToCeres.cmake)":
cd ..
echo "include(ceres_python_bindings/AddToCeres.cmake)" >> CMakeLists.txt
  1. Inside ceres-solver folder run:
mkdir ceres-bin
cd ceres-bin
cmake ..
make -j8
make test
  1. If everything worked you should see the following file:
bundle_adjustment/ceres-solver/ceres-bin/lib/PyCeres.cpython-38-x86_64-linux-gnu.so
  1. If you want to use this bundle adjustment implementation for a different project make sure to add the path of the shared object to linux PATH (in our code this is done for you). In the python project this would be for example:
import sys
sys.path.append('../bundle_adjustment/ceres-solver/ceres-bin/lib/PyCeres.cpython-38-x86_64-linux-gnu.so')
import PyCeres

To see the usage of the PyCeres functions go to code/utils/ceres_utils and code/utils/ba_functions.