Elasticfusion(配置运行方法--转)

系统:Ubuntu 14

Kintinuous + Elastic Fusion代码来源:https://github.com/mp3guy

准备工作


安装git

[html]  view plain  copy
  1. sudo apt-get install git  
  2. git config --global user.name 你的git username  
  3. git config --global user.email 你的邮箱  
安装cmake
直接在ubuntu软件中心下载安装,但是配置Elastic Fusion需要升级到3.2,否则自带的是2.8
参考:http://askubuntu.com/questions/610291/how-to-install-cmake-3-2-on-ubuntu-14-04
[plain] view plain copy
  1. sudo apt-get install build-essential  
  2. wget http://www.cmake.org/files/v3.2/cmake-3.2.2.tar.gz  
  3. tar xf cmake-3.2.2.tar.gz  
  4. cd cmake-3.2.2  
  5. ./configure  
  6. make  
  7. sudo make install  
运行cmake --version查看版本

如果提示找不到bin/cmake,那么sudo apt-get upgrade就可以了


配置Kinect运行环境(一个参考,实际上我并没有用Kinect跑,最后用的是Xtion)
参考:http://www.cc.gatech.edu/grads/a/ahuaman3/docs/tutorials/software/build/perception.html
OpenNI2安装:

[plain]  view plain  copy
  1. sudo apt-get install g++  
  2. sudo apt-get install python  
  3. sudo apt-get install libusb-1.0-0-dev  
  4. sudo apt-get install libudev-dev  
  5. sudo apt-get install openjdk-6-jdk  
  6. sudo apt-get install freeglut3-dev  
  7. sudo apt-get install graphviz  
  8. sudo apt-get install doxygen  
  9. git clone https://github.com/occipital/OpenNI2  
  10. cd OpenNI2  
  11. make  
更改kinect rules:以root权限改动/etc/udev/rules.d/51-kinect.rules (暂时获得root权限:sudo nautilus,在弹出的文件夹中进行改动)
在其中加入:

  1. UBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02b0", MODE:="0666", OWNER:="root", GROUP:="video"  
  2. SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02ad", MODE:="0666", OWNER:="root", GROUP:="video"  
  3. SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02ae", MODE:="0666", OWNER:="root", GROUP:="video"  
  4. SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02c2", MODE:="0666", OWNER:="root", GROUP:="video"  
  5. SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02be", MODE:="0666", OWNER:="root", GROUP:="video"  
  6. SUBSYSTEM=="usb", ATTR{idVendor}=="045e", ATTR{idProduct}=="02bf", MODE:="0666", OWNER:="root", GROUP:="video"  
libfreenect安装:
[plain]  view plain  copy
  1. git clone https://github.com/OpenKinect/libfreenect.git  
  2. cd libfreenect  
  3. mkdir build; cd build  
  4. cmake .. -DBUILD_OPENNI2_DRIVER=ON  
  5. make  
  6. cp -L lib/OpenNI2-FreenectDriver/libFreenectDriver.so ${OPENNI2_DIR}/Bin/x64-Release/OpenNI2/Drivers   #将驱动拷贝到OpenNI2的解压文件夹下,OPENNI2_DIR:OpenNI2的解压文件夹  

插上kinect后,使用lsusb命令查看确保有以下三个:
Xbot camera
Xbot motor
Xbot audio

安装成功检查:

[plain]  view plain  copy
  1. cd ${OPENNI2_DIR}/Bin/x64-Release/  
  2. ./NiViewer  
配置Kintinuours运行环境


