Skip to content

Commit

Permalink
Merge pull request #1 from nathanhhughes/fix/opencv4_patch
Browse files Browse the repository at this point in the history
fix issue with vocab loading taking to long with system opencv
  • Loading branch information
marcusabate authored Feb 22, 2023
2 parents 5dfc0f3 + 326380b commit 210b907
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
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];

0 comments on commit 210b907

Please sign in to comment.