fontan commited on
Commit
744b072
·
1 Parent(s): 548923a

executables

Browse files
colmap_mapper.sh CHANGED
@@ -1,76 +1,145 @@
1
  #!/bin/bash
2
- echo "Executing glomapMapper.sh ..."
3
 
4
  sequence_path="$1"
5
  exp_folder="$2"
6
  exp_id="$3"
7
- verbose="$4"
8
- settings_yaml="$5"
9
- calibration_yaml="$6"
10
- rgb_txt="$7"
11
-
12
 
13
  exp_folder_colmap="${exp_folder}/colmap_${exp_id}"
14
  rgb_path="${sequence_path}/$(awk '{print $2}' "${rgb_txt}" | awk -F'/' 'NR==1 {print $1}')"
15
 
16
  calibration_model=$(grep -oP '(?<=Camera\.model:\s)[\w]+' "$calibration_yaml")
17
  echo " camera model : $calibration_model"
18
- optimize_intrinsics="0"
19
- skip_view_graph_calibration="1"
20
- if [ "${calibration_model}" == "UNKNOWN" ]
21
- then
22
- optimize_intrinsics="1"
23
- skip_view_graph_calibration="0"
24
- fi
25
 
26
  # Reading settings from yaml file
27
- BundleAdjustment_thres_loss_function=$(yq '.BundleAdjustment.thres_loss_function // 1.0' $settings_yaml)
28
- RelPoseEstimation_max_epipolar_error=$(yq '.RelPoseEstimation.max_epipolar_error // 1.0' $settings_yaml)
29
- GlobalPositioning_thres_loss_function=$(yq '.GlobalPositioning.thres_loss_function // 0.10000000000000001' $settings_yaml)
30
-
31
- Triangulation_complete_max_reproj_error=$(yq '.Triangulation.complete_max_reproj_error // 15.0' $settings_yaml)
32
- Triangulation_merge_max_reproj_error=$(yq '.Triangulation.merge_max_reproj_error // 15.0' $settings_yaml)
33
- Triangulation_min_angle=$(yq '.Triangulation.min_angle // 1.0' $settings_yaml)
34
- Triangulation_min_num_matches=$(yq '.Triangulation.min_num_matches // 15.0' $settings_yaml)
35
-
36
- Thresholds_max_epipolar_error_E=$(yq '.Thresholds.max_epipolar_error_E // 1.0' $settings_yaml)
37
- Thresholds_max_epipolar_error_F=$(yq '.Thresholds.max_epipolar_error_F // 4.0' $settings_yaml)
38
- Thresholds_max_epipolar_error_H=$(yq '.Thresholds.max_epipolar_error_H // 4.0' $settings_yaml)
39
-
40
- Thresholds_min_inlier_num=$(yq '.Thresholds.min_inlier_num // 30.0' $settings_yaml)
41
- Thresholds_min_inlier_ratio=$(yq '.Thresholds.min_inlier_ratio // 0.25' $settings_yaml)
42
- Thresholds_max_rotation_error=$(yq '.Thresholds.max_rotation_error // 10.0' $settings_yaml)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
- Thresholds_max_angle_error=$(yq '.Thresholds.max_angle_error // 1.0' $settings_yaml)
45
- Thresholds_max_reprojection_error=$(yq '.Thresholds.max_reprojection_error // 0.01' $settings_yaml)
46
- Thresholds_min_triangulation_angle=$(yq '.Thresholds.min_triangulation_angle // 1.0' $settings_yaml)
47
-
48
-
49
- echo " glomap mapper ..."
50
  database="${exp_folder_colmap}/colmap_database.db"
51
 
52
- glomap mapper \
53
  --database_path ${database} \
54
  --image_path ${rgb_path} \
55
  --output_path ${exp_folder_colmap} \
56
- --skip_view_graph_calibration "${skip_view_graph_calibration}" \
57
- --RelPoseEstimation.max_epipolar_error "${RelPoseEstimation_max_epipolar_error}" \
58
- --GlobalPositioning.thres_loss_function "${GlobalPositioning_thres_loss_function}" \
59
- --BundleAdjustment.optimize_intrinsics "$optimize_intrinsics" #\
60
- # --BundleAdjustment.thres_loss_function "${BundleAdjustment_thres_loss_function}" \
61
- # --Thresholds.max_epipolar_error_E "${Thresholds_max_epipolar_error_E}" \
62
- # --Thresholds.max_epipolar_error_F "${Thresholds_max_epipolar_error_F}" \
63
- # --Thresholds.max_epipolar_error_H "${Thresholds_max_epipolar_error_H}" \
64
- # --Thresholds.min_inlier_num "${Thresholds_min_inlier_num}" \
65
- # --Thresholds.min_inlier_ratio "${Thresholds_min_inlier_ratio}" \
66
- # --Thresholds.max_rotation_error "${Thresholds_max_rotation_error}" \
67
- # --Thresholds.max_angle_error "${Thresholds_max_angle_error}" \
68
- # --Thresholds.max_reprojection_error "${Thresholds_max_reprojection_error}" \
69
- # --Thresholds.min_triangulation_angle "${Thresholds_min_triangulation_angle}" \
70
- # --Triangulation.complete_max_reproj_error "${Triangulation_complete_max_reproj_error}" \
71
- # --Triangulation.merge_max_reproj_error "${Triangulation_merge_max_reproj_error}" \
72
- # --Triangulation.min_angle "${Triangulation_min_angle}" \
73
- # --Triangulation.min_num_matches "${Triangulation_min_num_matches}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  echo " colmap model_converter ..."
76
  colmap model_converter \
 