[plain]  view plain  copy
  1. git clone https://github.com/mp3guy/Kintinuous  

    1.新系统:
    找到build.sh,在属性中设置为可执行
    ./build.sh
    等待配置成功

    2.非新系统:


    安装CUDA:

    下载deb文件 https://developer.nvidia.com/cuda-downloads 

    [plain]  view plain  copy
    1. sudo dpkg -i cuda-repo-ubuntu1404_7.5-18_amd64.deb  
    2. sudo apt-get update  
    3. sudo apt-get install cuda  
    4. sudo reboot  
    查看是否成功运行cuda
    1. cd /usr/local/cuda/samples  
    2. sudo make all -j4  
    3. cd /usr/local/cuda/samples/bin/x86_64/linux/release  
    4. sudo ./deviceQuery  
    成功之后会出现下列信息:
        CUDA Device Query (Runtime API) version (CUDART static linking)
        Detected 1 CUDA Capable device(s) 

    我在这里遇到了一定问题,找了很久,发现是Secure Boot没关掉,关掉之后就好了。解决的流程如下:

    运行deviceQuery:no capable device
    尝试解决:
    1.怀疑是内核问题
    add in: GRUB_CMDLINE_LINUX_DEFAULT with: pci=nocrs pci=realloc
    依然:no capable device
    2.装最新的nvidia 367
    新问题:CUDA driver version is insufficient for CUDA runtime version
    3.查看当前的kernel版本
    kernel:3.19.0-65-generic
    4.查看一些参数
    sudo dpkg --list | grep nvidia
    lspci | grep -i nvidia   设备里的确有nvidia显卡
    lsmod  发现video一览只有i915_bpo,说明nvidia独显并没有被启用
    sudo modprobe nvidia-367  手动启用nvidia显卡,提示ERROR: could not insert 'nvidia_367': Required key not available
    终于找到问题:不是显卡驱动没装好,而是无法启动显卡(被BIOS禁了?)
    5.装回nvidia 352
    sudo apt-get remove --purge nvidia-*
    (***提示cmake-qt-gui依赖cmake 2.8出错,卸载cmake-qt-gui。卸载后cmake命令没出错,其他情况会不会出错有待观察)
    sudo add-apt-repository ppa:xorg-edgers/ppa -y
    sudo apt-get update
    sudo apt-get install nvidia-352
    6.查看安装的版本
    sudo dpkg --list | grep nvidia
    ii  nvidia-352                    352.93-0ubuntu1                     amd64        NVIDIA binary driver - version 352.93
    ii  nvidia-modprobe               352.93-0ubuntu1                     amd64        Load the NVIDIA kernel driver and create device files
    ii  nvidia-opencl-icd-352         352.93-0ubuntu1                     amd64        NVIDIA OpenCL ICD
    ii  nvidia-prime                  0.6.2                               amd64        Tools to enable NVIDIA's Prime
    ii  nvidia-settings               367.35-0ubuntu0~gpu14.04.1          amd64        Tool for configuring the NVIDIA graphics driver
    安装正确,运行devieQuery依然提示no device found,回到原点
    7.现在的问题:
    sudo modprobe nvidia-352  手动启用nvidia显卡,提示ERROR: could not insert 'nvidia_352': Required key not available
    网上给出的解决方法:turn off the secure boot feature of the motherboard
    8.尝试解决:开机F12,secure boot勾选为disable,legacy勾选
    sudo modprobe nvidia-352   成功!
    nvidia-settings  显示独显成功!
    deviceQuery  检测到显卡!应该可以了!
    9.新问题:kinect无法连接了。。。(之前是可以的)
    lsusb   能看到XBOX的三个设备
    从头重新配置,发现有几个依赖包没有安装(可能之前哪一步把他卸载了)
    sudo apt-get install openjdk-6-jdk 
    sudo apt-get install graphviz
    sudo apt-get install doxygen
    之后NiViewer可以正常运行了



安装依赖项:

[plain]  view plain  copy
  1. sudo apt-get install -y cmake-qt-gui git build-essential libusb-1.0-0-dev libudev-dev openjdk-7-jdk freeglut3-dev python-vtk libvtk-java libglew-dev cuda-7-5 libsuitesparse-dev  

安装pcl:
[plain]  view plain  copy
  1. sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl  
  2. sudo apt-get update  
  3. sudo apt-get install libpcl-all  

安装opengl:
[plain]  view plain  copy
  1. sudo apt-get install build-essential  
  2. sudo apt-get install libgl1-mesa-dev  
  3. sudo apt-get install libgl1-mesa-dev  
  4. sudo apt-get install libglu1-mesa-dev  
  5. sudo apt-get install freeglut3-dev  

安装opencv:
(不可以直接在ubuntu的apt-get里面获取opencv,因为ubuntu提供的opencv没有nonfree模块)
下载http://opencv.org/downloads.html
[plain]  view plain  copy
  1. sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev  
  2. unzip opencv-2.4.9.zip  
  3. cd opencv-2.4.9  
  4. mkdir build  
  5. cd build  
  6. cmake -D BUILD_NEW_PYTHON_SUPPORT=OFF -D WITH_OPENCL=OFF -D WITH_OPENMP=ON -D INSTALL_C_EXAMPLES=OFF -D BUILD_DOCS=OFF -D BUILD_EXAMPLES=OFF -D WITH_QT=OFF -D WITH_OPENGL=OFF -D WITH_VTK=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_TESTS=OFF -D WITH_CUDA=OFF -D BUILD_opencv_gpu=OFF ..  
  7. make  
  8. sudo make install  


