Ubuntu18.04下安装COLMAP
Ubuntu18.04下安装COLMAP
背景
最近在做NeRF⽅⾯的研究,看到了DS-NeRF,感觉挺适合作为baseline进⾏改进,所以跑了⼀下源码。试了⼀下官⽅的数据没有问题。接着就想试⼀试⾃⼰的数据集。根据官⽅⽂档,要⽤⾃⼰的数据集的话需要⽤到COLMAP⽣成相机数据。所以开始了我的安(cai)装(keng)之路
附上DS-NeRF的GitHub:
Centos安装踩的坑
⾸先检查gcc版本运⾏gcc -v
gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/5.4.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../configure -enable-checking=release -enable-languages=c,c++ -disable-multilib
Thread model: posix
gcc version 5.4.0 (GCC)
gcc版本是5.4.0,⽀持c++11,满⾜要求
然后检查cmake版本运⾏cmake -version
cmake -version
cmake version 3.17.0-rc3
CMake suite maintained and supported by Kitware (kitware/cmake).
博客中推荐boost版本为1.58/1.66
本机器原版本为1.53,稳妥起见,更新到1.58
参考:
其他依赖也都装上:
sudo yum install
gflags-devel
glog-devel
ubuntu安装教程glew-devel
atlas
atlas-devel
lapack-devel
blas-devel
qt5-qtbase-devel
gflags和glog安装
Ubuntu18.04下安装
分析依赖
⾸先要弄清楚包之间的依赖关系,⽅便检查有⽆缺失。
通过对于colmap进⾏cmake的结果来看
-- 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 required Ceres dependency: Eigen version 3.3.4 in /usr/lib/cmake/eigen3
-- Found required Ceres dependency: glog
-- Found required Ceres dependency: gflags
-- Found Ceres version: 2.1.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAl
gebraLibrary, LAPACK, SuiteSparse, CXSparse, Schur Specializations, Multithreading]
-- Found Boost: /usr/include (found version "1.65.1") found components: program_options filesystem graph system unit_test_framework
-- Found Eigen3: /usr/include/eigen3 (Required is at least version "2.91.0")
-- Found Eigen
--  Includes : /usr/include/eigen3
-- Found FreeImage
--  Includes : /usr/include
--  Libraries : /usr/lib/x86_64-linux-gnu/libfreeimage.so
-- Found Metis
--  Includes : /usr/local/include
--  Libraries : /usr/local/lib/libmetis.a
-- Found Glog
--  Includes : /usr/include
--  Libraries : /usr/lib/x86_64-linux-gnu/libglog.so
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- Found Glew
--  Includes : /usr/include
--  Libraries : /usr/lib/x86_64-linux-gnu/libGLEW.so
-- Found Git: /usr/bin/git (found version "2.17.1")
-- Found CGAL
--  Includes : /usr//include
--  Libraries : /usr/lib/x86_64-linux-gnu/libCGAL.so.13.0.1
-
- Build type not specified, using Release
-- Enabling SIMD support
-- Enabling OpenMP support
-- Disabling interprocedural optimization
-- Autodetected CUDA architecture(s):  6.1 6.1
-- Enabling CUDA support (version: 10.2, archs: sm_61)
-- Disabling GUI support
-- Disabling OpenGL support
-- Disabling ccache support
-- Disabling profiling support
-- Enabling CGAL support
-
- Configuring done
-- Generating done
可见COLMAP的依赖为:CeresSolver、Boost、Eigen、FreeImage、Metis、Glog、OpenGL、Glew、CGAL、CUDA 这⼏个缺⼀不可
CeresSolver安装
iter      cost      cost_change  |gradient|  |step|    tr_ratio  tr_radius  ls_iter  iter_time  total_time
0  4.185660e+06    0.00e+00    1.09e+08  0.00e+00  0.00e+00  1.00e+04      0    7.59e-02    3.37e-01
1  1.062590e+05    4.08e+06    8.99e+06  5.36e+0
2  9.82e-01  3.00e+04      1    1.65e-01    5.03e-01
2  4.992817e+04    5.63e+04    8.32e+06  3.19e+02  6.52e-01  3.09e+04      1    1.45e-01    6.48e-01
3  1.899774e+0
4    3.09e+04    1.60e+06  1.24e+02  9.77e-01  9.26e+04      1    1.43e-01    7.92e-01
4  1.808729e+04    9.10e+02    3.97e+0
5  6.39e+01  9.51e-01  2.78e+05      1    1.45e-01    9.36e-01
5  1.803399e+04    5.33e+01    1.48e+04  1.23e+01  9.99e-01  8.33e+05      1    1.45e-01    1.08e+00
6  1.803390e+04    9.02e-02    6.35e+01  8.00e-01  1.00e+00  2.50e+06      1    1.50e-01    1.23e+00
Ceres Solver v2.0.0 Solve Report
----------------------------------
Original                  Reduced
Parameter blocks                        22122                    22122
Parameters                              66462                    66462
Residual blocks                        83718                    83718
Residual                              167436                  167436
Minimizer                        TRUST_REGION
Dense linear algebra library            EIGEN
Trust region strategy    LEVENBERG_MARQUARDT
Given                    Used
Linear solver                    DENSE_SCHUR              DENSE_SCHUR
Threads                                    1                        1
Linear solver threads                      1                        1
Linear solver ordering              AUTOMATIC                22106, 16
Cost:
Initial                          4.185660e+06
Final                            1.803390e+04
Change                          4.167626e+06
Minimizer iterations                        6
Successful steps                            6
Unsuccessful steps                          0
Time (in seconds):
Preprocessor                            0.261
Residual evaluation                  0.082
Jacobian evaluation                  0.412
Linear solver                        0.442
Minimizer                              1.051
Postprocessor                          0.002
Total                                  1.357
Termination:                      CONVERGENCE (Function tolerance reached. |cost_change|/cost: 1.769766e-09 <= 1.000000e-06)
安装metis
安装OPENGL、CUDA、FreeImage
没什么好说的
安装Qt5
qmake -v
QMake version 3.1
Using Qt version 5.15.2 in /usr/local/Qt-5.15.2/lib
测试COLMAP是否成功
由于没有图像化界⾯,咱们采⽤命令⾏测试
附上教程:
先scp传点图⽚然后运⾏命令:
colmap feature_extractor --database_path ./database.db --image_path ../images
============================================================================== Feature extraction
==============================================================================
Processed file [1/34]
Name:            IMG_2962.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.472
Features:        9061
Processed file [2/34]
Name:            IMG_2963.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.472
Features:        9016
Processed file [3/34]
Name:            IMG_2964.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.472
Features:        9405
Processed file [4/34]
Name:            IMG_2965.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.472
Features:        9525
Processed file [5/34]
Name:            IMG_2966.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.470
Features:        9300
Processed file [6/34]
Name:            IMG_2967.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.470
Features:        9278
Processed file [7/34]
Name:            IMG_2968.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.469
Features:        9345
Features:        9345
Processed file [8/34]
Name:            IMG_2969.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.468  Features:        9073
Processed file [9/34]
Name:            IMG_2970.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.465  Features:        8911
Processed file [10/34]
Name:            IMG_2971.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.463  Features:        8901
Processed file [11/34]
Name:            IMG_2972.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.462  Features:        8737
Processed file [12/34]
Name:            IMG_2973.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.462  Features:        8944
Processed file [13/34]
Name:            IMG_2974.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.458  Features:        9301
Processed file [14/34]
Name:            IMG_2975.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.456  Features:        9450
Processed file [15/34]
Name:            IMG_2976.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.456  Features:        9593
Processed file [16/34]
Name:            IMG_2977.JPG
Dimensions:      4032 x 3024
Camera:          #1 - SIMPLE_RADIAL
Focal Length:    3225.60px (Prior)
GPS:            LAT=37.874, LON=-122.238, ALT=215.445  Features:        9410
Processed file [17/34]
Name:            IMG_2978.JPG