1
  #!/bin/bash
2
+ echo "Executing colmap_mapper.sh ..."
3
 
4
  sequence_path="$1"
5
  exp_folder="$2"
6
  exp_id="$3"
7
+ settings_yaml="$4"
8
+ calibration_yaml="$5"
9
+ rgb_txt="$6"
 
 
10
 
11
  exp_folder_colmap="${exp_folder}/colmap_${exp_id}"
12
  rgb_path="${sequence_path}/$(awk '{print $2}' "${rgb_txt}" | awk -F'/' 'NR==1 {print $1}')"
13
 
14
  calibration_model=$(grep -oP '(?<=Camera\.model:\s)[\w]+' "$calibration_yaml")
15
  echo " camera model : $calibration_model"
 
 
 
 
 
 
 
16
 
17
  # Reading settings from yaml file
18
+ mapper_Mapper_min_num_matches=$(yq '.mapper.Mapper_min_num_matches // 15' $settings_yaml)
19
+ mapper_Mapper_ignore_watermarks=$(yq '.mapper.Mapper_ignore_watermarks // 0' $settings_yaml)
20
+ mapper_Mapper_multiple_models=$(yq '.mapper.Mapper_multiple_models // 1' $settings_yaml)
21
+ mapper_Mapper_max_num_models=$(yq '.mapper.Mapper_max_num_models // 50' $settings_yaml)
22
+ mapper_Mapper_max_model_overlap=$(yq '.mapper.Mapper_max_model_overlap // 20' $settings_yaml)
23
+ mapper_Mapper_min_model_size=$(yq '.mapper.Mapper_min_model_size // 10' $settings_yaml)
24
+ mapper_Mapper_init_image_id1=$(yq '.mapper.Mapper_init_image_id1 // -1' $settings_yaml)
25
+ mapper_Mapper_init_image_id2=$(yq '.mapper.Mapper_init_image_id2 // -1' $settings_yaml)
26
+ mapper_Mapper_init_num_trials=$(yq '.mapper.Mapper_init_num_trials // 200' $settings_yaml)
27
+ mapper_Mapper_extract_colors=$(yq '.mapper.Mapper_extract_colors // 1' $settings_yaml)
28
+ mapper_Mapper_num_threads=$(yq '.mapper.Mapper_num_threads // -1' $settings_yaml)
29
+ mapper_Mapper_min_focal_length_ratio=$(yq '.mapper.Mapper_min_focal_length_ratio // 0.1' $settings_yaml)
30
+ mapper_Mapper_max_focal_length_ratio=$(yq '.mapper.Mapper_max_focal_length_ratio // 10' $settings_yaml)
31
+ mapper_Mapper_max_extra_param=$(yq '.mapper.Mapper_max_extra_param // 1' $settings_yaml)
32
+ mapper_Mapper_ba_refine_focal_length=$(yq '.mapper.Mapper_ba_refine_focal_length // 1' $settings_yaml)
33
+ mapper_Mapper_ba_refine_principal_point=$(yq '.mapper.Mapper_ba_refine_principal_point // 0' $settings_yaml)
34
+ mapper_Mapper_ba_refine_extra_params=$(yq '.mapper.Mapper_ba_refine_extra_params // 1' $settings_yaml)
35
+ mapper_Mapper_ba_local_num_images=$(yq '.mapper.Mapper_ba_local_num_images // 6' $settings_yaml)
36
+ mapper_Mapper_ba_local_function_tolerance=$(yq '.mapper.Mapper_ba_local_function_tolerance // 0' $settings_yaml)
37
+ mapper_Mapper_ba_local_max_num_iterations=$(yq '.mapper.Mapper_ba_local_max_num_iterations // 25' $settings_yaml)
38
+ mapper_Mapper_ba_global_images_ratio=$(yq '.mapper.Mapper_ba_global_images_ratio // 1.1' $settings_yaml)
39
+ mapper_Mapper_ba_global_points_ratio=$(yq '.mapper.Mapper_ba_global_points_ratio // 1.1' $settings_yaml)
40
+ mapper_Mapper_ba_global_images_freq=$(yq '.mapper.Mapper_ba_global_images_freq // 500' $settings_yaml)
41
+ mapper_Mapper_ba_global_points_freq=$(yq '.mapper.Mapper_ba_global_points_freq // 250000' $settings_yaml)
42
+ mapper_Mapper_ba_global_function_tolerance=$(yq '.mapper.Mapper_ba_global_function_tolerance // 0' $settings_yaml)
43
+ mapper_Mapper_ba_global_max_num_iterations=$(yq '.mapper.Mapper_ba_global_max_num_iterations // 50' $settings_yaml)
44
+ mapper_Mapper_ba_global_max_refinements=$(yq '.mapper.Mapper_ba_global_max_refinements // 5' $settings_yaml)
45
+ mapper_Mapper_ba_global_max_refinement_change=$(yq '.mapper.Mapper_ba_global_max_refinement_change // 0.0005' $settings_yaml)
46
+ mapper_Mapper_ba_local_max_refinements=$(yq '.mapper.Mapper_ba_local_max_refinements // 2' $settings_yaml)
47
+ mapper_Mapper_ba_local_max_refinement_change=$(yq '.mapper.Mapper_ba_local_max_refinement_change // 0.001' $settings_yaml)
48
+ mapper_Mapper_ba_use_gpu=$(yq '.mapper.Mapper_ba_use_gpu // 0' $settings_yaml)
49
+ mapper_Mapper_ba_gpu_index=$(yq '.mapper.Mapper_ba_gpu_index // -1' $settings_yaml)
50
+ mapper_Mapper_ba_min_num_residuals_for_cpu_multi_threading=$(yq '.mapper.Mapper_ba_min_num_residuals_for_cpu_multi_threading // 50000' $settings_yaml)
51
+ mapper_Mapper_snapshot_images_freq=$(yq '.mapper.Mapper_snapshot_images_freq // 0' $settings_yaml)
52
+ mapper_Mapper_fix_existing_images=$(yq '.mapper.Mapper_fix_existing_images // 0' $settings_yaml)
53
+ mapper_Mapper_init_min_num_inliers=$(yq '.mapper.Mapper_init_min_num_inliers // 100' $settings_yaml)
54
+ mapper_Mapper_init_max_error=$(yq '.mapper.Mapper_init_max_error // 4' $settings_yaml)
55
+ mapper_Mapper_init_max_forward_motion=$(yq '.mapper.Mapper_init_max_forward_motion // 0.95' $settings_yaml)
56
+ mapper_Mapper_init_min_tri_angle=$(yq '.mapper.Mapper_init_min_tri_angle // 16' $settings_yaml)
57
+ mapper_Mapper_init_max_reg_trials=$(yq '.mapper.Mapper_init_max_reg_trials // 2' $settings_yaml)
58
+ mapper_Mapper_abs_pose_max_error=$(yq '.mapper.Mapper_abs_pose_max_error // 12' $settings_yaml)
59
+ mapper_Mapper_abs_pose_min_num_inliers=$(yq '.mapper.Mapper_abs_pose_min_num_inliers // 30' $settings_yaml)
60
+ mapper_Mapper_abs_pose_min_inlier_ratio=$(yq '.mapper.Mapper_abs_pose_min_inlier_ratio // 0.25' $settings_yaml)
61
+ mapper_Mapper_filter_max_reproj_error=$(yq '.mapper.Mapper_filter_max_reproj_error // 4' $settings_yaml)
62
+ mapper_Mapper_filter_min_tri_angle=$(yq '.mapper.Mapper_filter_min_tri_angle // 1.5' $settings_yaml)
63
+ mapper_Mapper_max_reg_trials=$(yq '.mapper.Mapper_max_reg_trials // 3' $settings_yaml)
64
+ mapper_Mapper_local_ba_min_tri_angle=$(yq '.mapper.Mapper_local_ba_min_tri_angle // 6' $settings_yaml)
65
+ mapper_Mapper_tri_max_transitivity=$(yq '.mapper.Mapper_tri_max_transitivity // 1' $settings_yaml)
66
+ mapper_Mapper_tri_create_max_angle_error=$(yq '.mapper.Mapper_tri_create_max_angle_error // 2' $settings_yaml)
67
+ mapper_Mapper_tri_continue_max_angle_error=$(yq '.mapper.Mapper_tri_continue_max_angle_error // 2' $settings_yaml)
68
+ mapper_Mapper_tri_merge_max_reproj_error=$(yq '.mapper.Mapper_tri_merge_max_reproj_error // 4' $settings_yaml)
69
+ mapper_Mapper_tri_complete_max_reproj_error=$(yq '.mapper.Mapper_tri_complete_max_reproj_error // 4' $settings_yaml)
70
+ mapper_Mapper_tri_complete_max_transitivity=$(yq '.mapper.Mapper_tri_complete_max_transitivity // 5' $settings_yaml)
71
+ mapper_Mapper_tri_re_max_angle_error=$(yq '.mapper.Mapper_tri_re_max_angle_error // 5' $settings_yaml)
72
+ mapper_Mapper_tri_re_min_ratio=$(yq '.mapper.Mapper_tri_re_min_ratio // 0.2' $settings_yaml)
73
+ mapper_Mapper_tri_re_max_trials=$(yq '.mapper.Mapper_tri_re_max_trials // 1' $settings_yaml)
74
+ mapper_Mapper_tri_min_angle=$(yq '.mapper.Mapper_tri_min_angle // 1.5' $settings_yaml)
75
+ mapper_Mapper_tri_ignore_two_view_tracks=$(yq '.mapper.Mapper_tri_ignore_two_view_tracks // 1' $settings_yaml)
76
 
