slambook2(ch11)—— Ubuntu18.04安装DBoW3 + 例程演示

一、安装DBoW3

git clone https://github.com/rmsalinas/DBow3
mkdir build
cd build
cmake ..
make -j4
sudo make install

二、例程演示

1.报错: *** 没有规则可制作目标“/usr/local/lib/libDBoW3.a”,由“gen_vocab” 需求。 停止。

$ make
Scanning dependencies of target gen_vocab
[ 16%] Building CXX object CMakeFiles/gen_vocab.dir/gen_vocab_large.cpp.o
make[2]: *** 没有规则可制作目标“/usr/local/lib/libDBoW3.a”,由“gen_vocab” 需求。 停止。
CMakeFiles/Makefile2:98: recipe for target 'CMakeFiles/gen_vocab.dir/all' failed
make[1]: *** [CMakeFiles/gen_vocab.dir/all] Error 2
Makefile:102: recipe for target 'all' failed
make: *** [all] Error 2

中文提示是:make: *** 没有规则可以创建“XXX.o”需要的目标“***”。 停止
也就是说/usr/local/lib/libDBoW3.a这个静态库文件不存在。
这是由于动态库链接中断造成的,我们在相应的文件目录下看看该文件的状态,但是观察到这个路径下有共享库,因此这个好解决,把其改为共享库:
在这里插入图片描述
解决办法:只需要将CMakeList.txt中的libDBow3.a改为libDBow3.so即可。

set( DBoW3_LIBS "/usr/local/lib/libDBoW3.so" )

2.报错: warning: libopencv_core.so.4.5, needed by /usr/local/lib/libDBoW3.so, not found (try using -rpath or -rpath-link)

$ make
[ 16%] Linking CXX executable gen_vocab
/usr/bin/ld: warning: libopencv_core.so.4.5, needed by /usr/local/lib/libDBoW3.so, not found (try using -rpath or -rpath-link)
/usr/local/lib/libDBoW3.so:对‘cv::operator<<(cv::FileStorage&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::FileNodeIterator::operator*() const’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::FileNodeIterator::operator=(cv::FileNodeIterator const&)’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::FileStorage::operator[](std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::FileNode::end() const’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::FileNode::operator=(cv::FileNode const&)’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::FileStorage::writeRaw(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, void const*, unsigned long)’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::FileStorage::FileStorage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::internal::WriteStructContext::WriteStructContext(cv::FileStorage&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::write(cv::FileStorage&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::Mat::Mat()’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::FileNode::operator int() const’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::error(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, char const*, int)’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::write(cv::FileStorage&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double)’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::Mat::Mat(cv::Mat&&)’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::FileNode::begin() const’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::operator!=(cv::FileNodeIterator const&, cv::FileNodeIterator const&)’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::FileNode::string[abi:cxx11]() const’未定义的引用
/usr/local/lib/libDBoW3.so:对‘cv::FileNode::operator double() const’未定义的引用
collect2: error: ld returned 1 exit status
CMakeFiles/gen_vocab.dir/build.make:120: recipe for target 'gen_vocab' failed
make[2]: *** [gen_vocab] Error 1
CMakeFiles/Makefile2:98: recipe for target 'CMakeFiles/gen_vocab.dir/all' failed
make[1]: *** [CMakeFiles/gen_vocab.dir/all] Error 2
Makefile:102: recipe for target 'all' failed
make: *** [all] Error 2

修改CMakeList.txt:

# opencv 
#find_package( OpenCV 3.2 REQUIRED )
find_package( OpenCV 4.5.2 REQUIRED )

CMakeList.txt:

cmake_minimum_required( VERSION 2.8 )
project( loop_closure )

set( CMAKE_BUILD_TYPE "Release" )
set( CMAKE_CXX_FLAGS "-std=c++11 -O3" )

# opencv 
#find_package( OpenCV 3.2 REQUIRED )
find_package( OpenCV 4.5.2 REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )

# dbow3 
# dbow3 is a simple lib so I assume you installed it in default directory 
set( DBoW3_INCLUDE_DIRS "/usr/local/include" )
#set( DBoW3_LIBS "/usr/local/lib/libDBoW3.o" )
set( DBoW3_LIBS "/usr/local/lib/libDBoW3.so" )

add_executable( feature_training feature_training.cpp )
target_link_libraries( feature_training ${OpenCV_LIBS} ${DBoW3_LIBS} )

add_executable( loop_closure loop_closure.cpp )
target_link_libraries( loop_closure ${OpenCV_LIBS} ${DBoW3_LIBS} )

add_executable( gen_vocab gen_vocab_large.cpp )
target_link_libraries( gen_vocab ${OpenCV_LIBS} ${DBoW3_LIBS} )

结果:

$ ./feature_training 
reading images... 
detecting ORB features ... 
creating vocabulary ... 
vocabulary info: Vocabulary: k = 10, L = 5, Weighting = tf-idf, Scoring = L1-norm, Number of words = 0

done

3.feature_training

$ ./feature_training 
reading images... 
detecting ORB features ... 
creating vocabulary ... 
vocabulary info: Vocabulary: k = 10, L = 5, Weighting = tf-idf, Scoring = L1-norm, Number of words = 4972
1 2 3 4 5 6 7 8 9 10 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 .....
......31 98 99 100 101 102 103 104 105 106 107 115 116 117 118 113 114 111 112 108 109 110 21 22 23 24 25 26 27 28 29 30 90 91 92 93 94 95 96 97 81 82 83 84 85 86 87 88 89 75 76 77 78 79 80 68 69 70 71 72 73 74 58 59 60 61 62 63 64 65 66 67 40 41 42 43 44 45 46 47 48 49 56 57 54 55 50 51 52 53 38 39 33 34 35 36 37 31 32 
done

4.loop_closure

$ ./loop_closure 
reading database
reading images... 
detecting ORB features ... 
comparing images with images 
image 0 vs image 0 : 1
image 0 vs image 1 : 0.0305829
image 0 vs image 2 : 0.0221928
image 0 vs image 3 : 0.0308756
image 0 vs image 4 : 0.0231492
image 0 vs image 5 : 0.0240249
image 0 vs image 6 : 0.0240589
image 0 vs image 7 : 0.0246117
image 0 vs image 8 : 0.0287788
image 0 vs image 9 : 0.0542239

image 1 vs image 1 : 1
image 1 vs image 2 : 0.0399516
image 1 vs image 3 : 0.0340341
image 1 vs image 4 : 0.024753
image 1 vs image 5 : 0.0256076
image 1 vs image 6 : 0.0333508
image 1 vs image 7 : 0.0423889
image 1 vs image 8 : 0.0308934
image 1 vs image 9 : 0.0330308

... ...

searching for image 6 returns 4 results:
<EntryId: 6, Score: 1>
<EntryId: 8, Score: 0.0474872>
<EntryId: 7, Score: 0.0407297>
<EntryId: 1, Score: 0.0333508>

searching for image 7 returns 4 results:
<EntryId: 7, Score: 1>
<EntryId: 1, Score: 0.0423889>
<EntryId: 6, Score: 0.0407297>
<EntryId: 8, Score: 0.0325378>

searching for image 8 returns 4 results:
<EntryId: 8, Score: 1>
<EntryId: 6, Score: 0.0474872>
<EntryId: 7, Score: 0.0325378>
<EntryId: 1, Score: 0.0308934>

searching for image 9 returns 4 results:
<EntryId: 9, Score: 1>
<EntryId: 0, Score: 0.0542239>
<EntryId: 3, Score: 0.0345848>
<EntryId: 1, Score: 0.0330308>

done.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值