安装Dlib:
[plain]  view plain  copy
  1. sudo apt-get install libboost-dev  
  2. git clone https://github.com/dorian3d/DLib  
  3. cd DLib/build  
  4. cmake ..  
  5. make  
  6. sudo make install  

安装DBoW2:

[plain]  view plain  copy
  1. git clone https://github.com/dorian3d/DBoW2#dbow2  
  2. cd DBoW2/build  
  3. cmake ..  
  4. make  
  5. sudo make install  

安装DLoopDetector:

[plain]  view plain  copy
  1. git clone https://github.com/dorian3d/DLoopDetector  
  2. cd DLoopDetector/build  
  3. cmake ..  
  4. make  
  5. sudo make install  

安装iSAM:

[plain]  view plain  copy
  1. svn co https://svn.csail.mit.edu/isam  
  2. cd isam  
  3. make  

安装Pangolin:
[plain]  view plain  copy
  1. sudo apt-get install libglew-dev  
  2. sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev  
  3. sudo apt-get install libpython2.7-dev  
  4. sudo apt-get install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev  
  5. sudo apt-get install libdc1394-22-dev libraw1394-dev  
  6. sudo apt-get install libjpeg-dev libpng12-dev libtiff5-dev libopenexr-dev  
  7. git clone https://github.com/stevenlovegrove/Pangolin  
  8. cd Pangolin/build  
  9. cmake -DCPP11_NO_BOOST=1 ..  
  10. make -j  

运行Kintinuous:

作者的一些说明:
The GUI (Kintinuous) can take a bunch of parameters when launching it from the command line. They are as follows:
    -c : Loads a camera calibration file specified by a depth_intrinsics matrix in OpenCV format.
    -l : Processes the specified .klg log file.
    -v : Loads DBoW vocabulary file.
    -p : Loads ground truth poses to use instead of estimated pose.
    -gpu : Sets which GPU should be used by CUDA.
    -n : Number of frames to process.
    -t : Voxel threshold for volume shifting (default 14).
    -cw : Removes voxels below this threshold when extracting slices (default 8).
    -lt : Disallow loop closures within this time period of the last (default 30s).
    -s : Size of the fusion volume (default 6m).
    -dg : Rate of pose sampling for deformation (default 0.8m).
    -il : Inlier threshold for RANSAC (default 0.35).
    -it : Residual threshold for pose graph optimisation (default 10).
    -sm : Static mode (disable volume shifting).
    -f : Flip RGB/BGR.
    -od : Perform online deformation (required for loop closure).
    -m : Enable mesh generation.
    -no : Disable overlap of extracted slices.
    -nos : Remove overlap when saving map.
    -r : Use RGB tracking only.
    -ri : Use combined ICP+RGB tracking.
    -d : Enable dynamic cube positioning.
    -dc : Disable color weighting by angle.
    -fl : Subsample pose graph for faster loop closure.
    -fod : Enable fast odometry.

以上所有配置以后就可以正常运行kintinuous了,运行的命令可以看上面的作者说明,比如:

[plain]  view plain  copy
  1. ./Kintinuous     

  # try run off an attached ASUS sensor live. You can provide a .klg log file instead with the -l parameter. You can capture .klg format logs using either Logger1 or Logger2.

默认从华硕Xtion中读取图像,如果没有Xtion则会报错找不到设备

没有话说Xtion的可以试试作者给的几个log,在原网址上有下载。

使用log的运行方法如下:

[plain]  view plain  copy
  1. ./Kintinuous -s 7 -v ../vocab.yml.gz -l loop.klg -ri -fl -od    

  # author has provided a sample dataset loop.klg which you can run easily with Kintinuous

配置ElasticFusion

准备工作和相关的依赖项包括开源包的配置方法和KIntinous一样,只需要额外安装开源包openni2

安装OpenNI2:
[plain]  view plain  copy
  1. git clone https://github.com/occipital/OpenNI2.git  
  2. cd OpenNI2  
  3. make -j8  
  4. cd ..  

生成 ./ElasticFusion

注意源码里有三个项目,Core、GPUTest和GUI

如果要使用作者的程序,则需要把三个项目安装顺序依次配置成功

