MaskFusion编译全过程

之前在自己的电脑上搭建过一次,当时虽然能成功运行,但是效果不咋地,代码也没有深入研究,因为后面做的课题和这个相关,所以这几天在服务器上再次搭建了一次,上次搭建的过程:https://blog.csdn.net/qq_35590091/article/details/105264163,说的比较简略,这次准备详细说一说流程,以及自己遇到的问题。

注:maskfusion对显卡要求较高,我这个服务器的配置是ubuntu16.04+1080Ti+cuda9.0+cudnn7.0,并且论文里要求的是双显卡实时运行,一个用于mask-Rcnn,一个用于slam。我这里只有单显卡,所以有点卡,另外窗口里的实例分割的效果我总感觉很不理想,很多时候各个实例都没有分割出来,不知道我的参数没有设置好还是怎么说,准备接下来详细研究一下。


环境搭建与安装

maskfusion的构建还是比较简单的,具体的细节都写在了项目的build.sh里面,另外最上方也有介绍用法,整个build.sh主要分为三部分,根据运行build.sh的参数来决定运行那几个部分:

 `--install-packages` to install required Ubuntu packages
 `--install-cuda` to install the NVIDIA CUDA suite
 `--build-dependencies` to build third party dependencies

三部分分别用来:安装需要的各种包+cuda+第三方依赖。因为我cuda之前安装过了,所以我没有运行第二部分。那就可以运行:

./build.sh --install-packages --build-dependencies

需要注意的是,过程中会安装一个virtualenv,这个是一个虚拟环境,和anaconda差不多,他会安装在你的项目目录下,然后接下来他会运行:

virtualenv python-environment
source python-environment/bin/activate

来创建一个叫python-environment的虚拟环境,以及进入这个虚拟环境,这之后,你的命令行前面就会出现:

说明进入了虚拟环境,下面的所有pip3 install安装的软件都是安装在这个虚拟环境。所以后面每次运行都要启动这个虚拟环境才行。

最需要注意的是--build-dependencies会创建一个deps目录,将所有需要的第三方依赖库都安装在这,但是因为网络原因,很多库可能下载失败,所以建议这部分都手动执行安装build,举个例子,第一部分是安装opencv,build.sh里面的代码为:

highlight "Building opencv..."
  git_clone "git clone --branch 3.4.1 --depth=1 https://github.com/opencv/opencv.git"
  cd opencv
  mkdir -p build
  cd build
  cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="`pwd`/../install" \
    \
。。。。省略

那么我们手动执行就是:

git clone --branch 3.4.1 --depth=1 https://github.com/opencv/opencv.git
cd opencv
  mkdir -p build
  cd build
  cmake \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX="`pwd`/../install" \
    \
。。。省略

对每个部分都手动下载以及安装,确保每个部分都下载完整以及安装成功。这才能保证最后的make成功。另外,里面的有些部分我没有按照build.sh里面的来,比如tensorflow和keras的版本,我都手动指定了,参考:https://blog.csdn.net/qq_35590091/article/details/105264163


遇到的问题

  • 运行 ./build.sh --install-packages 遇到
The following packages have unmet dependencies: 
openjdk-8-jdk : 
Depends: openjdk-8-jre (= 8u77-b03-3ubuntu3) but it is not going to be installed Depends: openjdk-8-jdk-headless (= 8u77-b03-3ubuntu3) but it is not going to be installed E: Unable to correct problems, you have held broken packages.

执行:

sudo apt-get remove openjdk-8-jre

sudo apt-get remove openjdk-8-jdk-headless

又提示:

The following packages were automatically installed and are no longer required:
 ca-certificates-java default-jre-headless fonts-dejavu-extra java-common openjdk-8-jre-headless python-colorama python-distlib 
Use 'sudo apt autoremove' to remove them.

然后执行:sudo apt autoremove

重新安装:sudo apt-get install openjdk-8-jdk

  • 遇到:pip3: command not found

解决:sudo apt-get install python3-pip

  • 运行virtualenv python-environment,遇到:AttributeError: module 'os' has no attribute 'PathLike'

在python里面运行import os os.PathLike

