Python bindings for OpenVSLAM, an ORB based visual SLAM similar to ORB-SLAM2.
By compiling the provided cpp file, you get the module openvslam that let you control openvslam'system from Python. OpenVSlam must be already installed in your system. You'll be able to run openvslam, load & save maps, feed images and get the pose matrix.
Right now no bindings for viewers are provided, so do not expect to see the 3D map nor the features over the image.
These bindings should work with the original OpenVSLAM, OpenVSLAM community fork and Stella-vslam until version 0.21 March 21. Stella-vslam version 0.22 changed the API rendering these bindings unusable. Proper bindings for that version and on are provided at Stella-vslam Python bindings repo.
In order to get a openvslam module you can import from Python, you need to:
This is an example of command line compilation in Linux:
/usr/bin/g++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) -I/usr/local/include/openvslam/3rd/json/include -DUSE_DBOW2 /home/user/OpenVSLAM-Python-bindings/openvslam_bindings.cpp -o openvslam$(python3-config --extension-suffix) -lopenvslam
In this command line you can remove -DUSE_DBOW2 if you don't want to use DBoW2, and use fbow instead.
The result is a module in a form of a shared library, like
openvslam.cpython-38-x86_64-linux-gnu.so
You can import this module in your Python code simply like
import openvslam
provided the module file is reachable, for example being in the working directory.
In order to run openvslam you always need a configuration file and a vocabulary file. You can get the vocabulary orb_vocab.dbow2 file from openvslam.
Two tests are available in Python.
test1.py is a minimal proof of operation, it starts and shuts down openvslam. A random config.yaml file is provided in this project to facilitate this test. Don't rest until you get this test running without errors.
test2.py is a more complete demo, inspired in run_video_slam example. You'll need a video with the right config.yaml. You can download them from the datasets openvslam made public. Here are the direct links:
Each zip contains a video and the appropiate config.yaml.
openvslam module contains two clases: config and system. The former is only used to pass config.yaml to system initialization. You do all the work with a system object.
At the end of openvslam_binding.cpp you'll find the list of bound functions accessible from Python. Tests serve as example of use.
3-clause BSD license (see LICENSE)
This project uses code from the following third party libraries:
- NDArrayConverter from edmBernard/pybind11_opencv_numpy, Apache License 2.0
- NDArrayConverter uses code from OpenCV 3.1.0, 3-clause BSD license
- NDArrayConverter is based on the work of yati-sagade/opencv-ndarray-conversion, MIT license
Many thanks to Jack Cai whose non appropiable code inspired this project.
All help is welcome to facilitate installation with cmake. From cmakelists.txt to the documentation with examples of use. We can communicate through Dicussions.