才安装了Ubuntu新系统,从零开始安装colmap
1.依赖项安装
(1)ceres安装
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3.1.2 libgflags-dev libgoogle-glog-dev libgtest-dev git
sudo apt-get install libeigen3-dev
其中libcxsparse3.1.2有可能提示错误,试试libcxsparse3.1.4或者参考https://www.cnblogs.com/qilai/p/13654810.html,具体如下:
//第一步,打开sources.list
sudo gedit /etc/apt/sources.list
//第二步,将下面的源粘贴到最上方sources.list
deb http://cz.archive.ubuntu.com/ubuntu trusty main universe
//第三步,更新源
sudo apt-get update
//第四步,重新输入依赖项安装命令安装依赖项
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3.1.2 libgflags-dev libgoogle-glog-dev libgtest-dev
下载ceres,链接为https://github.com/ceres-solver/ceres-solver/tree/2.0.0
解压以后
cd ceres-solver-2.0.0 (这里下载的是2.0版本的)
mkdir build
cd build
cmake ..
make
sudo make install
(2)boost安装,Ubuntu可以直接命令行
sudo apt-get install libboost-dev
sudo apt-get install libboost-program-options-dev
sudo apt-get install libboost-filesystem-dev
sudo apt-get install libboost-graph-dev
(3)freeimage
sudo apt-get install libfreeimage-dev
(4)openGL
sudo apt-get install build-essential libgl1-mesa-dev
sudo apt-get install freeglut3-dev
sudo apt-get install libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev
(5)Qt5
sudo apt-get install cmake qt5-default qtcreator
2.colmap安装
下载链接:https://github.com/colmap/colmap/tree/3.6,这里下载的版本是3.6,版本选择如下方式
安装,解压以后步骤如下:
cd ./colmap-3.6 # 进入colmap目录
mkdir build && cd ./build # 创建build文件夹,并进入
cmake .. # cmake
make -j8 # make多线程编译
sudo make install
3.colmap使用
参考链接:https://www.cnblogs.com/Todd-Qi/p/10792685.html
https://blog.csdn.net/X_kh_2001/article/details/82591978
https://zhuanlan.zhihu.com/p/184978050
下面自己照做看效果
(1)自动创建,images应该在/home/saners/proj/3DRes/目录下,并且存在需要重建的图像
DATASET_PATH=/home/saners/proj/3DRes/
colmap automatic_reconstructor --workspace $DATASET_PATH --image_path $DATASET_PATH/images
(2)单步创建
//路径设置
DATASET_PATH=/home/saners/proj/3DRes/
//提取特征点
colmap feature_extractor --database_path $DATASET_PATH/database.db --image_path $DATASET_PATH/images
//特征点匹配
colmap exhaustive_matcher --database_path $DATASET_PATH/database.db
//建稀疏图
mkdir $DATASET_PATH/sparse
colmap mapper --database_path $DATASET_PATH/database.db --image_path $DATASET_PATH/images --output_path $DATASET_PATH/sparse
linux在虚拟机里,没有GPU不好创建,下面是Windows下的结果
//建稠密图
mkdir $DATASET_PATH/dense
//图像去畸变
colmap image_undistorter --image_path $DATASET_PATH/images --input_path $DATASET_PATH/sparse/0 --output_path $DATASET_PATH/dense --output_type COLMAP --max_image_size 200
//为建稠密图再匹配
colmap patch_match_stereo --workspace_path $DATASET_PATH/desne --workspace_format COLMAP --PatchMatchStereo.geom_consistency true
原图 深度图 法向量图
//开始建图
colmap stereo_fusion --workspace_path $DATASET_PATH/dense --workspace_format COLMAP --input_type geometric --output_path $DATASET_PATH/dense/fused.ply
建图结果
下面两步结果太大,这个软件看不了,推荐用matlab看
//poisson法建网格添加纹理
colmap poisson_mesher --input_path $DATASET_PATH/dense/ --output_path $DATASET_PATH/dense/meshed-poisson.ply
//delaunay法建网格添加纹理
colmap delaunay_mesher --input_path $DATASET_PATH/dense/fused.ply --output_path $DATASET_PATH/dense/meshed-delaunay.ply