linux + colmap 错误汇总

安装教程

官网教程:Installation — COLMAP 3.7 documentation

别人翻译:三维重建_COLMAP安装、使用和参数说明(翻译自官方文档)_一步一脚印-CSDN博客_colmap安装

错误汇总

1、git clone https://ceres-solver.googlesource.com/ceres-solver Cloning into 'ceres-solver'...
fatal: unable to access 'https://ceres-solver.googlesource.com/ceres-solver/': Failed to connect to 127.0.0.1 port 1080: Connection refused

解决方法:自己下载 ceres-solver

Download the package via the cmd:
wget http://ceres-solver.org/ceres-solver-1.9.0.tar.gz
and install it from source.

2、qt.qpa.screen: QXcbConnection: Could not connect to display Could not connect

首先

vim ~/.bashrc

然后把下面的这句话加进去,第一行就可以

export QT_QPA_PLATFORM='offscreen'

运行如下命令使配置生效

source ~/.bashrc

再次运行colmap gui,

GUI是用不了 用终端操作吧: 三维重建_COLMAP安装、使用和参数说明(翻译自官方文档)_一步一脚印-CSDN博客_colmap安装

3、改了一二天的错误

Describe the bug
CMakeOutput:
-- Found installed version of Eigen: /usr/lib/cmake/eigen3
-- Found required Ceres dependency: Eigen version 3.2.92 in /usr/include/eigen3
-- Found required Ceres dependency: glog
-- Found required Ceres dependency: gflags
-- Found Ceres version: 2.0.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, CXSparse, SchurSpecializations]
-- Boost version: 1.58.0
-- Found the following Boost libraries:
-- program_options
-- filesystem
-- graph
-- regex
-- system
-- unit_test_framework
-- Found Eigen
-- Includes : /usr/include/eigen3
-- Found FreeImage
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libfreeimage.so
-- Found Glog
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libglog.so
-- Found Glew
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libGLEW.so
-- Found Qt
-- Module : /usr/lib/x86_64-linux-gnu/cmake/Qt5Core
-- Module : /usr/lib/x86_64-linux-gnu/cmake/Qt5OpenGL
-- Module : /usr/lib/x86_64-linux-gnu/cmake/Qt5Widgets
-- Found CGAL
-- Includes : /usr/include
-- Libraries : /usr/lib/x86_64-linux-gnu/libCGAL.so.11.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 6.1
-- Enabling CUDA support (version: 9.0, archs: sm_61)
-- Enabling OpenGL support
-- Disabling profiling support
-- Enabling CGAL support
-- Configuring done
-- Generating done

Build error with linking:

