最近在做NeRF方面的研究,看到了DS-NeRF,感觉挺适合作为baseline进行改进,所以跑了一下源码。试了一下官方的数据,没有问题。接着就想试一试自己的数据集。根据官方文档,要用自己的数据集的话需要用到COLMAP生成相机数据。所以开始了我的安(cai)装(keng)之路
附上DS-NeRF的GitHub:传送门
最开始网上搜了一篇教程:传送门https://blog.csdn.net/X_kh_2001/article/details/82591978
是基于ubuntu安装的,但是因为经常使用的机器是Centos,我就不信邪,同样都是linux系统,安装起来应该差不多。然后就开始借鉴centos安装的教程。也附上:传送门
https://blog.csdn.net/weixin_42252533/article/details/119143305
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 -version
cmake version 3.17.0-rc3
CMake suite maintained and supported by Kitware (kitware.com/cmake).
博客中推荐boost版本为1.58/1.66
本机器原版本为1.53,稳妥起见,更新到1.58
参考:传送门
其他依赖也都装上:
sudo yum install
gflags-devel
glog-devel
glew-devel
atlas
atlas-devel
lapack-devel
blas-devel
qt5-qtbase-devel
这是两个大坑,首先两者的安装顺序很重要,据说要先安装glog然后再安装gflags。原因我也没有整明白。
gflags我在安装的时候十分顺利,test也是全部通过,但是后面还是报错。glog安装的时候,务必注意,不要去官方的git下去clone,会缺少autogen.sh和configure文件。选用这个仓库:传送门https://github.com/boboxxd/glog
首先要弄清楚包之间的依赖关系,方便检查有无缺失。
通过对于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, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, CXSparse, SchurSpecializations, 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
这几个缺一不可
在ubuntu上比centos上容易的关键我感觉就在于CeresSolver安装
因为CeresSolver官方给的linux安装教程就是基于ubuntu18.04的,所以按着教程来一路绿灯,不像在centos上面一样,都需要源码编译,处处踩坑。附上官方教程:传送门
http://ceres-solver.org/installation.html
安装CeresSolver的时候,Boost
安装完之后务必跑一下test测试一下有没有什么错误,要是无误会得到以下结果:
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+02 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+04 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+05 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)
很多教程都会忽略这个包,我在最后安装的时候根据报错才发现。
没有啥坑,根据教程来就好:传送门
https://blog.csdn.net/weixin_45858597/article/details/110845874
没什么好说的
最麻烦的一个步骤,问题也贼多。
由于没有图形化界面,所以全程使用命令行安装。
附上保姆级教程:传送门
在./configure -xcb的时候可能会报错,原因是依赖包不全。可以搜一下问题,是普遍存在的。可以参考这两个链接解决办法:
1:https://blog.csdn.net/markey1/article/details/119392028
2:https://www.itdaan.com/blog/2014/09/13/3c5b25a0d1f7864d7995a93d8ba143e6.html
其中编译过程较慢,需要等待2~3小时
判断是否成功可以检验一下:
qmake -v
QMake version 3.1
Using Qt version 5.15.2 in /usr/local/Qt-5.15.2/lib
由于没有图像化界面,咱们采用命令行测试
附上教程:传送门
先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
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
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.441
Features: 9206
Processed file [18/34]
Name: IMG_2979.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.440
Features: 9288
Processed file [19/34]
Name: IMG_2980.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.440
Features: 9761
Processed file [20/34]
Name: IMG_2981.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.438
Features: 9460
Processed file [21/34]
Name: IMG_2982.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.438
Features: 9674
Processed file [22/34]
Name: IMG_2983.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.433
Features: 9501
Processed file [23/34]
Name: IMG_2984.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.433
Features: 9335
Processed file [24/34]
Name: IMG_2985.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.433
Features: 9227
Processed file [25/34]
Name: IMG_2986.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.434
Features: 8774
Processed file [26/34]
Name: IMG_2987.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.437
Features: 8747
Processed file [27/34]
Name: IMG_2988.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.436
Features: 8777
Processed file [28/34]
Name: IMG_2989.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.436
Features: 9070
Processed file [29/34]
Name: IMG_2990.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.430
Features: 9425
Processed file [30/34]
Name: IMG_2991.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.428
Features: 9198
Processed file [31/34]
Name: IMG_2992.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.428
Features: 9156
Processed file [32/34]
Name: IMG_2993.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.420
Features: 9518
Processed file [33/34]
Name: IMG_2994.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.420
Features: 9380
Processed file [34/34]
Name: IMG_2995.JPG
Dimensions: 4032 x 3024
Camera: #1 - SIMPLE_RADIAL
Focal Length: 3225.60px (Prior)
GPS: LAT=37.874, LON=-122.238, ALT=215.421
Features: 9292
Elapsed time: 0.089 [minutes]
可以看出特征提取成功,COLMAP安装成功!!!完结撒花
1、配置环境还是得有耐心,由于之前Linux操作不够熟练,对于cmake不够熟悉,踩了太多坑,浪费了三四天时间,以至于被导师认为在摸鱼。但是还是得坚持,毕竟是后面项目的基础,硬骨头也一定得啃下来。
2、碰到问题要多搜索多思考,看着别人的教程,不仅要照着做,也要弄懂为啥这样,知其然也要知其所以然,这样才能解决问题,不然问题只会一个接一个。
3、虽然浪费了很多时间,但是也让自己对于Linux系统更加熟悉了,也对与cmake有了些许浅薄了解,也是很有收获的。