和大家分享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
以下是安装过程:
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上装了,实在太费时间精力了
更新:ceres-solver切换版本:
点开ceres仓库ceres-solver,进入的是master分支,点击master,在Branches旁边有个Tags,点击Tags,选中2.0.0即可
所以切换成功,然后点击Code,然后git clone下来就行了