Scanning dependencies of target colmap
[ 58%] Building CXX object src/CMakeFiles/colmap.dir/util/bitmap.cc.o
[ 58%] Linking CXX static library libcolmap.a
[ 98%] Built target colmap
[100%] Linking CXX executable colmap
../libcolmap.a(bitmap.cc.o): In function char const* boost::re_detail::re_is_set_member<char const*, char, boost::regex_traits<char, boost::cpp_regex_traits<char> >, unsigned int>(char const*, char const*, boost::re_detail::re_set_long<unsigned int> const*, boost::re_detail::regex_data<char, boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, bool)': bitmap.cc:(.text._ZN5boost9re_detail16re_is_set_memberIPKccNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_S8_S8_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb[_ZN5boost9re_detail16re_is_set_memberIPKccNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_S8_S8_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb]+0x145): undefined reference to boost::re_detail::cpp_regex_traits_implementation::transform_primary[abi:cxx11](char const*, char const*) const'
bitmap.cc:(.text._ZN5boost9re_detail16re_is_set_memberIPKccNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_S8_S8_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb[_ZN5boost9re_detail16re_is_set_memberIPKccNS_12regex_traitsIcNS_16cpp_regex_traitsIcEEEEjEET_S8_S8_PKNS0_11re_set_longIT2_EERKNS0_10regex_dataIT0_T1_EEb]+0x4a1): undefined reference to `boost::re_detail::cpp_regex_traits_implementation::transform[abi:cxx11](char const*, char const*) const'
collect2: error: ld returned 1 exit status
src/exe/CMakeFiles/colmap_exe.dir/build.make:143: recipe for target 'src/exe/colmap' failed
make[2]: *** [src/exe/colmap] Error 1
CMakeFiles/Makefile2:1184: recipe for target 'src/exe/CMakeFiles/colmap_exe.dir/all' failed
make[1]: *** [src/exe/CMakeFiles/colmap_exe.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

result:

I could finally solve it with cuda 9.0, gcc version 6 and boost version 1.58.0.
I was able to compile by removing the boost/regex dependency (I just replaced every boost:: for std:: in the bitmap.cc file, similar to what is suggested in this issue (#36), and removing the regex dependency in the CMakeLists.txt.

Here is what I did according to @BertaBescos 's comments to make it to compile:
(I have to replace boost::cmatch with std::cmatch too)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ffda4d..d6effb0 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -90,7 +90,6 @@ find_package(Boost REQUIRED COMPONENTS
              program_options
              filesystem
              graph
-             regex
              system
              unit_test_framework)
 
diff --git a/src/util/bitmap.cc b/src/util/bitmap.cc
index f59a22f..87bb533 100755
--- a/src/util/bitmap.cc
+++ b/src/util/bitmap.cc
@@ -34,7 +34,7 @@
 #include <unordered_map>
 
 #include <boost/filesystem/operations.hpp>
-#include <boost/regex.hpp>
+#include <regex>
 
 #include "base/camera_database.h"
 #include "VLFeat/imopv.h"
@@ -291,9 +291,9 @@ bool Bitmap::ExifFocalLength(double* focal_length) const {
   std::string focal_length_35mm_str;
   if (ReadExifTag(FIMD_EXIF_EXIF, "FocalLengthIn35mmFilm",
                   &focal_length_35mm_str)) {
-    const boost::regex regex(".*?([0-9.]+).*?mm.*?");
-    boost::cmatch result;
-    if (boost::regex_search(focal_length_35mm_str.c_str(), result, regex)) {
+    const std::regex regex(".*?([0-9.]+).*?mm.*?");
+    std::cmatch result;
+    if (std::regex_search(focal_length_35mm_str.c_str(), result, regex)) {
       const double focal_length_35 = std::stold(result[1]);
       if (focal_length_35 > 0) {
         *focal_length = focal_length_35 / 35.0 * max_size;
@@ -308,9 +308,9 @@ bool Bitmap::ExifFocalLength(double* focal_length) const {
 
   std::string focal_length_str;
   if (ReadExifTag(FIMD_EXIF_EXIF, "FocalLength", &focal_length_str)) {
-    boost::regex regex(".*?([0-9.]+).*?mm");
-    boost::cmatch result;
-    if (boost::regex_search(focal_length_str.c_str(), result, regex)) {
+    std::regex regex(".*?([0-9.]+).*?mm");
+    std::cmatch result;
+    if (std::regex_search(focal_length_str.c_str(), result, regex)) {
       const double focal_length_mm = std::stold(result[1]);
 
       // Lookup sensor width in database.
@@ -334,11 +334,11 @@ bool Bitmap::ExifFocalLength(double* focal_length) const {
           ReadExifTag(FIMD_EXIF_EXIF, "FocalPlaneXResolution", &x_res_str) &&
           ReadExifTag(FIMD_EXIF_EXIF, "FocalPlaneResolutionUnit",
                       &res_unit_str)) {
-        regex = boost::regex(".*?([0-9.]+).*?");
-        if (boost::regex_search(pixel_x_dim_str.c_str(), result, regex)) {
+        regex = std::regex(".*?([0-9.]+).*?");
+        if (std::regex_search(pixel_x_dim_str.c_str(), result, regex)) {
           const double pixel_x_dim = std::stold(result[1]);
-          regex = boost::regex(".*?([0-9.]+).*?/.*?([0-9.]+).*?");
-          if (boost::regex_search(x_res_str.c_str(), result, regex)) {
+          regex = std::regex(".*?([0-9.]+).*?/.*?([0-9.]+).*?");
+          if (std::regex_search(x_res_str.c_str(), result, regex)) {
             const double x_res = std::stold(result[2]) / std::stold(result[1]);
             // Use PixelXDimension instead of actual width of image, since
             // the image might have been resized, but the EXIF data preserved.
@@ -364,9 +364,9 @@ bool Bitmap::ExifFocalLength(double* focal_length) const {
 bool Bitmap::ExifLatitude(double* latitude) const {
   std::string str;
   if (ReadExifTag(FIMD_EXIF_GPS, "GPSLatitude", &str)) {
-    const boost::regex regex(".*?([0-9.]+):([0-9.]+):([0-9.]+).*?");
-    boost::cmatch result;
-    if (boost::regex_search(str.c_str(), result, regex)) {
+    const std::regex regex(".*?([0-9.]+):([0-9.]+):([0-9.]+).*?");
+    std::cmatch result;
+    if (std::regex_search(str.c_str(), result, regex)) {
       const double hours = std::stold(result[1]);
       const double minutes = std::stold(result[2]);
       const double seconds = std::stold(result[3]);
@@ -380,9 +380,9 @@ bool Bitmap::ExifLatitude(double* latitude) const {
 bool Bitmap::ExifLongitude(double* longitude) const {
   std::string str;
   if (ReadExifTag(FIMD_EXIF_GPS, "GPSLongitude", &str)) {
-    const boost::regex regex(".*?([0-9.]+):([0-9.]+):([0-9.]+).*?");
-    boost::cmatch result;
-    if (boost::regex_search(str.c_str(), result, regex)) {
+    const std::regex regex(".*?([0-9.]+):([0-9.]+):([0-9.]+).*?");
+    std::cmatch result;
+    if (std::regex_search(str.c_str(), result, regex)) {
       const double hours = std::stold(result[1]);
       const double minutes = std::stold(result[2]);
       const double seconds = std::stold(result[3]);
@@ -396,9 +396,9 @@ bool Bitmap::ExifLongitude(double* longitude) const {
 bool Bitmap::ExifAltitude(double* altitude) const {
   std::string str;
   if (ReadExifTag(FIMD_EXIF_GPS, "GPSAltitude", &str)) {
-    const boost::regex regex(".*?([0-9.]+).*?/.*?([0-9.]+).*?");
-    boost::cmatch result;
-    if (boost::regex_search(str.c_str(), result, regex)) {
+    const std::regex regex(".*?([0-9.]+).*?/.*?([0-9.]+).*?");
+    std::cmatch result;
+    if (std::regex_search(str.c_str(), result, regex)) {
       *altitude = std::stold(result[1]) / std::stold(result[2]);
       return true;
     }

### COLMAP的下载与安装 #### 下载Colmap官方程序 为了获取最新的稳定版或开发版COLMAP,可以从GitHub仓库克隆源码。推荐使用Git命令来保持更新方便[^1]。 ```bash git clone https://github.com/colmap/colmap.git --recursive ``` #### 安装依赖库 在编译COLMAP前,需确保已安装所有必需的依赖项。这通常涉及CMake、Boost库、FLANN库以及其他一些辅助工具和库。具体可以通过包管理器apt-get来进行安装[^2]: ```bash sudo apt-get update sudo apt-get install cmake git libboost-all-dev libsuitesparse-dev \ libcgal-dev libvcglib-dev qtbase5-dev python3-sphinx \ libgoogle-glog-dev libprotobuf-dev protobuf-compiler ``` 如果计划利用GPU加速,则还需要额外安装NVIDIA驱动及相关CUDA组件。注意版本兼容性问题;例如,在描述的情况下,使用的NVIDIA驱动版本为430.64而CUDA版本是10.1[^4]。 #### 编译COLMAP 进入解压后的文件夹后执行如下命令进行构建。建议创建一个独立于源代码树之外的build目录用于存放编译产物,这样做有助于维护项目的整洁度。 ```bash mkdir build cd build cmake .. make -j$(nproc) ``` 上述`-j$(nproc)`参数可以让编译过程尽可能高效地利用CPU核心数加快速度。 #### 验证安装成功与否 一旦编译完成,可以尝试运行简单的测试用例验证是否一切正常工作。一般情况下,会在终端输入`colmap`查看是否有帮助信息返回作为初步确认手段。 ```bash colmap --help ``` 通过以上步骤应该能够在Linux环境下顺利部署好COLMAP环境,并为进一步探索三维重建技术打下坚实基础。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值