最近项目需要进行点云地图的相关处理,因此在测试机上安装了colmap。记录一下安装过程和其中的一些坑如何解决。
机型:2020 MacBookPro (M1)
系统:macOS 12.6.3
colmap官网安装手册
https://colmap.github.io/install.html#id2
- 安装homebrew
过程略 - 安装依赖
brew install \
git \
cmake \
boost \
eigen \
freeimage \
flann \
glog \
gflags \
metis \
suite-sparse \
ceres-solver \
qt5 \
glew \
cgal \
sqlite3
外网下载时间较长,请耐心等待。
- 源码编译安装colmap
git clone https://github.com/colmap/colmap.git
cd colmap
git checkout dev
mkdir build
cd build
cmake .. -DQt5_DIR=/opt/homebrew/opt/qt@5/lib/cmake/Qt5
make
sudo make install
可能遇到的问题:
- 其中cmake后跟的DQt5_DIR,需要根据实际安装路径指定。本地安装时我修改为了:
cmake .. -DQt5_DIR=/usr/local/Cellar/qt@5/5.15.8_1/lib/cmake/Qt5
- 编译时可能会报错:
CMake Error at /usr/local/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:15 (message): The imported target "Qt5::Core" references the file "/usr/local/.//mkspecs/macx-clang" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/local/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake" but not all the files it references.
查阅了github的Qt5项目,发现一个issue:
https://github.com/Homebrew/homebrew/issues/29938vi /usr/local/lib/cmake/Qt5Core/Qt5CoreConfig.cmake 找到此处: get_filename_component(_qt5Core_install_prefix "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE) 修改为: get_filename_component(_qt5Core_install_prefix "${CMAKE_CURRENT_LIST_DIR}/../../../Cellar/qt@5/5.15.8_1/" ABSOLUTE)
再次执行cmake后报错消失。
全部安装完毕后,执行colmap gui
即可图形化运行colmap。