无论在我的电脑上还是服务器上,都是返回这个,但是我的电脑是可以正常创建环境的。

最后发现还是版本问题,原来的版本是virtualenv-20.1.0,最后换成:virtualenv-20.0.13就好了。

  • 在coco的coco/PythonAPI目录下进行make时出现:pycocotools/_mask.c:32:20: fatal error: Python.h: No such file or directory

网上说因为没有安装python3-dev,于是安装这个,结果又返回一堆错误。

The following packages have unmet dependencies:
 python3-dev :
Depends: libpython3-dev (= 3.5.1-3) but it is not going to be installed 
Depends: python3.5-dev (>= 3.5.1-2~) but it is not going to be installed E: Unable to correct problems, you have held broken packages.

解决:https://www.cnblogs.com/ymjyqsx/p/6194968.html

  • 最后make -j8时遇到:
make[2]: *** No rule to make target '/usr/lib/libOpenNI.so', needed by 'Core/liblibmaskfusion.so'. Stop. 
make[2]: *** Waiting for unfinished jobs.... [ 73%] Building CXX object Core/CMakeFiles/libmaskfusion.dir/Segmentation/MaskRCNN/MaskRCNN.cpp.o CMakeFiles/Makefile2:117: recipe for target 'Core/CMakeFiles/libmaskfusion.dir/all' failed 
make[1]: *** [Core/CMakeFiles/libmaskfusion.dir/all] Error 2 Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

好象是pangolin库没有编译好,把pangolin下面的build删除掉,重新编译一遍。

  • 运行maskrcnn的demo:./offline_runner.py -i /path/to/rgb/frames -o /path/to/output/masks --filter teddy_bear

返回ImportError: cannot import name 'Type'

解决:降低scipy的版本,pip3 install scipy==1.2.1

  • 然后,又遇到了:
ImportError: No module named '_tkinter', please install the python3-tk package

解决:sudo apt-get install python3-tk

现在可以了,只要在同一个目录下创建一个input,里面放入图片,然后创建一个output目录,执行:

./offline_runner.py -i input -o output --filter person

这样,就会在output目录下看到结果。

  • 另外,关于:
Your GPU "GeForce GTX 1080 Ti" isn't in the ICP Step performance database, please add it 
Your GPU "GeForce GTX 1080 Ti" isn't in the RGB Step performance database, please add it 
Your GPU "GeForce GTX 1080 Ti" isn't in the RGB Res performance database, please add it 
Your GPU "GeForce GTX 1080 Ti" isn't in the SO3 Step performance database, please add it

这个问题,查看ElasticFusion github README.

方法就是运行GPUtest这个程序,但是这个程序是在elasticfusion里面才有的,maskfusion没有,因此还得安装一个elasticfusion???

https://blog.csdn.net/phy12321/article/details/103011957


最后,make成功的话,只要运行build/GUI下的MaskFusion即可,运行命令如下:

./MaskFusion -run -l   /home/wei/Documents/dataset/klg/room4-noise.klg

存在的问题

1,分割的效果不理想:

如下图,右边红色的就是墙,这怎么还能呢个被识别出来,另外,下面还有个杯子,从头到尾就没有被识别出来,另外的几个数据集也是类似的效果,为什么??


2020.12.8更新

要解决上面的问题首先需要在config.toml.in里面填写进去需要识别那些物体,以及需要跟踪的物体,第二,源程序里面默认的是所有物体都是静态的,所以一旦当物体运动时,效果会非常差 ,注意看作者这段话:

Tracking of individual objects can easily be enabled / disabled by calling makeStatic() and makeNonStatic() of instances of the Model class. The overall system runs more robustly if objects are only tracked when being touched by a person. We are not providing hand-detection software at the moment.

因此,需要修改源码里面将新生成的物体都设置为动态的,将:

MaskFusion::spawnObjectModel()方法里面的newModel->makeStatic(globalModel->getPose()),修改为:newModel->makeNonStatic();


效果比之前好了很多,起码物体移动路径上没有残影了,另外,最好还是双GPU跑,单GPU确实效果不好,包括使用离线分割的方法。

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值