add scripts
Browse files- colmap_mapper.sh +79 -0
- colmap_reconstruction.sh +73 -0
- vslamlab_colmap_settings.yaml +45 -0
colmap_mapper.sh
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 \
|
| 77 |
+
--input_path ${exp_folder_colmap}/0 --output_path ${exp_folder_colmap} --output_type TXT
|
| 78 |
+
|
| 79 |
+
|
colmap_reconstruction.sh
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|
| 12 |
+
local value=$(echo $input | cut -d':' -f2-)
|
| 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}')"
|
| 65 |
+
database="${exp_folder_colmap}/colmap_database.db"
|
| 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 |
+
|
vslamlab_colmap_settings.yaml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 30 |
+
SiftExtraction_peak_threshold: 0.0066666666666666671
|
| 31 |
+
SiftExtraction_edge_threshold: 10.0
|
| 32 |
+
SiftExtraction_dsp_min_scale: 0.1666666666666666
|
| 33 |
+
SiftExtraction_dsp_max_scale: 3.0
|
| 34 |
+
SiftExtraction_dsp_num_scales: 10
|
| 35 |
+
|
| 36 |
+
matcher:
|
| 37 |
+
SiftMatching_max_ratio: 0.80000000000000004
|
| 38 |
+
SiftMatching_max_distance: 0.69999999999999996
|
| 39 |
+
TwoViewGeometry_min_num_inliers: 15
|
| 40 |
+
TwoViewGeometry_max_error: 4.0
|
| 41 |
+
TwoViewGeometry_confidence: 0.999
|
| 42 |
+
TwoViewGeometry_min_inlier_ratio: 0.25
|
| 43 |
+
SequentialMatching_overlap: 10
|
| 44 |
+
SequentialMatching_quadratic_overlap: 1
|
| 45 |
+
ExhaustiveMatching_block_size: 50
|