77
+ echo " colmap mapper ..."
 
 
 
 
 
78
  database="${exp_folder_colmap}/colmap_database.db"
79
 
80
+ colmap mapper \
81
  --database_path ${database} \
82
  --image_path ${rgb_path} \
83
  --output_path ${exp_folder_colmap} \
84
+ --Mapper.min_num_matches ${mapper_Mapper_min_num_matches} \
85
+ --Mapper.ignore_watermarks ${mapper_Mapper_ignore_watermarks} \
86
+ --Mapper.multiple_models ${mapper_Mapper_multiple_models} \
87
+ --Mapper.max_num_models ${mapper_Mapper_max_num_models} \
88
+ --Mapper.max_model_overlap ${mapper_Mapper_max_model_overlap} \
89
+ --Mapper.min_model_size ${mapper_Mapper_min_model_size} \
90
+ --Mapper.init_image_id1 ${mapper_Mapper_init_image_id1} \
91
+ --Mapper.init_image_id2 ${mapper_Mapper_init_image_id2} \
92
+ --Mapper.init_num_trials ${mapper_Mapper_init_num_trials} \
93
+ --Mapper.extract_colors ${mapper_Mapper_extract_colors} \
94
+ --Mapper.num_threads ${mapper_Mapper_num_threads} \
95
+ --Mapper.min_focal_length_ratio ${mapper_Mapper_min_focal_length_ratio} \
96
+ --Mapper.max_focal_length_ratio ${mapper_Mapper_max_focal_length_ratio} \
97
+ --Mapper.max_extra_param ${mapper_Mapper_max_extra_param} \
98
+ --Mapper.ba_refine_focal_length ${mapper_Mapper_ba_refine_focal_length} \
99
+ --Mapper.ba_refine_principal_point ${mapper_Mapper_ba_refine_principal_point} \
100
+ --Mapper.ba_refine_extra_params ${mapper_Mapper_ba_refine_extra_params} \
101
+ --Mapper.ba_local_num_images ${mapper_Mapper_ba_local_num_images} \
102
+ --Mapper.ba_local_function_tolerance ${mapper_Mapper_ba_local_function_tolerance} \
103
+ --Mapper.ba_local_max_num_iterations ${mapper_Mapper_ba_local_max_num_iterations} \
104
+ --Mapper.ba_global_images_ratio ${mapper_Mapper_ba_global_images_ratio} \
105
+ --Mapper.ba_global_points_ratio ${mapper_Mapper_ba_global_points_ratio} \
106
+ --Mapper.ba_global_images_freq ${mapper_Mapper_ba_global_images_freq} \
107
+ --Mapper.ba_global_points_freq ${mapper_Mapper_ba_global_points_freq} \
108
+ --Mapper.ba_global_function_tolerance ${mapper_Mapper_ba_global_function_tolerance} \
109
+ --Mapper.ba_global_max_num_iterations ${mapper_Mapper_ba_global_max_num_iterations} \
110
+ --Mapper.ba_global_max_refinements ${mapper_Mapper_ba_global_max_refinements} \
111
+ --Mapper.ba_global_max_refinement_change ${mapper_Mapper_ba_global_max_refinement_change} \
112
+ --Mapper.ba_local_max_refinements ${mapper_Mapper_ba_local_max_refinements} \
113
+ --Mapper.ba_local_max_refinement_change ${mapper_Mapper_ba_local_max_refinement_change} \
114
+ --Mapper.ba_use_gpu ${mapper_Mapper_ba_use_gpu} \
115
+ --Mapper.ba_gpu_index ${mapper_Mapper_ba_gpu_index} \
116
+ --Mapper.ba_min_num_residuals_for_cpu_multi_threading ${mapper_Mapper_ba_min_num_residuals_for_cpu_multi_threading} \
117
+ --Mapper.snapshot_images_freq ${mapper_Mapper_snapshot_images_freq} \
118
+ --Mapper.fix_existing_images ${mapper_Mapper_fix_existing_images} \
119
+ --Mapper.init_min_num_inliers ${mapper_Mapper_init_min_num_inliers} \
120
+ --Mapper.init_max_error ${mapper_Mapper_init_max_error} \
121
+ --Mapper.init_max_forward_motion ${mapper_Mapper_init_max_forward_motion} \
122
+ --Mapper.init_min_tri_angle ${mapper_Mapper_init_min_tri_angle} \
123
+ --Mapper.init_max_reg_trials ${mapper_Mapper_init_max_reg_trials} \
124
+ --Mapper.abs_pose_max_error ${mapper_Mapper_abs_pose_max_error} \
125
+ --Mapper.abs_pose_min_num_inliers ${mapper_Mapper_abs_pose_min_num_inliers} \
126
+ --Mapper.abs_pose_min_inlier_ratio ${mapper_Mapper_abs_pose_min_inlier_ratio} \
127
+ --Mapper.filter_max_reproj_error ${mapper_Mapper_filter_max_reproj_error} \
128
+ --Mapper.filter_min_tri_angle ${mapper_Mapper_filter_min_tri_angle} \
129
+ --Mapper.max_reg_trials ${mapper_Mapper_max_reg_trials} \
130
+ --Mapper.local_ba_min_tri_angle ${mapper_Mapper_local_ba_min_tri_angle} \
131
+ --Mapper.tri_max_transitivity ${mapper_Mapper_tri_max_transitivity} \
132
+ --Mapper.tri_create_max_angle_error ${mapper_Mapper_tri_create_max_angle_error} \
133
+ --Mapper.tri_continue_max_angle_error ${mapper_Mapper_tri_continue_max_angle_error} \
134
+ --Mapper.tri_merge_max_reproj_error ${mapper_Mapper_tri_merge_max_reproj_error} \
135
+ --Mapper.tri_complete_max_reproj_error ${mapper_Mapper_tri_complete_max_reproj_error} \
136
+ --Mapper.tri_complete_max_transitivity ${mapper_Mapper_tri_complete_max_transitivity} \
137
+ --Mapper.tri_re_max_angle_error ${mapper_Mapper_tri_re_max_angle_error} \
138
+ --Mapper.tri_re_min_ratio ${mapper_Mapper_tri_re_min_ratio} \
139
+ --Mapper.tri_re_max_trials ${mapper_Mapper_tri_re_max_trials} \
140
+ --Mapper.tri_min_angle ${mapper_Mapper_tri_min_angle} \
141
+ --Mapper.tri_ignore_two_view_tracks ${mapper_Mapper_tri_ignore_two_view_tracks}
142
+
143
 
