跟大家分享一下colmap安装经历。colmap在windows上的安装至今未成功,无奈选择linux,我的系统版本是ubuntu18.04,安装经历给大家做一个参考。官方安装教程参考这里:官方文档
第一步和官方教程是一样的,apt-get命令安装依赖包:
sudo apt-get install \
git \
cmake \
build-essential \
libboost-program-options-dev \
libboost-filesystem-dev \
libboost-graph-dev \
libboost-system-dev \
libboost-test-dev \
libeigen3-dev \
libsuitesparse-dev \
libfreeimage-dev \
libmetis-dev \
libgoogle-glog-dev \
libgflags-dev \
libglew-dev \
qtbase5-dev \
libqt5opengl5-dev \
libcgal-dev \
libcgal-qt5-dev
如果这一步失败的话,检查网络情况,或者替换为国内源。(自行搜索linux如何更换国内源,这里不再赘述)
第二步,安装ceres-solver,但是按照官网教程安装的话,git无法访问到googlesource,因此我把googlesource的网址替换为github的网址,ceres-solver在github上的仓库地址:ceres-solver
但是注意,不能克隆这个仓库的master分支,而要手动切换到2.0分支或2.1分支,否则会导致安装失败!
以下是安装过程:
sudo apt-get install libatlas-base-dev libsuitesparse-dev
git clone https://github.com/ceres-solver/ceres-solver.git // 记得切换分支,不要装master分支,我装的是2.0版本的
cd ceres-solver
mkdir build
cd build
cmake .. -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF
make -j
sudo make install
然后把colmap克隆下来再安装就好了
git clone https://github.com/colmap/colmap
cd colmap
git checkout dev
mkdir build
cd build
cmake ..
make -j
sudo make install
验证是否安装成功:
colmap -h
colmap gui
验证能否调用colmap库:
新建一个hello_world.cc文件,写入如下内容:
#include <cstdlib>
#include <iostream>
#include <colmap/util/option_manager.h>
#include <colmap/util/string.h>
int main(int argc, char** argv) {
colmap::InitializeGlog(argv);
std::string input_path;
std::string output_path;
colmap::OptionManager options;
options.AddRequiredOption("input_path", &input_path);
options.AddRequiredOption("output_path", &output_path);
options.Parse(argc, argv);
std::cout << colmap::StringPrintf("Hello %s!", "COLMAP") << std::endl;
return EXIT_SUCCESS;
}
在hello_world.cc相同目录下新建一个CMakeLists.txt文件,写入如下内容:
cmake_minimum_required(VERSION 2.8.11)
project(TestProject)
find_package(COLMAP REQUIRED)
# or to require a specific version: find_package(COLMAP 3.4 REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include_directories(${COLMAP_INCLUDE_DIRS})
link_directories(${COLMAP_LINK_DIRS})
add_executable(hello_world hello_world.cc)
target_link_libraries(hello_world ${COLMAP_LIBRARIES})
然后执行:
cmake .
cmake --build .
可以看到当前目录下生成了一个名为hello_world的可执行文件。说明编译成功了,hello_world.cc成功调用了colmap中的函数。
linux安装还是很简单的,只要ceres-solver注意不要装master版本的就行了。至于windows,我至今没成功。。。还是建议大家不要在windows上装了,实在太费时间精力了