编译安装DSO并在线运行摄像头
操作系统:Ubuntu16.04
数据集:https://vision.in.tum.de/data/datasets/mono-dataset?redirect=1
摄像头:笔记本摄像头
1. 当然,先下载源码:
$ git clone https://github.com/JakobEngel/dso.git
2. 安装相应的依赖项
$ sudo apt-get install libsuitesparse-dev libeigen3-dev libboost-all-dev
最好将ziplib装上(下载的源码里有安装包),因为在运行数据集的时候,可以直接读取.zip文件。在libzip解压文件下,敲下面几行命令:
$ ./configure
$ make
$ sudo make install
$ sudo cp lib/zipconf.h /usr/local/include/zipconf.h
3. 安装DSO,在dso文件下输入:
$ mkdir build
$ cd build
$ cmake ..
$ make -j
此时,有可能会报如下的错误 /usr/bin/ld: CMakeFiles/dso_dataset.dir/src/main_dso_pangolin.cpp.o: undefined reference to symbol 'pthread_create@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/dso_dataset.dir/build.make:139: recipe for target 'bin/dso_dataset' failed
make[2]: *** [bin/dso_dataset] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/dso_dataset.dir/all' failed
make[1]: *** [CMakeFiles/dso_dataset.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
解决方案: 修改CMakeLists.txt有关于Thread,首先在CMakeLists.txt中添加一条:
FIND_PACKAGE(Threads QUIET)
然后将:
if (OpenCV_FOUND AND Pangolin_FOUND)
message("--- compiling dso_dataset.")
add_executable(dso_dataset ${PROJECT_SOURCE_DIR}/src/main_dso_pangolin.cpp )
target_link_libraries(dso_dataset dso boost_system boost_thread cxsparse ${LIBZIP_LIBRARY} ${Pangolin_LIBRARIES} ${OpenCV_LIBS} )
else()
message("--- not building dso_dataset, since either don't have openCV or Pangolin.")
endif()
改为:
if (OpenCV_FOUND AND Pangolin_FOUND)
message("--- compiling dso_dataset.")
add_executable(dso_dataset ${PROJECT_SOURCE_DIR}/src/main_dso_pangolin.cpp )
target_link_libraries(dso_dataset dso boost_system boost_thread cxsparse ${LIBZIP_LIBRARY} ${Pangolin_LIBRARIES} ${OpenCV_LIBS} ${CMAKE_THREAD_LIBS_INIT})
else()
message("--- not building dso_dataset, since either don't have openCV or Pangolin.")
endif()
然后重新编译:
$ cmake ..
$ make -j
4. 启动数据集,在安装了OpenCV和Pangolin的前提下,在命令行输入:
$ ~/dso/build/bin/dso_dataset \
files=PATH/sequence_14/images.zip \
calib=PATH/sequence_14/camera.txt \
gamma=PATH/sequence_14/pcalib.txt \
vignette=PATH/sequence_14/vignette.png \
preset=0 \
mode=0
其中,PATH为自己放置sequence_14数据集的路径,运行的结果如下: 5.下面在线跑自己的摄像头,我们需要dso_ros (catkin版本),下载地址:https://github.com/JakobEngel/dso_ros/tree/catkin
此时需要电脑中安装了ROS,安装步骤可以参考另一篇博文:
http://blog.csdn.net/qq_17232031/article/details/79519308
将下载的文件放置在catkin_ws/src目录下,执行:
$ cd ~/catkin_ws
$ catkin_make
$ cd ./src/dso_ros
$ export DSO_PATH=PATH/dso
$ rosmake
一样的,PATH为自己安装dso的路径,注意是dso路径,不是dso_ros路径!!!
6. 在第一个终端中执行:
$ roscore
第二个终端,在usb_cam/lauch路径下执行:
roslaunch usb_cam usb_cam-test.launch
第三个终端就要执行runros操作了:
rosrun dso_ros dso_live image:=/usb_cam/image_raw calib=PATH/camera.txt mode=1
其中,PATH为自己的相机标定文件的路径。
不出意外,就能在线运行自己的摄像头了。