Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added binary version of vocabulary to speedup ORB_SLAM2 start #21

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

poine
Copy link

@poine poine commented Feb 11, 2016

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

If you ever had weird results with this code for few observations, here is why...
@hashten
Copy link

hashten commented Sep 16, 2016

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!

Copy link

@hashten hashten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@poine
Copy link
Author

poine commented Sep 17, 2016

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 notifications@github.com
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
#21 (review),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGTzzNueT8k7M-DphLGWRcIImzEeADRks5qqr7DgaJpZM4HX6iC
.

@tdnet12434
Copy link

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.

@poine
Copy link
Author

poine commented Oct 6, 2016

@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 notifications@github.com
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
#21 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAGTz9s8EKTszJyXd5J30IN-Jes-NHWRks5qxSdCgaJpZM4HX6iC
.

@sunghoon031
Copy link

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

ahelou2 added a commit to ahelou2/slam-exp that referenced this pull request Dec 22, 2016
added binary version of vocabulary to speedup ORB_SLAM2 start
pancx pushed a commit to pancx/ORB_SLAM2 that referenced this pull request Nov 10, 2017
This method is from raulmur#21. But it hasn't been accepted and now the branch has conflicts. So I change the code manually.
Matchstic added a commit to Matchstic/ORB_SLAM2 that referenced this pull request Apr 5, 2018
@busybyte1
Copy link

busybyte1 commented Jun 19, 2018

added binary version of vocabulary to speedup ORB_SLAM2 start (4122702)

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)

@chenzhanjie
Copy link

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

@busybyte1
Copy link

busybyte1 commented Jul 3, 2018

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 (4122702) 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

PeterVanNostrand added a commit to PeterVanNostrand/ORB_SLAM2 that referenced this pull request Oct 3, 2018
Changelog:
 - Implemented binary ORB Vocabulary from ORBSLAM pull 21
   raulmur#21
 - Added load and save binary functions to TemplatedVocabulary.h
 - Added bin_vocabulary.cc which converts vocabulary to binary
 - Edited System.cc to use new binary load/save methods
 - Edited CMakeLists, build.sh, .gitnore to reflect changes in build
   files
 - ORBSLAM loading times have been significantly increased
 - Requires reubuild of all ORBSLAM code to implement
Copy link

@YumaTheCompanion YumaTheCompanion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked the file changes with the vanilla version of ORB_SLAM2 on:
Ubuntu 18.04,
CMAKE 3.10.2,
g++7.4.0.

The solution works as expected.

cgnerds added a commit to cgnerds/orbslam2-windows that referenced this pull request Oct 18, 2019
tshellum added a commit to tshellum/DBoW2 that referenced this pull request Apr 7, 2021
Dkaka pushed a commit to sjulier/Refactored_ORB_SLAM2 that referenced this pull request Jun 29, 2021
sgolodetz added a commit to sgolodetz/ORB_SLAM2 that referenced this pull request Aug 1, 2021
sgolodetz added a commit to sgolodetz/ORB_SLAM2 that referenced this pull request Aug 1, 2021
sgolodetz added a commit to sgolodetz/ORB_SLAM2 that referenced this pull request Aug 1, 2021
sjulier pushed a commit to sjulier/Refactored_ORB_SLAM2 that referenced this pull request Mar 13, 2022
@Fourierw
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants