0. 需求

  • 修改meshroom未修改稠密点云的输出格式,需要在alicevision项目编译前修改代码
    • AliceVision/src/software/pipeline# vim main_meshing.cpp

      if(saveRawDensePointCloud)
      {
        ALICEVISION_LOG_INFO("Save dense point cloud before cut and filtering.");
        StaticVector<StaticVector<int>> ptsCams;
        delaunayGC.createPtsCams(ptsCams);
        sfmData::SfMData densePointCloud;
        createDenseSfMData(sfmData, mp, delaunayGC._verticesCoords, ptsCams, densePointCloud);
        removeLandmarksWithoutObservations(densePointCloud);
        if(colorizeOutput)
          sfmData::colorizeTracks(densePointCloud);
        sfmDataIO::Save(densePointCloud, (outDirectory/"densePointCloud_raw.abc").string(), sfmDataIO::ESfMData::ALL_DENSE);
      }
      
      // 修改 densePointCloud_raw.abc -> densePointCloud_raw.ply
      

1. Nvidia docker安装AliceVision

  • host克隆alicevision项目
git clone --recursive https://github.com/alicevision/AliceVision.git
cd AliceVision/ && git checkout v2.4.0
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DALICEVISION_USE_ALEMBIC=ON ..
  • 装组件
  1. 参考AliceVision/CMakeLists.txt获得各组件的版本
  2. 下载编译或apt-get安装

-- Boost 1_76 found. 编译
-- OpenEXR found. (Version 2.5.8) 编译
	可选: libjpeg-turbo-2.1.1 编译
-- OpenImageIO found. 
	apt-get install libopenimageio-dev
-- eigen3 3.4.0 编译(可选)
-- git clone ceres-solver 编译
	apt-get install libgoogle-glog-dev libgflags-dev libatlas-base-dev libeigen3-dev libsuitesparse-dev
	apt-get install libmetis-dev liblapack-dev libcxsparse3 libgflags-dev libgtest-dev
-- geogram-1.7.6 编译
	apt-get install libxinerama-dev libxcursor-dev
	apt-get install libglfw3 libglfw3-dev xlibmesa-glu-dev
	# https://stackoverflow.com/questions/8321628/compiling-error-cannot-find-lglu-and-lgl-in-kubuntu-linux
-- alembic 编译
	apt-get install zlib1g-dev
  • make 编译
    • 出现error,修改问题部分
  • make install

2. AliceVision docker安装AliceVision

  • 下载docker image

    docker pull alicevision/alicevision-deps:cuda10.2-ubuntu18.04
    
  • 克隆项目

    git clone --recursive https://github.com/alicevision/AliceVision.git
    cd AliceVision/ && git checkout v2.4.0
    mkdir build && cd build
    
  • 安装依赖, 参考AliceVision/CMakeLists.txt获得各组件的版本

    -- zlib 1.2.11 编译
    
  • 编译项目

    export AV_DEV=/opt/AliceVision_git && \
    export AV_INSTALL=/opt/AliceVision_install && \
    cmake -DCMAKE_BUILD_TYPE=Release -DALICEVISION_USE_ALEMBIC=ON \
     -DOPENIMAGEIO_LIBRARY_DIR_HINTS:PATH=/opt/AliceVision_install/lib/ \
     -DOPENIMAGEIO_INCLUDE_DIR:PATH=/opt/AliceVision_install/include/ \
     -DOPENEXR_HOME:PATH=/opt/AliceVision_install/include/OpenEXR \
     -DGEOGRAM_INSTALL_PREFIX:PATH=/opt/AliceVision_install/lib \
     -DGEOGRAM_INCLUDE_DIR:PATH=/opt/AliceVision_install/include/geogram1 \
     ..
    
  • make 编译

    • 出现error,修改问题部分
  • make install

3. 结果

  • 用meshroom的cache测试结果,获得raw dense point cloud.ply文件。

    aliceVision_meshing --input /dataset/algorithm/xxx/meshroom_save/06_03_meshroom_cache_result/MeshroomCache_dtu_images_scan12_sift/StructureFromMotion/ab427438bb1653cf7294c95b53293706552114b5/sfm.abc \
    --depthMapsFolder /dataset/algorithm/xxx/meshroom_save/06_03_meshroom_cache_result/MeshroomCache_dtu_images_scan12_sift/DepthMapFilter/3cf9ff40f09181afd9e7f29a2b0d2f0b876571c8/ \
    --estimateSpaceFromSfM True --estimateSpaceMinObservations 3 --estimateSpaceMinObservationAngle 10 --maxInputPoints 50000000 --maxPoints 5000000 --maxPointsPerVoxel 1000000 --minStep 2 \
    --partitioning singleBlock --repartition multiResolution --angleFactor 15.0 --simFactor 15.0 --pixSizeMarginInitCoef 2.0 --pixSizeMarginFinalCoef 4.0 --voteMarginFactor 4.0 \
    --contributeMarginFactor 2.0 --simGaussianSizeInit 10.0 --simGaussianSize 10.0 --minAngleThreshold 1.0 --refineFuse True --helperPointsGridSize 10 --nPixelSizeBehind 4.0 --fullWeight 1.0 \
    --voteFilteringForWeaklySupportedSurfaces True --addLandmarksToTheDensePointCloud False --invertTetrahedronBasedOnNeighborsNbIterations 10 --minSolidAngleRatio 0.2 \
    --nbSolidAngleFilteringIterations 2 --colorizeOutput False --maxNbConnectedHelperPoints 50 --saveRawDensePointCloud True --exportDebugTetrahedralization False --seed 0 --verboseLevel info \
    --outputMesh /root/output/MeshroomCache_dtu_images_scan12_sift/mesh.obj --output /root/output/MeshroomCache_dtu_images_scan12_sift/densePointCloud.ply
    
  • 上面两种方式都可以在--colorizeOutput False 的时候生成未过滤的稠密点云,但是数量小于10w(其他项目生成的稠密点云在100w以上),使用--colorizeOutput True 会报错:

    • 报错

      方法1报错:
      Compute scene structure color
      0%   10   20   30   40   50   60   70   80   90   100%
      |----|----|----|----|----|----|----|----|----|----|
      Abnormal program termination: function terminate() was called
      aliceVision_meshing: /build/openimageio-l3oG0b/openimageio-2.1.12.0~dfsg0/src/include/OpenImageIO/unordered_map_concurrent.h:434: OpenImageIO_v2_1::unordered_map_concurrent<KEY, VALUE, HASH, PRED, BINS, BINMAP>::Bin::~Bin() [with KEY = OpenImageIO_v2_1::ustring; VALUE = OpenImageIO_v2_1::intrusive_ptr<OpenImageIO_v2_1::pvt::ImageCacheFile>; HASH = OpenImageIO_v2_1::ustringHash; PRED = std::equal_to<OpenImageIO_v2_1::ustring>; long unsigned int BINS = 64; BINMAP = tsl::robin_map<OpenImageIO_v2_1::ustring, OpenImageIO_v2_1::intrusive_ptr<OpenImageIO_v2_1::pvt::ImageCacheFile>, OpenImageIO_v2_1::ustringHash>]: Assertion `m_nlocks == 0' failed.
      ./run.sh: line 1:    27 Aborted                 (core dumped) aliceVision_meshing --input /dataset/algorithm/xxx/meshroom_save/06_03_meshroom_cache_result/MeshroomCache_dtu_images_scan12_sift/StructureFromMotion/ab427438bb1653cf7294c95b53293706552114b5/sfm.abc --depthMapsFolder /dataset/algorithm/xxx/meshroom_save/06_03_meshroom_cache_result/MeshroomCache_dtu_images_scan12_sift/DepthMapFilter/3cf9ff40f09181afd9e7f29a2b0d2f0b876571c8/ --estimateSpaceFromSfM True --estimateSpaceMinObservations 3 --estimateSpaceMinObservationAngle 10 --maxInputPoints 50000000 --maxPoints 5000000 --maxPointsPerVoxel 1000000 --minStep 2 --partitioning singleBlock --repartition multiResolution --angleFactor 15.0 --simFactor 15.0 --pixSizeMarginInitCoef 2.0 --pixSizeMarginFinalCoef 4.0 --voteMarginFactor 4.0 --contributeMarginFactor 2.0 --simGaussianSizeInit 10.0 --simGaussianSize 10.0 --minAngleThreshold 1.0 --refineFuse True --helperPointsGridSize 10 --nPixelSizeBehind 4.0 --fullWeight 1.0 --voteFilteringForWeaklySupportedSurfaces True --addLandmarksToTheDensePointCloud False --invertTetrahedronBasedOnNeighborsNbIterations 10 --minSolidAngleRatio 0.2 --nbSolidAngleFilteringIterations 2 --colorizeOutput True --maxNbConnectedHelperPoints 50 --saveRawDensePointCloud True --exportDebugTetrahedralization False --seed 0 --verboseLevel info --outputMesh /root/output/MeshroomCache_dtu_images_scan12_sift/mesh.obj --output /root/output/MeshroomCache_dtu_images_scan12_sift/densePointCloud.ply
      
      方法2报错:
      Compute scene structure color
      0%   10   20   30   40   50   60   70   80   90   100%
      |----|----|----|----|----|----|----|----|----|----|
      Abnormal program termination: function terminate() was called
      Abnormal program termination: received signal 11 (Segmentation fault)