emfusion编译全过程

5 篇文章 0 订阅

这两天看到一个emfusion,刚开源不久,看上去和之前的fusion系列差不多,只不过是基于TSDF的,之前是基于面元的,并且使用的数据集和之前的也都是同一套很方便,于是想跑跑看看效果,下面把自己搭建的过程和遇到的问题分享一下。

  • 首先就是安装各种依赖,官网里都写的很清楚了,这里就不重复了,但是我遇到的第一个问题就是这里的,在安装依赖的时候返回:
E: Unable to locate package libvtk7-dev(对应包)

推测可能是因为安装说明上是针对ubuntu18.04版本的,而我是ubuntu16.04,因此可能那个版本的在16.04里面没有,因此降低版本,安装libvtk5-dev.成功。

  • 编译的时候因为是使用的maskfusion的maskrcnn以及virtualenv,因此使用cmake参数指定位置:
cmake .. -DMASKRCNN_ROOT_DIR=/home/Documents/project/maskfusion-master/deps/Mask_RCNN -DMASKRCNN_VENV_DIR=/home/Documents/project/maskfusion-master/python-environment

但是后面发现emfusion需要cuda10,但是maskfusion我用的是cuda9,他们对应的tensorflow-gpu的版本是不一样的,所以后面还是按照要求重新装了一个virtualenv,执行的步骤如下:

#在maskrcnn目录下安装virtualenv
virtualenv -p /usr/bin/python3 venv
source venv/bin/activate 
#然后安装环境里面各种依赖
pip3 install -r requirements.txt
注意:里面默认装的不是gpu版本,修改为:tensorflow-gpu==1.14.0
整体如下:
numpy
scipy
Pillow
cython
matplotlib
scikit-image
tensorflow-gpu==1.14.0
keras>=2.0.8,<2.4.0
opencv-python
h5py
imgaug
IPython[all]

最后安装:pip install pycocotools
然后把预训练权重复制到maskrcnn目录下
  • 进行make的时候,遇到了问题,出现了下面这些错误:
/home/wei/Documents/project/emfusion/include/EMFusion/utils/RGBDReader.h:121:10: error: ‘thread’ in namespace ‘std’ does not name a type
     std::thread readerThread;
          ^
/home/wei/Documents/project/emfusion/include/EMFusion/utils/RGBDReader.h:122:10: error: ‘mutex’ in namespace ‘std’ does not name a type
     std::mutex readerMutex, bufferMutex;
          ^
/home/wei/Documents/project/emfusion/include/EMFusion/utils/RGBDReader.h:123:10: error: ‘condition_variable’ in namespace ‘std’ does not name a type
     std::condition_variable readerCondition, bufferCondition;
     
error: no matching function for call to ‘std::basic_ifstream<char>::open(const string&, const openmode&)’
     assocFile.open ( filename, std::ios::in );    
     
/home/wei/Documents/project/emfusion/src/utils/TUMRGBDReader.cpp:63:49: error: ‘stod’ was not declared in this scope
                 startTime = stod ( entryStrs[0] );
                                                 ^
/home/wei/Documents/project/emfusion/src/utils/TUMRGBDReader.cpp:68:49: error: ‘stod’ was not declared in this scope
                 startTime = stod ( entryStrs[0] );
                                                 ^
/home/wei/Documents/project/emfusion/src/utils/TUMRGBDReader.cpp:88:43: error: ‘stod’ was not declared in this scope
             endTime = stod ( entryStrs[0] );
                                           ^
/home/wei/Documents/project/emfusion/src/utils/TUMRGBDReader.cpp:92:21: error: ‘round’ is not a member of ‘std’
     minBufferSize = std::round ( frameRate );       

以及:

#error This file requires compiler and library support for the ISO C++ 2011 standard.
 This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.

在项目目录下的CmakeLIsts.txt里面开头加上:

set( CMAKE_CXX_FLAGS "-std=c++11" )

表示要使用C++11的标准编译,重新编译。

  • 后面make时出现:
In file included from /home/wei/Documents/project/emfusion/include/EMFusion/core/cuda/ObjTSDF.cuh:25:0,
                 from /home/wei/Documents/project/emfusion/src/core/cuda/ObjTSDF.cu:23:
/home/wei/Documents/project/emfusion/include/EMFusion/core/cuda/common.cuh:36:34: fatal error: opencv2/cudaarithm.hpp: No such file or directory
compilation terminated.
In file included from /home/wei/Documents/project/emfusion/include/EMFusion/core/cuda/TSDF.cuh:25:0,
                 from /home/wei/Documents/project/emfusion/src/core/cuda/TSDF.cu:23:
/home/wei/Documents/project/emfusion/include/EMFusion/core/cuda/common.cuh:36:34: fatal error: opencv2/cudaarithm.hpp: No such file or directory

貌似是因为opencv的版本问题(或者是之前版本编译的时候没有加上关于cuda的支持),因为我这里使用的是3.4.3,重新编译一下opencv:找打opencv的源码目录下的 build目录,重新编译安装:

cmake -DOPENCV_EXTRA_MODULES_PATH=/home/zhao/software/opencv-3.4.3/opencv_contrib-3.4.3/modules \
      -DBUILD_TESTS=OFF \
      -DBUILD_PERF_TESTS=OFF \
      -DWITH_CUDA=ON \
      -DCUDA_GENERATION=Auto \
       -DENABLE_CXX11=ON \
       -D WITH_PROTOBUF=OFF \
      ..

