Python bindings(and C++ code) for C++ implementation of ORB-Feature Extractor and ORB-Matcher, as implemented in ORB-SLAM2
cd orb_extractor
Set corresponding numpy path for numpy in CMakeLists.txt line 13
mkdir build
python3 gen2.py pyorb build headers.txt
cmake .
Go to build/pyorb_generated_include.h
. Change #include "src/ORB.hpp"
to #include "../src/ORB.hpp"
make .
Copy orb.so
to parent folder.
Please follow the same steps for orb_extractor.
Change python3 gen2.py pyorb build headers.txt
to python3 gen2.py pyorb_matcher build headers.txt
Copy orb_matcher.so
to parent folder.
import orb
import orb_matcher
OE = orb.orb_ORBextractor(2048,1.2,8,20,5)
kps,desc = OE.extract_orb_fts(im, None)
EM = orb_matcher.orb_matcher_ORBmatcher(float_val)
no_of_matches,matches = EM.find_matches(kp1,kp2,desc1,desc2,windowsize)
Example runner.cpp code.
cmake .
make
./Example
The C++ code has mostly been borrowed from ORB-SLAM2, in specific the ORBextractor.cc and ORBmatcher.cc with a few tiny changes (removed the concept of frames).
The code to create python bindings is from learnopencv.com. The g++
compilation code has been written equivalently in cmake. (to the best of my knowledge).
- This is a novice implementation, and can certainly be improved massively.
- For some reason, the orb_matcher object has to be created everytime we wish to find matches. It gives wrong results otherwise. Need to investigate.
- Will try to combine the two into a single module, which will be certainly easier to handle.
- I'm not sure how to return
cv::keypoints
directly to Python, hence currently they're being converted tocv::Mat
and returned asnp array
.