elasticfusion的配置以及环境说明参考上一篇博客
接下来说caffe的配置:
详细的配置过程说明参考:
caffe的官方指导
semanticfusion中关于caffe的安装指导
1.安装依赖项
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libopenblas-dev
sudo apt-get install the python-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install libopenblas-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
2.编译
cd semanticfusion/caffe_semanticfusion
mkdir build
cd build
cmake ..
make -j
接下来进行最后一步:编译Semanticfusion
cd semanticfusion
mkdir build
cd build
cmake ..
这个时候会报错:
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find OpenNI2 (missing: OPENNI2_LIBRARY OPENNI2_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
FindOpenNI2.cmake:62 (find_package_handle_standard_args)
CMakeLists.txt:13 (find_package)
原因是OpenNI2这个库找不到。事实上,不但找不到,编译也没有成功,库文件压根不存在去哪里找?
整了一晚上才解决,OpenNI2这个库真的是太不人性化了!
具体怎么解决的其实我也有点迷,试了好多次要放弃的时候突然编译成功了?可以按照这个步骤试一下:
1. 成功编译OpenNI2
没错之前的并没有编译成功。。。运行elasticfusion时即使编译不成功也不会报错
cd semanticfusion/elasticfusionpublic/OpenNI2/Packaging/Linux
sudo ./install.sh
cat OpenNIDevEnvironment >> ~/.bashrc
然后关闭终端重新打开(更新.bashrc文件)
cd semanticfusion/elasticfusionpublic/OpenNI2
make
如果没有报错,路径 semanticfusion/elasticfusionpublic/OpenNI2/Bin/x64-Release下面有18个文件(夹),而且有libopenNI2.so这个文件,说明OpenNI2编译成功了。
2.修改semanticfusion的FindOpenNI2.cmake文件
因为原来的FindOpenNI2.cmake文件找不到OpenNI2的库文件
gedit semanticfusion/FindOpenNI2.cmake
原来的文件:
find_path(OPENNI2_INCLUDE_DIR OpenNI.h
HINTS
${PC_OPENNI_INCLUDEDIR}
${PC_OPENNI_INCLUDE_DIRS}
PATHS
"${PROGRAM_FILES}/OpenNI2/Include"
"${CMAKE_SOURCE_DIR}/../OpenNI2/Include"
"${CMAKE_SOURCE_DIR}/../../OpenNI2/Include"
"${CMAKE_SOURCE_DIR}/../../../OpenNI2/Include"
"${CMAKE_SOURCE_DIR}/../../../code/OpenNI2/Include"
/usr/include
/user/include
PATH_SUFFIXES openni2 ni2
)
以及
find_library(OPENNI2_LIBRARY
NAMES OpenNI2
HINTS
${PC_OPENNI_LIBDIR}
${PC_OPENNI_LIBRARY_DIRS}
PATHS
"${PROGRAM_FILES}}/OpenNI2/Redist"
"${PROGRAM_FILES}/OpenNI2"
"${CMAKE_SOURCE_DIR}/../OpenNI2/Bin/x64-Release"
"${CMAKE_SOURCE_DIR}/../../OpenNI2/Bin/x64-Release"
"${CMAKE_SOURCE_DIR}/../../../OpenNI2/Bin/x64-Release"
"${CMAKE_SOURCE_DIR}/../../../code/OpenNI2/Bin/x64-Release"
/usr/lib
/user/lib
PATH_SUFFIXES ${OPENNI_PATH_SUFFIXES}
)
两块代码分别改写为:
find_path(OPENNI2_INCLUDE_DIR OpenNI.h
HINTS
${PC_OPENNI_INCLUDEDIR}
${PC_OPENNI_INCLUDE_DIRS}
PATHS
"${PROGRAM_FILES}/OpenNI2/Include"
"${CMAKE_SOURCE_DIR}/elasticfusionpublic/OpenNI2/Include"
"${CMAKE_SOURCE_DIR}/../OpenNI2/Include"
"${CMAKE_SOURCE_DIR}/../../OpenNI2/Include"
"${CMAKE_SOURCE_DIR}/../../../OpenNI2/Include"
"${CMAKE_SOURCE_DIR}/../../../code/OpenNI2/Include"
/usr/include
/user/include
PATH_SUFFIXES openni2 ni2
)
以及
find_library(OPENNI2_LIBRARY
NAMES OpenNI2
HINTS
${PC_OPENNI_LIBDIR}
${PC_OPENNI_LIBRARY_DIRS}
PATHS
"${PROGRAM_FILES}}/OpenNI2/Redist"
"${PROGRAM_FILES}/OpenNI2"
"${CMAKE_SOURCE_DIR}/elasticfusionpublic/OpenNI2/Bin/x64-Release"
"${CMAKE_SOURCE_DIR}/../OpenNI2/Bin/x64-Release"
"${CMAKE_SOURCE_DIR}/../../OpenNI2/Bin/x64-Release"
"${CMAKE_SOURCE_DIR}/../../../OpenNI2/Bin/x64-Release"
"${CMAKE_SOURCE_DIR}/../../../code/OpenNI2/Bin/x64-Release"
/usr/lib
/user/lib
PATH_SUFFIXES ${OPENNI_PATH_SUFFIXES}
)
其实就是多加了两行寻找库文件的路径。
改写完成后保存退出:
cd semanticfusion
mkdir build
cd build
cmake ..
make -j
输出:
[100%] Linking CXX executable SemanticFusion
[100%] Built target SemanticFusion
完成!