144
  echo " colmap model_converter ..."
145
  colmap model_converter \
colmap_matcher.sh CHANGED
@@ -1,15 +1,15 @@
1
  #!/bin/bash
2
  echo ""
3
- echo "Executing colmapMatcher.sh ..."
4
 
5
  sequence_path="$1"
6
  exp_folder="$2"
7
  exp_id="$3"
8
- matcher_type="$4" # Options: exhaustive, sequential
9
- use_gpu="$5"
10
- settings_yaml="$6"
11
- calibration_yaml="$7"
12
- rgb_txt="$8"
13
 
14
  exp_folder_colmap="${exp_folder}/colmap_${exp_id}"
15
  rgb_path="${sequence_path}/$(awk '{print $2}' "${rgb_txt}" | awk -F'/' 'NR==1 {print $1}')"
@@ -58,7 +58,7 @@ database="${exp_folder_colmap}/colmap_database.db"
58
  rm -rf ${database}
59
  colmap database_creator --database_path ${database}
60
 
61
- ################################################################################
62
  echo " colmap feature_extractor ..."
63
 
64
  if [ "${calibration_model}" == "UNKNOWN" ]
@@ -81,9 +81,6 @@ colmap feature_extractor \
81
  --SiftExtraction.dsp_num_scales ${feature_extractor_SiftExtraction_dsp_num_scales}