make -j12
sudo make install
  • 重新编译opencv的时候遇到了和protobuf相关的问题:
/home/jovyan/opencv-4.0.0/3rdparty/protobuf/src/google/protobuf/arena.cc:51:29: error: ‘SequenceNumber’ in namespace ‘google::protobuf::internal’ does not name a type
 google::protobuf::internal::SequenceNumber ArenaImpl::lifecycle_id_generator_;
                             ^~~~~~~~~~~~~~
/home/jovyan/opencv-4.0.0/3rdparty/protobuf/src/google/protobuf/arena.cc: In member function ‘void google::protobuf::internal::ArenaImpl::Init()’:
/home/jovyan/opencv-4.0.0/3rdparty/protobuf/src/google/protobuf/arena.cc:68:43: error: ‘struct std::atomic<long int>’ has no member named ‘GetNext’
   lifecycle_id_ = lifecycle_id_generator_.GetNext();
                                           ^~~~~~~
/home/jovyan/opencv-4.0.0/3rdparty/protobuf/src/google/protobuf/arena.cc:69:31: error: ‘NoBarrier_Store’ is not a member of ‘google::protobuf::internal’
   google::protobuf::internal::NoBarrier_Store(&hint_, 0);
                               ^~~~~~~~~~~~~~~
/home/jovyan/opencv-4.0.0/3rdparty/protobuf/src/google/protobuf/arena.cc:70:31: error: ‘NoBarrier_Store’ is not a member of ‘google::protobuf::internal’
   google::protobuf::internal::NoBarrier_Store(&threads_, 0);
                               ^~~~~~~~~~~~~~~
/home/jovyan/opencv-4.0.0/3rdparty/protobuf/src/google/protobuf/arena.cc:76:5: error: ‘InitBlock’ was not declared in this scope
     InitBlock(initial_block_, &thread_cache(), options_.initial_block_size);
     ^~~~~~~~~
/home/jovyan/opencv-4.0.0/3rdparty/protobuf/src/google/protobuf/arena.cc:76:5: note: suggested alternative: ‘NewBlock’
     InitBlock(initial_block_, &thread_cache(), options_.initial_block_size);

解决:原因可能是3rd目录里面的protobuf和本机上的protobuf发生冲突,重新编译时加上:-D WITH_PROTOBUF=OFF。

  • 编译opencv时出现:

/home/zhao/software/opencv-3.4.3/opencv_contrib-3.4.3/modules/rgbd/src/odometry.cpp:41:45:
 fatal error: unsupported/Eigen/MatrixFunctions: No such file or directory
compilation terminated.

解决:https://www.it610.com/article/1282169329793646592.htm

  • 再次遇到错误

怀疑是eigen版本的问题,因为之前把eigen的版本降级过一次,从3.3.8变成了3.3.5,重新升级成3.3.8之后就可以了,更换版本教程见:

https://blog.csdn.net/qq_43247439/article/details/107574195?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param

注意:maskfusion似乎只能用eigen3.3.5的版本,如果后面还要运行maksfusion,eigen只能重新安装了。

  • opencv编译好了,重新回来make -j8,出现:
/usr/include/c++/5/cmath(105): error: inline specifier allowed on function declarations only

/usr/include/c++/5/cmath(105): error: variable "std::constexpr" has already been defined

/usr/include/c++/5/cmath(105): error: expected a ";"

/usr/include/c++/5/cmath(124): error: inline specifier allowed on function declarations only

/usr/include/c++/5/cmath(124): error: variable "std::constexpr" has already been defined
CMake Error at emfusion_generated_EMFusion.cu.o.cmake:279 (message):
  Error generating file
  /home/wei/Documents/project/emfusion/build/src/CMakeFiles/emfusion.dir/core/cuda/./emfusion_generated_EMFusion.cu.o

应该是cuda相关问题,试试把cuda9.0升级成10.0,opencv还得重新编译,适配成cuda10.0的版本。还是有这些错误。

这个怎么解决的记得不是很清楚了,好像是在项目目录下的CmakeLists.txt的开头加上:set( CMAKE_CXX_FLAGS "-std=c++11" ),就解决了。

  • make遇到:
fatal error: sophus/se3.hpp: No such file or directory

解决,这个是因为我跟着slam14将里面安装的非模板类老版本导致的,因此不要进行版本回滚,直接安装:https://blog.csdn.net/fb_941219/article/details/104590842

  • make错误:
/home/wei/Documents/project/emfusion/src/core/EMFusion.cpp:1022:34: error: use of ‘mesh_vis’ before deduction of ‘auto’
     for ( const auto& mesh_vis : mesh_vis ) {

这个错误貌似是代码有问题??将源代码1022~1024行修改为:

for ( const auto& mesh : mesh_vis ) {

writeImage ( mesh_vis_out, mesh.first, mesh.second );

}

 


总结

以上就是我遇到的所有问题,以及解决版本,如果对您有帮助,希望给我的文章点个小小的赞!!!!谢谢。

另外说一句,本系统我使用的是离线进行maskrcnn的分割,但是整个系统还是运行的很慢,感觉只有2Hz左右的速度,着实很困惑,要知道maskfusion离线几乎都要实时了。我运行dynslam的时候,也是需要与处理,那也比这个系统要快很多,,,dynslam可以2年前才开源的啊,而且老实说运行的效果差强人意啊,即使是相同的数据集,和视频里面也有所差距,及比如car4-full这个数据集,数据集的前半段,maskrcnn根本没有识别出来小车,但是视频里面很快就识别出来,怎么会这样??

 

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值