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

fix issue with vocab loading taking to long with system opencv #1

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ExternalProject_Add(dbow2_src
GIT_REPOSITORY https://github.com/dorian3d/DBoW2.git
GIT_TAG master
UPDATE_COMMAND ""
#PATCH_COMMAND ""
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_LIST_DIR}/fix_fs_iter.patch
CONFIGURE_COMMAND cd ../dbow2_src && cmake -DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX:PATH=${CATKIN_DEVEL_PREFIX}
-DBUILD_Demo=Off .
Expand Down
36 changes: 36 additions & 0 deletions fix_fs_iter.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/include/DBoW2/TemplatedVocabulary.h b/include/DBoW2/TemplatedVocabulary.h
index 6d8d621..c95e72e 100644
--- a/include/DBoW2/TemplatedVocabulary.h
+++ b/include/DBoW2/TemplatedVocabulary.h
@@ -1473,12 +1473,12 @@ void TemplatedVocabulary<TDescriptor,F>::load(const cv::FileStorage &fs,
m_nodes.resize(fn.size() + 1); // +1 to include root
m_nodes[0].id = 0;

- for(unsigned int i = 0; i < fn.size(); ++i)
+ for(auto iter = fn.begin(); iter != fn.end(); ++iter)
{
- NodeId nid = (int)fn[i]["nodeId"];
- NodeId pid = (int)fn[i]["parentId"];
- WordValue weight = (WordValue)fn[i]["weight"];
- std::string d = (std::string)fn[i]["descriptor"];
+ NodeId nid = (int)(*iter)["nodeId"];
+ NodeId pid = (int)(*iter)["parentId"];
+ WordValue weight = (WordValue)(*iter)["weight"];
+ std::string d = (std::string)(*iter)["descriptor"];

m_nodes[nid].id = nid;
m_nodes[nid].parent = pid;
@@ -1493,10 +1493,10 @@ void TemplatedVocabulary<TDescriptor,F>::load(const cv::FileStorage &fs,

m_words.resize(fn.size());

- for(unsigned int i = 0; i < fn.size(); ++i)
+ for(auto iter = fn.begin(); iter != fn.end(); ++iter)
{
- NodeId wid = (int)fn[i]["wordId"];
- NodeId nid = (int)fn[i]["nodeId"];
+ NodeId wid = (int)(*iter)["wordId"];
+ NodeId nid = (int)(*iter)["nodeId"];

m_nodes[nid].word_id = wid;
m_words[wid] = &m_nodes[nid];