82
  fi
83
 
84
- feature_extractor_SiftExtraction_dsp_num_scales=$(yq '.feature_extractor.SiftExtraction_dsp_num_scales // 10.0' $settings_yaml)
85
-
86
-
87
  if [ "${calibration_model}" == "PINHOLE" ]
88
  then
89
  echo " camera model : $calibration_model"
@@ -147,7 +144,7 @@ then
147
  --SiftExtraction.dsp_num_scales ${feature_extractor_SiftExtraction_dsp_num_scales}
148
  fi
149
 
150
- ################################################################################
151
  if [ "${matcher_type}" == "exhaustive" ]
152
  then
153
  echo " colmap exhaustive_matcher ..."
@@ -164,17 +161,18 @@ then
164
 
165
  fi
166
 
 
167
  if [ "${matcher_type}" == "sequential" ]
168
  then
169
  num_rgb=$(wc -l < ${rgb_txt})
170
 
171
  # Pick vocabulary tree based on the number of images
172
- vocabulary_tree="Baselines/glomap/vocab_tree_flickr100K_words32K.bin"
173
  if [ "$num_rgb" -gt 1000 ]; then
174
- vocabulary_tree="Baselines/glomap/vocab_tree_flickr100K_words256K.bin"
175
  fi
176
  if [ "$num_rgb" -gt 10000 ]; then
177
- vocabulary_tree="Baselines/glomap/vocab_tree_flickr100K_words1M.bin"
178
  fi
179
 
180
  echo " colmap sequential_matcher ..."
 
1
  #!/bin/bash
2
  echo ""
3
+ echo "Executing colmap_matcher.sh ..."
4
 
5
  sequence_path="$1"
6
  exp_folder="$2"
7
  exp_id="$3"
8
+ settings_yaml="$4"
9
+ calibration_yaml="$5"
10
+ rgb_txt="$6"
11
+ matcher_type="$7"
12
+ use_gpu="$8"
13
 
14
  exp_folder_colmap="${exp_folder}/colmap_${exp_id}"
15
  rgb_path="${sequence_path}/$(awk '{print $2}' "${rgb_txt}" | awk -F'/' 'NR==1 {print $1}')"
 
58
  rm -rf ${database}
59
  colmap database_creator --database_path ${database}
60
 
61
+ # Feature extractor
62
  echo " colmap feature_extractor ..."
63
 
64
  if [ "${calibration_model}" == "UNKNOWN" ]
 
81
  --SiftExtraction.dsp_num_scales ${feature_extractor_SiftExtraction_dsp_num_scales}
82
  fi
83
 
 
 
 
84
  if [ "${calibration_model}" == "PINHOLE" ]
85
  then
86
  echo " camera model : $calibration_model"
 
144
  --SiftExtraction.dsp_num_scales ${feature_extractor_SiftExtraction_dsp_num_scales}
145
  fi
146
 
147
+ # Exhaustive Feature Matcher
148
  if [ "${matcher_type}" == "exhaustive" ]
149
  then
150
  echo " colmap exhaustive_matcher ..."
 
161
 
162
  fi
163
 
164
+ # Sequential Feature Matcher
165
  if [ "${matcher_type}" == "sequential" ]
166
  then
167
  num_rgb=$(wc -l < ${rgb_txt})
168
 
169
  # Pick vocabulary tree based on the number of images
170
+ vocabulary_tree="Baselines/colmap/vocab_tree_flickr100K_words32K.bin"
171
  if [ "$num_rgb" -gt 1000 ]; then
172
+ vocabulary_tree="Baselines/colmap/vocab_tree_flickr100K_words256K.bin"
173
  fi
174
  if [ "$num_rgb" -gt 10000 ]; then
175
+ vocabulary_tree="Baselines/colmap/vocab_tree_flickr100K_words1M.bin"
176
  fi
177
 
178
  echo " colmap sequential_matcher ..."
colmap_reconstruction.sh CHANGED
@@ -1,11 +1,17 @@
1
  #!/bin/bash
2
 
3
- # Function to split key-value pairs and assign them to variables
4
  matcher_type="exhaustive"
5
  use_gpu="1"
6
  verbose="0"
7
  settings_yaml=""
 
 
 
 
 