[plain]  view plain  copy
  1. cd ../Core  
  2. mkdir build  
  3. cd build  
  4. cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-7.5 ../src  
  5. make -j8  
  6. cd ../../GPUTest  
  7. mkdir build  
  8. cd build  
  9. cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-7.5 ../src  
  10. make -j8  
  11. cd ../../GUI  
  12. mkdir build  
  13. cd build  
  14. cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-7.5 ../src  
  15. make -j8  
  16. cd ../../myfusion  
  17. mkdir build  
  18. cd build  
  19. cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-7.5 ../src  
  20. make -j8  
之后就能在GUI/build中看到可执行项ElasticFusion

直接调用以下命令,默认从华硕Xtion中获取图像并开始三位重建

[plain]  view plain  copy
  1. ./ElasticFusion  

也可以使用参数控制,一些Elastci Fusion的运行参数如下:

  • -cal : Loads a camera calibration file specified as fx fy cx cy. 载入相机参数(默认参数为华硕Xtion的参数)
  • -l : Processes the specified .klg log file. 不使用摄像头读取,使用log文件模拟相机的图像采集过程
  • -p : Loads ground truth poses to use instead of estimated pose. 读取ground truth的位姿来作为三位重建的依据之一(默认会自动估计当前的位置,如果传入ground truth的位姿则直接使用传入的位姿)
  • -c : Surfel confidence threshold (default 10). Surfel的信任阈值
  • -d : Cutoff distance for depth processing (default 3m). 多少距离以上的深度数据视为无用数据(单位mm,默认为3000,即3m)
  • -i : Relative ICP/RGB tracking weight (default 10). ICP/RGB的tracking阈值
  • -ie : Local loop closure residual threshold (default 5e-05).
  • -ic : Local loop closure inlier threshold (default 35000).
  • -cv : Local loop closure covariance threshold (default 1e-05).
  • -pt : Global loop closure photometric threshold (default 115).
  • -ft : Fern encoding threshold (default 0.3095). 关键帧编码阈值
  • -t : Time window length (default 200).
  • -s : Frames to skip at start of log. 如果使用log,跳过初始帧的数目
  • -e : Cut off frame of log.
  • -f : Flip RGB/BGR.
  • -icl : Enable this if using the ICL-NUIM dataset (flips normals to account for negative focal length on that data).
  • -o : Open loop mode.
  • -rl : Enable relocalisation.
  • -fs : Frame skip if processing a log to sim
  • ulate real-time.
  • -q : Quit when finished a log.
  • -fo : Fast odometry (single level pyramid).
  • -nso : Disables SO(3) pre-alignment in tracking.
  • -r : Rewind and loop log forever.
  • -ftf : Do frame-to-frame RGB tracking.
  • -sc : Showcase mode (minimal GUI).

使用Elastic Fusion的CoreAPI

作者还提供了使用他的Core作为基础库的方法。

首先编译Core项目

[plain]  view plain  copy
  1. cd ../Core  
  2. mkdir build  
  3. cd build  
  4. cmake -D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-7.5 ../src  
  5. make -j8  

然后在CMakelist.txt中加入

[plain]  view plain  copy
  1. find_package(efusion REQUIRED)  
  2. include_directories(${EFUSION_INCLUDE_DIR})  
  3. target_link_libraries(MyProject ${EFUSION_LIBRARY})  

在头文件中加入

[plain]  view plain  copy
  1. #include <ElasticFusion.h>  


初始化

[plain]  view plain  copy
  1. Resolution::getInstance(640, 480); #图像大小  
  2. Intrinsics::getInstance(528, 528, 320, 240); #相机参数  
  3. pangolin::Params windowParams; #GUI窗口  
  4. windowParams.Set("SAMPLE_BUFFERS", 0);  
  5. windowParams.Set("SAMPLES", 0);  
  6. pangolin::CreateWindowAndBind("Main", width, height, windowParams);  
  7. glPixelStorei(GL_UNPACK_ALIGNMENT, 1);  
  8. glPixelStorei(GL_PACK_ALIGNMENT, 1);  

使用封装好的ElasticFusion类,可以精确定义每一个参数

默认的构造函数

[plain]  view plain  copy
  1. ElasticFusion eFusion;   

精确定义每一个参数后调用构建函数

[plain]  view plain  copy
  1. float confidence = 10.0f; //fusion的confidence阈值  
  2. float depth = 3.0f; //去掉depth大于某个阈值的帧  
  3. float icp = 10.0f; //icp的阈值  
  4. float icpErrThresh = 5e-05; //icp错误阈值  
  5. float covThresh = 1e-05;  
  6. float photoThresh = 115;  
  7. float fernThresh = 0.3095f; //新fern的阈值  
  8. int timeDelta = 200;  
  9. int icpCountThresh = 35000;  
  10. bool openLoop = 0; //open loop模式:不开启  
  11. bool iclnuim = 0; //使用icl dataset:不使用  
  12. bool reloc = 0; //重定位模式:不开启  
  13. bool fastOdom = 0; //Fast odometry (single level pyramid) mode :不开启  
  14. bool so3 = 1; //SO(3) pre-alignment in tracking:开启  
  15. bool frameToFrameRGB = 0; //只做rgb图像的tracking:不开启  
  16. int timestamp = 0;  
  17. std::string savefilename = "test";  
  18. ElasticFusion eFusion(openLoop ? std::numeric_limits<int>::max() / 2 : timeDelta,icpCountThresh, icpErrThresh, covThresh, !openLoop, iclnuim, reloc,photoThresh, confidence, depth, icp, fastOdom, fernThresh, so3,frameToFrameRGB, savefilename);  


 

处理输入帧:

[plain]  view plain  copy
  1. eFusion.processFrame(rgb, depth, timestamp, currentPose, weightMultiplier);  

其中rgb为uchar*,depth为ushor*,timestamp为时间戳(不重要),剩下两个为可选参数

可选参数1:currentPose——先验的current pose,比如传入了标定好的ground truth三维坐标数据,则可以用上一时刻和这一时刻的三位坐标来估计相机姿态

[plain]  view plain  copy
  1. Eigen::Matrix4f * currentPose;//当前的位姿  
  2. currentPose = new Eigen::Matrix4f;  
  3. currentPose->setIdentity();  
  4. *currentPose = groundTruthOdometry->getTransformation(timestamp); }  
  5. eFusion.processFrame(rgb, depth, timestamp, currentPose, weightMultiplier);  
  6. delete currentPose;    

可选参数2:weightMultiplier (full frame fusion weight)——默认为1.f  可以自己调整,比如针对前面跳过的帧数对参数进行调整

[plain]  view plain  copy
  1. float weightMultiplier = framesToSkip + 1;  
  2. eFusion.processFrame(rgb, depth, timestamp, currentPose, weightMultiplier);  



一个简单的使用CoreAPI的程序:

