ORB_SLAM2 icon indicating copy to clipboard operation
ORB_SLAM2 copied to clipboard

added binary version of vocabulary to speedup ORB_SLAM2 start

Open poine opened this issue 9 years ago • 10 comments

I am a noob at both C++ and git, so please be forgiving.

This is a patch to speedup ORB-SLAM2 startup by loading the vocabulary from a binary file instead of ascii.

I tested it on linux on an intel I7 and an arm Exynos5422 (odroid xu4) ascii | binary I7 12.06s | 0.2s arm 77s | 1s

(ORB_SLAM2 was just not usable on the arm with a startup duration of 77s)

I added a line to build.sh to convert Vocabulary/ORBvoc.txt to Vocabulary/ORBvoc.bin

ORB_SLAM2 uses file extension to choose between ascii and binary.

Test with ./Examples/Monocular/mono_tum Vocabulary/ORBvoc.bin Examples/Monocular/TUM1.yaml /data/tum/rgbd_dataset_freiburg1_xyz/ versus ./Examples/Monocular/mono_tum Vocabulary/ORBvoc.txt Examples/Monocular/TUM1.yaml /data/tum/rgbd_dataset_freiburg1_xyz/

Regards

Poine

poine avatar Feb 11 '16 05:02 poine

This works extremely nice straight out of the box! From a loading time of 20.8 sec to 0.48 sec on my 5 year old really slow AMD A6-3410MX. Thanks a bunch, makes testing much more fun!

hashten avatar Sep 16 '16 15:09 hashten

You're very welcome. You make the that time i spend preparing the patch worth.

On Fri, Sep 16, 2016 at 6:07 PM, Joel Harsten [email protected] wrote:

@hashten approved this pull request.

Works straight away and changed loading time from 20 sec to 0.5 sec!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/raulmur/ORB_SLAM2/pull/21#pullrequestreview-381664, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGTzzNueT8k7M-DphLGWRcIImzEeADRks5qqr7DgaJpZM4HX6iC .

poine avatar Sep 17 '16 07:09 poine

Hi @poine , Thx u for your patch, this can save a lot of time for doing my thesis!! I wanna ask a question. How smooth that ORB_SLAM2 running on odroid XU4? I think i will buy one but i not sure about its max frame rate handling.

tdnet12434 avatar Oct 06 '16 16:10 tdnet12434

@Thanabadee Blsc

It is difficult to answer your question. Framerate depends on the resolution of your video, the number of extracted features and so on. But all in all, i don't think you'll get a great framerate with an XU4 (like maybe a few fps).

If you are concerned about miniaturization and power consumption, i would advise to take a look at nvidia tegra based boards as you might be able to take profit of the cuda cores. Parrot has recently released a tegra based dev board that look very nice: https://corporate.parrot.com/en/pressrelease/parrots.l.a.m.dunkturnadroneintoasmartrobot

If power consumption is not critical to your application, i would suggest to make your life easier and use the fastest intel processor you can afford. This is the path i am following. This was my first robot, with the XU4: https://goo.gl/photos/WhxoUfWTV6JWFAtn8 This is my current robot: https://goo.gl/photos/17ptWpjAzf2B6gfK7 I am just using an I7 powered laptop on it. I do not regret switching to the larger robot, which by the way, was not that much more expensive than the small one (it's an old electric wheelchair). I would call my first experiment with the small robot premature optimization.

Hth

Poine

On Thu, Oct 6, 2016 at 6:52 PM, Thanabadee Blsc [email protected] wrote:

Hi @poine https://github.com/poine , Thx u for your patch, this can save a lot of time for doing my thesis!! I wanna ask a question. How smooth that ORB_SLAM2 running on odroid XU4? I think i will buy one but i not sure about its max frame rate handling.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/raulmur/ORB_SLAM2/pull/21#issuecomment-252022685, or mute the thread https://github.com/notifications/unsubscribe-auth/AAGTz9s8EKTszJyXd5J30IN-Jes-NHWRks5qxSdCgaJpZM4HX6iC .

poine avatar Oct 06 '16 17:10 poine

@poine Did you try with localization-only mode on XU4? Or was it with mapping + loop-closing?

sunghoon031 avatar Oct 21 '16 01:10 sunghoon031

added binary version of vocabulary to speedup ORB_SLAM2 start (https://github.com/raulmur/ORB_SLAM2/pull/21/commits/4122702ced85b20bd458d0e74624b9610c19f8cc)

For Windows 8.1, Visual Studio 2017 : Compiler-Error like: Not interpreted as constant

Thirdparty/DBoW2/DBoW2/TemplatedVocabulary.h Line 1484: -char buf[size_node]; +char *buf = new char[size_node];

rest works perfect, many thanks ! (0.45sec to load ORBvoc.bin)

busybyte1 avatar Jun 19 '18 22:06 busybyte1

i am a new, i do not know how to convert, the line which your added is what, thank you.

chenzhanjie avatar Jul 03 '18 03:07 chenzhanjie

i'm not an expert but if you managed to get orb to work you should know what i write about next, otherwise it's useless.

  1. open dbow.sln project, which you should have build with cmake, with VisualStudio .
  2. in your project-explorer go to external dependencies and open TemplateVocabulary.h.
  3. change the lines like in (https://github.com/raulmur/ORB_SLAM2/commit/4122702ced85b20bd458d0e74624b9610c19f8cc) and recompile (if not possible you may have to rebuild dbow with cmake and do it again). recompile always both, debug and release version.
  4. almost the same do for your orb-slam2 project (not the examples), wich should be build with cmake, for system.cc and bin_vocabulary.cc (search the files in your project-explorer)
  5. read the new code to change intensive, theres a function called "save_as_binary". with this function you can save the vocabulary as bin, so you have to implement it somehow in your tum-project.
  6. load the voc.txt and save as .bin (watch the path where it's saved, maybe you have to search it i.e. in your tum-project-folder and copy it to the path from the .txt version)
  7. change the voc-filename in your mono/rgbd/stereo_tum from .txt to .bin and load it as .bin

hope i could help you

busybyte1 avatar Jul 03 '18 07:07 busybyte1

After adding the code I completely rebuilt the 'ORB_SLAM2' project , yet the ORBvoc.bin was nowhere to find. Then I debugged the 'bin_vocabulary' project , it said "Vocabulary loading failure: This is not a correct text file!" , how can I solve this to get the binary file of ORBvoc ? (when I run the mono_tum project , the ORB.txt file can be read correctly and the entire program was fine)

Fourierw avatar Jun 25 '23 03:06 Fourierw

Disclaimer: I don't intend to create spam. If the ORB_SLAM2 developers wish me to stop posting, I will cease immediately.

ORB_SLAM2 seems to be inactive, but there are a number of community patches, including yours, which provide important bugfixes or improvements. Therefore I have created a new project ORB_SLAM_COMMUNITY (https://github.com/jeremysalwen/ORB_SLAM_COMMUNITY) to gather together these improvements and continue active development. I have already merged this PR in the ORB_SLAM_COMMUNITY version. We would welcome any other contributions you might have.

jeremysalwen avatar Jul 26 '24 00:07 jeremysalwen