8
 
 
9
  split_and_assign() {
10
  local input=$1
11
  local key=$(echo $input | cut -d':' -f1)
@@ -13,52 +19,40 @@ split_and_assign() {
13
  eval $key=$value
14
  }
15
 
16
- # Split the input string into individual components
17
  for ((i=1; i<=$#; i++)); do
18
  split_and_assign "${!i}"
19
  done
20
 
21
  exp_id=$(printf "%05d" ${exp_id})
22
 
23
- echo "Sequence Path: $sequence_path"
24
- echo "Experiment Folder: $exp_folder"
25
- echo "Experiment ID: $exp_id"
26
- echo "Verbose: $verbose"
27
- echo "matcher_type: $matcher_type"
28
- echo "use_gpu: $use_gpu"
29
- echo "settings_yaml: $settings_yaml"
30
- echo "calibration_yaml: $calibration_yaml"
31
- echo "rgb_txt: $rgb_txt"
 
 
32
 
 
33
  exp_folder_colmap="${exp_folder}/colmap_${exp_id}"
34
  rm -rf "$exp_folder_colmap"
35
  mkdir "$exp_folder_colmap"
36
 
37
- export QT_QPA_PLATFORM_PLUGIN_PATH="$CONDA_PREFIX/plugins/platforms"
38
-
39
  # Run COLMAP scripts for matching and mapping
40
- ./Baselines/glomap/colmap_matcher.sh $sequence_path $exp_folder $exp_id $matcher_type $use_gpu ${settings_yaml} ${calibration_yaml} ${rgb_txt}
41
- ./Baselines/glomap/glomap_mapper.sh $sequence_path $exp_folder $exp_id ${verbose} ${settings_yaml} ${calibration_yaml} ${rgb_txt}
42
-
43
- # Convert COLMAP outputs to a format suitable for VSLAM-Lab
44
- python Baselines/glomap/colmap_to_vslamlab.py $sequence_path $exp_folder $exp_id $verbose $rgb_txt
45
 
46
- # Get colmap stats
47
- colmap_stats_csv="${exp_folder}/${exp_id}_colmap_stats.csv"
48
- if [[ ! -f "$colmap_stats_csv" ]]; then
49
- echo "File,Cameras,Images,Registered Images,Points,Observations,Mean Track Length,Mean Observations per Image,Mean Reprojection Error" > "$colmap_stats_csv"
50
- fi
51
- colmap_stats=$(pixi run -e colmap colmap model_analyzer --path "$exp_folder_colmap" 2>&1)
52
- cameras=$(echo "$colmap_stats" | grep -oP "(?<=Cameras: )\d+")
53
- images=$(echo "$colmap_stats" | grep -oP "(?<=Images: )\d+")
54
- registered_images=$(echo "$colmap_stats" | grep -oP "(?<=Registered images: )\d+")
55
- points=$(echo "$colmap_stats" | grep -oP "(?<=Points: )\d+")
56
- observations=$(echo "$colmap_stats" | grep -oP "(?<=Observations: )\d+")
57
- mean_track_length=$(echo "$colmap_stats" | grep -oP "(?<=Mean track length: )\d+\.\d+")
58
- mean_observations_per_image=$(echo "$colmap_stats" | grep -oP "(?<=Mean observations per image: )\d+\.\d+")
59
- mean_reprojection_error=$(echo "$colmap_stats" | grep -oP "(?<=Mean reprojection error: )\d+\.\d+")
60
- echo "$exp_folder_colmap,${cameras:-0},${images:-0},${registered_images:-0},${points:-0},${observations:-0},${mean_track_length:-0},${mean_observations_per_image:-0},${mean_reprojection_error:-0}" >> "$colmap_stats_csv"
61
 
 
62
  if [ "$verbose" -eq 1 ]; then
63
  exp_folder_colmap="${exp_folder}/colmap_${exp_id}"
64
  rgb_path="${sequence_path}/$(awk '{print $2}' "${rgb_txt}" | awk -F'/' 'NR==1 {print $1}')"
@@ -66,8 +60,7 @@ if [ "$verbose" -eq 1 ]; then
66
  colmap gui --import_path "${exp_folder_colmap}/0" --database_path ${database} --image_path ${rgb_path}
67
  fi
68
 
69
-
70
- # Remove colmap data
71
- rm -rf ${exp_folder_colmap}
72
 
73
 
 
1
  #!/bin/bash
2
 
3
+ # Default values
4
  matcher_type="exhaustive"
5
  use_gpu="1"
6
  verbose="0"
7
  settings_yaml=""
8
+ sequence_path=""
9
+ exp_folder=""
10
+ exp_id=""
11
+ calibration_yaml=""
12
+ rgb_txt=""
13
 
14
+ # Function to split key-value pairs and assign them to variables
15
  split_and_assign() {
16
  local input=$1
17
  local key=$(echo $input | cut -d':' -f1)
 
19
  eval $key=$value
20
  }
21
 
22
+ # Read Inputs
23
  for ((i=1; i<=$#; i++)); do
24
  split_and_assign "${!i}"
25
  done
26
 
27
  exp_id=$(printf "%05d" ${exp_id})
28
 
29
+ echo -e "\n================= Experiment Configuration ================="
30
+ echo " Sequence Path : $sequence_path"
31
+ echo " Experiment Folder : $exp_folder"
32
+ echo " Experiment ID : $exp_id"
33
+ echo " Verbose : $verbose"
34
+ echo " Matcher Type : $matcher_type"
35
+ echo " Use GPU : $use_gpu"
36
+ echo " Settings YAML : $settings_yaml"
37
+ echo " Calibration YAML : $calibration_yaml"
38
+ echo " RGB TXT : $rgb_txt"
39
+ echo "============================================================"
40
 
41
+ # Create folder to save colmap files
42
  exp_folder_colmap="${exp_folder}/colmap_${exp_id}"
43
  rm -rf "$exp_folder_colmap"
44
  mkdir "$exp_folder_colmap"
45
 
 
 
46
  # Run COLMAP scripts for matching and mapping
47
+ export QT_QPA_PLATFORM_PLUGIN_PATH="$CONDA_PREFIX/plugins/platforms"
48
+ colmap_args="$sequence_path $exp_folder $exp_id $settings_yaml $calibration_yaml $rgb_txt"
49
+ ./Baselines/colmap/colmap_matcher.sh $colmap_args $matcher_type $use_gpu
50
+ ./Baselines/colmap/colmap_mapper.sh $colmap_args
 
51
 
52
+ # Convert COLMAP outputs to a format suitable for VSLAM-LAB
53
+ python Baselines/colmap/colmap_to_vslamlab.py $sequence_path $exp_folder $exp_id $verbose $rgb_txt
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
+ # Visualization with colmap gui
56
  if [ "$verbose" -eq 1 ]; then
57
  exp_folder_colmap="${exp_folder}/colmap_${exp_id}"
58
  rgb_path="${sequence_path}/$(awk '{print $2}' "${rgb_txt}" | awk -F'/' 'NR==1 {print $1}')"
 
60
  colmap gui --import_path "${exp_folder_colmap}/0" --database_path ${database} --image_path ${rgb_path}
61
  fi
62
 
63
+ # # Remove colmap data
64
+ # rm -rf ${exp_folder_colmap}
 
65
 
66
 
colmap_to_vslamlab.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ from scipy.spatial.transform import Rotation as R
3
+ import sys
4
+ import os
5
+
6
+ def get_colmap_keyframes(images_file, number_of_header_lines, verbose=False):
7
+ print(f"get_colmap_keyframes: {images_file}")
8
+
9
+ image_id = []
10
+ q_wc_xyzw = []
11
+ t_wc = []
12
+
13
+ with open(f"{images_file}", 'r') as file:
14
+ # Skip the header lines
15
+ for _ in range(number_of_header_lines):
16
+ file.readline()
17
+
18
+ while True:
19
+ line1 = file.readline()
20
+ if not line1:
21
+ break
22
+ elements = line1.split()
23
+
24
+ IMAGE_ID = int(elements[0])
25
+ image_id.append(IMAGE_ID)
26
+
27
+ QW = float(elements[1])
28
+ QX = float(elements[2])
29
+ QY = float(elements[3])
30
+ QZ = float(elements[4])
31
+
32
+ TX = float(elements[5])
33
+ TY = float(elements[6])
34
+ TZ = float(elements[7])
35
+
36
+ t_cw_i = np.array([TX, TY, TZ])
37
+ q_wc_i = R.from_quat([QX, QY, QZ, QW]).inv()
38
+ R_wc_i = q_wc_i.as_matrix()
39
+
40
+ q_wc_xyzw.append([q_wc_i.as_quat()[0], q_wc_i.as_quat()[1], q_wc_i.as_quat()[2], q_wc_i.as_quat()[3]])
41
+ t_wc.append(-R_wc_i @ t_cw_i)
42
+
43
+ file.readline()
44
+
45
+ image_id = np.array(image_id)
46
+ q_wc_xyzw = np.array(q_wc_xyzw)
47
+ t_wc = np.array(t_wc)
48
+
49
+ sorted_indices = image_id.argsort()
50
+ image_id = image_id[sorted_indices]
51
+ q_wc_xyzw = q_wc_xyzw[sorted_indices]
52
+ t_wc = t_wc[sorted_indices]
53
+
54
+ q_wc_xyzw_corrected = q_wc_xyzw.copy()
55
+ for i in range(1, len(q_wc_xyzw_corrected)):
56
+ dot_product = np.dot(q_wc_xyzw_corrected[i - 1], q_wc_xyzw_corrected[i])
57
+ if dot_product < 0:
58
+ q_wc_xyzw_corrected[i] = -q_wc_xyzw_corrected[i]
59
+
60
+ return image_id, t_wc, q_wc_xyzw_corrected
61
+
62
+ def write_trajectory_tum_format(file_name, image_ts, t_wc, q_wc_xyzw):
63
+ print(f"writeTrajectoryTUMformat: {file_name}")
64
+
65
+ data = np.hstack((image_ts.reshape(-1, 1), t_wc, q_wc_xyzw))
66
+ data = data[data[:, 0].argsort()]
67
+
68
+ with open(file_name, 'w') as file:
69
+ for row in data:
70
+ # Format the row with the appropriate precision
71
+ file.write(' '.join(f'{x:.15f}' for x in row) + '\n')
72
+
73
+ def get_timestamps(files_path, rgb_file):
74
+ print(f"getTimestamps: {os.path.join(files_path, rgb_file)}")
75
+
76
+ ts = []
77
+
78
+ with open(os.path.join(files_path, rgb_file), 'r') as file:
79
+ for line in file:
80
+ parts = line.split()
81
+ ts.append(float(parts[0])) # Assuming the first part is the timestamp
82
+
83
+ return ts
84
+
85
+ if __name__ == "__main__":
86
+
87
+ sequence_path = sys.argv[1]
88
+ exp_folder = sys.argv[2]
89
+ exp_id = sys.argv[3]
90
+ verbose = bool(int(sys.argv[4]))
91
+ rgb_file = sys.argv[5]
92
+
93
+ images_file = os.path.join(exp_folder, f'colmap_{exp_id}', 'images.txt')
94
+
95
+ number_of_header_lines = 4
96
+ image_id, t_wc, q_wc_xyzw = get_colmap_keyframes(images_file, number_of_header_lines, verbose)
97
+
98
+ image_ts = np.array(get_timestamps(sequence_path, rgb_file))
99
+ timestamps = []
100
+ for id in image_id:
101
+ timestamps.append(float(image_ts[id-1]))
102
+
103
+ timestamps = np.array(timestamps)
104
+
105
+ keyFrameTrajectory_txt = os.path.join(exp_folder, exp_id + '_KeyFrameTrajectory' + '.txt')
106
+ write_trajectory_tum_format(keyFrameTrajectory_txt, timestamps, t_wc, q_wc_xyzw)
vslamlab_colmap_settings.yaml CHANGED
@@ -1,29 +1,3 @@
1
- BundleAdjustment:
2
- thres_loss_function: 1.0
3
-
4
- RelPoseEstimation:
5
- max_epipolar_error: 1.0
6
-
7
- GlobalPositioning:
8
- thres_loss_function: 0.10000000000000001
9
-
10
- Triangulation:
11
- complete_max_reproj_error: 15.0
12
- merge_max_reproj_error: 15.0
13
- min_angle: 1.0
14
- min_num_matches: 15
15
-
16
- Thresholds:
17
- max_angle_error: 1.0
18
- max_reprojection_error: 0.01
19
- min_triangulation_angle: 1.0
20
- min_inlier_num: 30.0
21
- min_inlier_ratio: 0.25
22
- max_rotation_error: 10.0
23
- max_epipolar_error_E: 1.0
24
- max_epipolar_error_F: 4.0
25
- max_epipolar_error_H: 4.0
26
-
27
  feature_extractor:
28
  SiftExtraction_num_octaves: 4
29
  SiftExtraction_octave_resolution: 3
@@ -43,3 +17,63 @@ matcher:
43
  SequentialMatching_overlap: 10
44
  SequentialMatching_quadratic_overlap: 1
45
  ExhaustiveMatching_block_size: 50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  feature_extractor:
2
  SiftExtraction_num_octaves: 4
3
  SiftExtraction_octave_resolution: 3
 
17
  SequentialMatching_overlap: 10
18
  SequentialMatching_quadratic_overlap: 1
19
  ExhaustiveMatching_block_size: 50
20
+
21
+ mapper:
22
+ Mapper_min_num_matches: 15
23
+ Mapper_ignore_watermarks: 0
24
+ Mapper_multiple_models: 1
25
+ Mapper_max_num_models: 50
26
+ Mapper_max_model_overlap: 20
27
+ Mapper_min_model_size: 10
28
+ Mapper_init_image_id1: -1
29
+ Mapper_init_image_id2: -1
30
+ Mapper_init_num_trials: 200
31
+ Mapper_extract_colors: 1
32
+ Mapper_num_threads: -1
33
+ Mapper_min_focal_length_ratio: 0.10000000000000001
34
+ Mapper_max_focal_length_ratio: 10
35
+ Mapper_max_extra_param: 1
36
+ Mapper_ba_refine_focal_length: 1
37
+ Mapper_ba_refine_principal_point: 0
38
+ Mapper_ba_refine_extra_params: 1
39
+ Mapper_ba_local_num_images: 6
40
+ Mapper_ba_local_function_tolerance: 0
41
+ Mapper_ba_local_max_num_iterations: 25
42
+ Mapper_ba_global_images_ratio: 1.1000000000000001
43
+ Mapper_ba_global_points_ratio: 1.1000000000000001
44
+ Mapper_ba_global_images_freq: 500
45
+ Mapper_ba_global_points_freq: 250000
46
+ Mapper_ba_global_function_tolerance: 0
47
+ Mapper_ba_global_max_num_iterations: 50
48
+ Mapper_ba_global_max_refinements: 5
49
+ Mapper_ba_global_max_refinement_change: 0.00050000000000000001
50
+ Mapper_ba_local_max_refinements: 2
51
+ Mapper_ba_local_max_refinement_change: 0.001
52
+ Mapper_ba_use_gpu: 0
53
+ Mapper_ba_gpu_index: -1
54
+ Mapper_ba_min_num_residuals_for_cpu_multi_threading: 50000
55
+ Mapper_snapshot_images_freq: 0
56
+ Mapper_fix_existing_images: 0
57
+ Mapper_init_min_num_inliers: 100
58
+ Mapper_init_max_error: 4
59
+ Mapper_init_max_forward_motion: 0.94999999999999996
60
+ Mapper_init_min_tri_angle: 16
61
+ Mapper_init_max_reg_trials: 2
62
+ Mapper_abs_pose_max_error: 12
63
+ Mapper_abs_pose_min_num_inliers: 30
64
+ Mapper_abs_pose_min_inlier_ratio: 0.25
65
+ Mapper_filter_max_reproj_error: 4
66
+ Mapper_filter_min_tri_angle: 1.5
67
+ Mapper_max_reg_trials: 3
68
+ Mapper_local_ba_min_tri_angle: 6
69
+ Mapper_tri_max_transitivity: 1
70
+ Mapper_tri_create_max_angle_error: 2
71
+ Mapper_tri_continue_max_angle_error: 2
72
+ Mapper_tri_merge_max_reproj_error: 4
73
+ Mapper_tri_complete_max_reproj_error: 4
74
+ Mapper_tri_complete_max_transitivity: 5
75
+ Mapper_tri_re_max_angle_error: 5
76
+ Mapper_tri_re_min_ratio: 0.20000000000000001
77
+ Mapper_tri_re_max_trials: 1
78
+ Mapper_tri_min_angle: 1.5
79
+ Mapper_tri_ignore_two_view_tracks: 1