1、下载程序
git clone https://github.com/mp3guy/ElasticFusion.git
git clone https://github.com/wenjinshi/Pangolin_0.git
首先下载好了ElasticFusion程序和Pangolin程序,我这里用到的Pangolin是使用旧版本的,因为这里也参考了之前的博主也类似的问题,大家如果感兴趣可以结合起来看。
总而言之,你要下载一个pangolin以及Elasticfusion程序,接下来的就是安装包下载安装了。
2、相关环境的配置
2.1 简单方法
简单方法是有要求的,假如你是Ubuntu 14.04 15.04 16.04版本,并且电脑是属于啥也没有安装的状态,那么你可以选择一键安装,也就是直接运行build.sh文件(其实build.sh文件就是在帮你操作,你只是不用自己输入指令罢了)
2.2 手动安装依赖包
sudo apt-get install -y cmake-qt-gui git build-essential libusb-1.0-0-dev libudev-dev openjdk-7-jdk freeglut3-dev libglew-dev libsuitesparse-dev libeigen3-dev zlib1g-dev libjpeg-dev
安装Pangolin
cd Pangolin
mkdir build
cd build
cmake ../ -DAVFORMAT_INCLUDE_DIR="" -DCPP11_NO_BOOST=ON
make -j8
cd ../..
安装OpenNI2
sudo apt-cache search openni2
sudo apt-get install libopenni2-dev
2.3安装依赖包问题解决
(1)查看自己的硬件,得是N卡,因为要用cuda
(base) csl@csl-220:~$ lspci | grep -i vga
01:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
03:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
(2)查看安装的cuda版本,作者要求cuda版本不低于7.0,通过指令可以看到我的版本是11.5
(base) csl@csl-220:~$ nvidia-smi
Fri Feb 25 20:52:29 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 495.29.05 Driver Version: 495.29.05 CUDA Version: 11.5 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... On | 00000000:01:00.0 On | N/A |
| 0% 32C P8 21W / 275W | 1243MiB / 11177MiB | 5% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 1 NVIDIA GeForce ... On | 00000000:03:00.0 Off | N/A |
| 23% 25C P8 8W / 250W | 13MiB / 11178MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1117 G /usr/lib/xorg/Xorg 35MiB |
| 0 N/A N/A 1665 G /usr/lib/xorg/Xorg 270MiB |
| 0 N/A N/A 1794 G /usr/bin/gnome-shell 57MiB |
| 0 N/A N/A 725247 G .../csl/anaconda3/bin/python 2MiB |
| 0 N/A N/A 1059685 C .../csl/anaconda3/bin/python 823MiB |
| 0 N/A N/A 1488220 G ...nlogin/bin/sunloginclient 11MiB |
| 0 N/A N/A 1732533 G ...AAAAAAAAA= --shared-files 25MiB |
| 1 N/A N/A 1117 G /usr/lib/xorg/Xorg 4MiB |
| 1 N/A N/A 1665 G /usr/lib/xorg/Xorg 4MiB |
+-----------------------------------------------------------------------------+
(3)安装openjdk
在用上述指令安装时,因为版本问题,我的出现如下内容:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
没有可用的软件包 openjdk-7-jdk,但是它被其它的软件包引用了。
这可能意味着这个缺失的软件包可能已被废弃,
或者只能在其他发布源中找到
E: 软件包 openjdk-7-jdk 没有可安装候选
使用指令
apt search openjdk
进行查看可安装的OpenJDK版本,选择合适版本进行安装,安装之后查看是否安装成功
(base) csl@csl-220:~$ java --version
openjdk 11.0.13 2021-10-19
OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)
(4)还有一个问题,报错我不记得了,但是是要给gcc版本降级,具体可以等大家遇到相关报错我再来补充,因为我当时遇到这个问题并没有做详细的记录。
3、对Elasticfusion进行编译
cd ../Core
mkdir build
cd build
cmake ../src
make -j8
cd ../../GPUTest
mkdir build
cd build
cmake ../src
make -j8
cd ../../GUI
mkdir build
cd build
cmake ../src
make -j8
4、运行数据集dyson.klg
可以直接点超链接下载数据集
将下载好的数据集放在GUI的build目录下
然后运行它
./ElasticFusion -l dyson_lab.klg
5、运行结果展示
对于弹出来的main窗口,点下save键保存点云数据展示
6、问题总结
说实话,我光是运行这个程序,还没到理解代码的阶段,就花费了很久的时间,它存在很多问题,对硬件配置有要求,还有软件版本也有要求,我也很头疼,所以不同的人运行出现的问题也可能不一样,我尽量给大家总结。
error1
在进行Core编译的时候,出现了如下问题
‘decay_t’ is not a member of ‘std’
这个问题是由于c++版本不匹配引起的,在对应的CMakeLsit.txt文件里面,做出如下改动
set(CMAKE_CXX_FLAGS ${ADDITIONAL_CMAKE_CXX_FLAGS} "-O3 -msse2 -msse3 -Wall -std=c++11 -DSHADER_DIR=${efusion_SHADER_DIR}")
将这里的c++11改成c++14即可
error2
在编译Core的过程中,进行cmake …/src指令之后,看到终端有如下显示
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found CUDA: /usr (found version "10.1")
-- Found SuiteSparse
-- CUDA NVCC target flags: -gencode;arch=compute_30,code=sm_30;-gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_61,code=sm_61
-- Configuring done
-- Generating done
-- Build files have been written to: /home/csl/wenjin/ElasticFusion/Core/build
这个我一开始以为有问题,倒不必担心,我在上篇博客中已经解释,但一定得观察清楚,终端显示是否和我完全一样,因为有的最后并没有找到pthread,有的又是没有找到SuitSparse等问题,但是这些我这里都Found了,所以不必在意
error3
在编译GUI部分,有关于Set函数的报错,这个部分改动是对set函数的调用进行改动(原因,因为我现在还没有看明白代码,我也还不太明白)。
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp: In constructor ‘MainController::MainController(int, char**)’:
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp:115:28: error: ‘class std::shared_ptr<pangolin::VarValueT<bool> >’ has no member named ‘Set’; did you mean ‘get’?
gui->flipColors->Ref().Set(logReader->flipColors);
^~~
get
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp:116:25: error: ‘class std::shared_ptr<pangolin::VarValueT<bool> >’ has no member named ‘Set’; did you mean ‘get’?
gui->rgbOnly->Ref().Set(false);
^~~
get
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp:117:25: error: ‘class std::shared_ptr<pangolin::VarValueT<bool> >’ has no member named ‘Set’; did you mean ‘get’?
gui->pyramid->Ref().Set(true);
^~~
get
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp:118:26: error: ‘class std::shared_ptr<pangolin::VarValueT<bool> >’ has no member named ‘Set’; did you mean ‘get’?
gui->fastOdom->Ref().Set(fastOdom);
^~~
get
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp:119:37: error: ‘class std::shared_ptr<pangolin::VarValueT<float> >’ has no member named ‘Set’; did you mean ‘get’?
gui->confidenceThreshold->Ref().Set(confidence);
^~~
get
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp:120:29: error: ‘class std::shared_ptr<pangolin::VarValueT<float> >’ has no member named ‘Set’; did you mean ‘get’?
gui->depthCutoff->Ref().Set(depth);
^~~
get
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp:121:27: error: ‘class std::shared_ptr<pangolin::VarValueT<float> >’ has no member named ‘Set’; did you mean ‘get’?
gui->icpWeight->Ref().Set(icp);
^~~
get
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp:122:21: error: ‘class std::shared_ptr<pangolin::VarValueT<bool> >’ has no member named ‘Set’; did you mean ‘get’?
gui->so3->Ref().Set(so3);
^~~
get
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp:123:33: error: ‘class std::shared_ptr<pangolin::VarValueT<bool> >’ has no member named ‘Set’; did you mean ‘get’?
gui->frameToFrameRGB->Ref().Set(frameToFrameRGB);
^~~
get
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp: In member function ‘void MainController::run()’:
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp:335:34: error: ‘class std::shared_ptr<pangolin::VarValueT<std::__cxx11::basic_string<char> > >’ has no member named ‘Set’; did you mean ‘get’?
gui->trackInliers->Ref().Set(stri.str());
^~~
get
/home/csl/wenjin/ElasticFusion/GUI/src/MainController.cpp:339:30: error: ‘class std::shared_ptr<pangolin::VarValueT<std::__cxx11::basic_string<char> > >’ has no member named ‘Set’; did you mean ‘get’?
gui->trackRes->Ref().Set(stre.str());
^~~
get
make[2]: *** [CMakeFiles/ElasticFusion.dir/build.make:76:CMakeFiles/ElasticFusion.dir/MainController.cpp.o] 错误 1
make[2]: *** 正在等待未完成的任务....
make[1]: *** [CMakeFiles/Makefile2:76:CMakeFiles/ElasticFusion.dir/all] 错误 2
make: *** [Makefile:130:all] 错误 2
在MainController.cpp中找到下面的两处代码,将Set函数前面的.换成->即可。
gui->flipColors->Ref().Set(logReader->flipColors);
gui->rgbOnly->Ref().Set(false);
gui->pyramid->Ref().Set(true);
gui->fastOdom->Ref().Set(fastOdom);
gui->confidenceThreshold->Ref().Set(confidence);
gui->depthCutoff->Ref().Set(depth);
gui->icpWeight->Ref().Set(icp);
gui->so3->Ref().Set(so3);
gui->frameToFrameRGB->Ref().Set(frameToFrameRGB);
std::stringstream stri;
stri << eFusion->getModelToModel().lastICPCount;
gui->trackInliers->Ref().Set(stri.str());
std::stringstream stre;
stre << (std::isnan(eFusion->getModelToModel().lastICPError) ? 0 : eFusion->getModelToModel().lastICPError);
gui->trackRes->Ref().Set(stre.str());
error4
在运行数据集的时候,本以为成功了,因为编译完成了,结果又有报错
terminate called after throwing an instance of 'pangolin::FactoryRegistry::ParameterMismatchException'
what(): Unable to open URI
full_uri:
scheme: default
params:
SAMPLE_BUFFERS = 0
SAMPLES = 0
w = 1485
h = 980
window_title = Main
Unrecognized options for scheme (SAMPLES,SAMPLE_BUFFERS,)
已放弃 (核心已转储)
这个问题解决方法,在GUI.h文件中找到如下代码
windowParams.Set("SAMPLE_BUFFERS", 0);
windowParams.Set("SAMPLES", 0);
将这两行代码删除即可
error5
在运行数据的时候,结果可以正常显示,但是终端显示这个问题
Your GPU "NVIDIA GeForce GTX 1080 Ti" isn't in the ICP Step performance database, please add it
Your GPU "NVIDIA GeForce GTX 1080 Ti" isn't in the RGB Step performance database, please add it
Your GPU "NVIDIA GeForce GTX 1080 Ti" isn't in the RGB Res performance database, please add it
Your GPU "NVIDIA GeForce GTX 1080 Ti" isn't in the SO3 Step performance database, please add it
意思是说,代码没有对显卡进行适配,这个问题不用担心,作者的程序有专门针对这个的解决方法。
进入GPUTset/build
./GPUtest ../
可以看到终端有输出结果,将终端的输出结果复制到GPUConfig.h文件中即可。
icpStepMap["NVIDIA GeForce GTX 1080 Ti"] = std::pair<int, int>(240, 80);
rgbStepMap["NVIDIA GeForce GTX 1080 Ti"] = std::pair<int, int>(256, 48);
rgbResMap["NVIDIA GeForce GTX 1080 Ti"] = std::pair<int, int>(96, 496);
so3StepMap["NVIDIA GeForce GTX 1080 Ti"] = std::pair<int, int>(176, 80);
(这是Core里面的文件,所以要重新编译Core)
error6
救命,本来已经运行正常了,当我再去跑数据集的时候,出现了这个???
ElasticFusion: /home/csl/wenjin/ElasticFusion/Core/src/Deformation.cpp:311: void Deformation::sampleGraphModel(const std::pair<unsigned int, unsigned int>&): Assertion `false && "Assumption failed"' failed.
我以为又出啥事儿了呢,别担心,再次将Core编译一遍即可。
由于这是成功之后的总结,我记得我遇到的问题远不止这么多,我以后会继续补充哒!!!