[plain]  view plain  copy
  1. #include "myfusion_base.h"  
  2.   
  3. int main() {  
  4.   
  5.     //图像的尺寸以及相机参数  
  6.     int width = 640;  
  7.     int height = 480;  
  8.     int camera_fx = 528;  
  9.     int camera_fy = 528;  
  10.     int camera_cx = 320;  
  11.     int camera_cy = 240;  
  12.   
  13.     cout << "Initializing ..." << endl;  
  14.     Resolution::getInstance(width, height);  
  15.     Intrinsics::getInstance(camera_fx, camera_fy, camera_cx, camera_cy);  
  16.     cout << "Initializing done." << endl;  
  17.   
  18.     cout << "Setting parameters..." << endl;  
  19.     float confidence = 10.0f; //fusion的confidence阈值  
  20.     float depth = 3.0f; //去掉depth大于某个阈值的帧  
  21.     float icp = 10.0f; //icp的阈值  
  22.     float icpErrThresh = 5e-05; //icp错误阈值  
  23.     float covThresh = 1e-05;  
  24.     float photoThresh = 115;  
  25.     float fernThresh = 0.3095f; //新fern的阈值  
  26.     int timeDelta = 200;  
  27.     int icpCountThresh = 35000;  
  28.     //int start = 1;  
  29.     //int end = std::numeric_limits<unsigned short>::max(); //Funny bound, since we predict times in this format really!  
  30.     bool openLoop = 0; //open loop模式:不开启  
  31.     bool iclnuim = 0; //使用icl dataset:不使用  
  32.     bool reloc = 0; //重定位模式:先做重建,不开启重定位  
  33.     bool fastOdom = 0; //Fast odometry (single level pyramid) mode :不开启  
  34.     bool so3 = 1; //SO(3) pre-alignment in tracking:开启  
  35.     bool frameToFrameRGB = 0; //只做rgb图像的tracking:不开启  
  36.     int timestamp = 0;  
  37.     std::string savefilename = "test";  
  38.     cout << "Setting parameters done." << endl;  
  39.   
  40.     cout << "Building eFusion..." << endl;  
  41.     pangolin::Params windowParams;  
  42.     windowParams.Set("SAMPLE_BUFFERS", 0);  
  43.     windowParams.Set("SAMPLES", 0);  
  44.     pangolin::CreateWindowAndBind("Main", width, height, windowParams);  
  45.     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);  
  46.     glPixelStorei(GL_PACK_ALIGNMENT, 1);  
  47.     ElasticFusion eFusion(  
  48.             openLoop ? std::numeric_limits<int>::max() / 2 : timeDelta,  
  49.             icpCountThresh, icpErrThresh, covThresh, !openLoop, iclnuim, reloc,  
  50.             photoThresh, confidence, depth, icp, fastOdom, fernThresh, so3,  
  51.             frameToFrameRGB, savefilename);  
  52.     cout << "Building eFusion done" << endl;  
  53.   
  54.     //待处理文件的位置和下标  
  55.     std::string filedir = "../pic/";  
  56.     int file_start = 1;  
  57.     int file_end = 782;  
  58.   
  59.       
  60.         vector<Eigen::Matrix4f> pose;  
  61.         //三位重建  
  62.         for (int file_ptr = file_start; file_ptr <= file_end; file_ptr = file_ptr +1) {  
  63.             cout << "Processing frame : "<<file_ptr << " ..."<<endl;  
  64.             FRAME f = readFrame(file_ptr, filedir);  
  65.             unsigned char * rgb = f.rgb;  
  66.             unsigned short * dep = f.dep;  
  67.             eFusion.processFrame(rgb, dep, timestamp);  
  68.             Eigen::Matrix4f currPose = eFusion.getCurrPose();  
  69.             pose.push_back(currPose);  
  70.             cout << "current pose is : " << endl<<currPose << endl;  
  71.         }  
  72.         cout << "Processing frames done." << endl<<endl;  
  73.         cout<<"Saving Elastic-Fusion model..."<<endl;  
  74.         cout<<"Saving Elastic-Fusion model done"<<endl<<endl;  
  75.   
  76.     /*  
  77.      //查看处理的结果  
  78.   
  79.      int time = eFusion.getTick();//查看此时eFusion的系统时间  
  80.      cout<<"time : "<<time<<endl;  
  81.   
  82.      Ferns keyfern = eFusion.getFerns();//关键帧dataset  
  83.   
  84.      int ld_num = eFusion.getDeforms();//局部deformations的数量  
  85.      Deformation ld = eFusion.getLocalDeformation();//局部deformation图  
  86.   
  87.      int gd_num = eFusion.getFernDeforms();//全局deformations的数量  
  88.      GlobalModel gm = eFusion.getGlobalModel();//全局deformation model:  
  89.   
  90.      int CloudPoint_num = eFusion.globalModel.lastCount(); //点云的点数量  
  91.      Eigen::Vector4f * mapData = eFusion.globalModel.downloadMap(); //点云图  
  92.      for (unsigned int i = 0; i < CloudPoint_num; i++) {  
  93.      Eigen::Vector4f pos = mapData[(i * 3) + 0];  
  94.      if (pos[3] > eFusion.confidenceThreshold) {  
  95.      //这是个有效的顶点,validCount++;  
  96.      }  
  97.      }//调用点云中的每一个点  
  98.      */  
  99.   
  100.     cout << "saving cloud points..." << endl;  
  101.     eFusion.savePly();           //保存当前的点云图至ply  
  102.     cout << "cloud point has saved to " << savefilename << ".ply" << endl;  
  103.   
  104.     return 0;  
  105. }  
  106.   
  107. FRAME readFrame(int index, std::string filedir) {  
  108.     FRAME f;  
  109.     // 文件目录  
  110.     string rgbDir = filedir + "rgb/";  
  111.     string depthDir = filedir + "depth/";  
  112.     // 文件后缀  
  113.     string rgbExt = ".png";  
  114.     string depthExt = ".png";  
  115.     stringstream ss;  
  116.     // 读rgb图  
  117.     ss << rgbDir << index << rgbExt;  
  118.     string filename;  
  119.     ss >> filename;  
  120.     f.rgb_mat = cv::imread(filename);  
  121.     f.rgb = f.rgb_mat.data;  
  122.     // 读depth图  
  123.     ss.clear();  
  124.     filename.clear();  
  125.     ss << depthDir << index << depthExt;  
  126.     ss >> filename;  
  127.     f.dep_mat = cv::imread(filename, -1);  
  128.     f.dep = (unsigned short*) f.dep_mat.data;  
  129.     f.frameID = index;  
  130.   
  131.     return f;  
  132. }   









评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值