File size: 5,514 Bytes
e93d220 744b072 e93d220 744b072 d7e30ae 744b072 e8ace62 e93d220 d7e30ae e93d220 e8ace62 e93d220 e8ace62 e93d220 e8ace62 e93d220 744b072 e93d220 e8ace62 e93d220 bed028c e93d220 e8ace62 e93d220 e8ace62 e93d220 e8ace62 e93d220 d7e30ae e93d220 bed028c e8ace62 e93d220 e8ace62 e93d220 e8ace62 e93d220 e8ace62 e93d220 e8ace62 e93d220 bed028c e8ace62 e93d220 e8ace62 e93d220 e8ace62 d7e30ae e8ace62 e93d220 e8ace62 e93d220 e8ace62 e93d220 bed028c e8ace62 e93d220 744b072 e93d220 e8ace62 e93d220 744b072 e93d220 d7e30ae e93d220 744b072 e93d220 744b072 e93d220 744b072 e93d220 e8ace62 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
#!/bin/bash
echo ""
echo "Executing colmap_matcher.sh ..."
sequence_path="$1"
exp_folder="$2"
exp_id="$3"
settings_yaml="$4"
calibration_yaml="$5"
rgb_csv="$6"
matcher_type="$7"
use_gpu="$8"
camera_name="$9"
exp_folder_colmap="${exp_folder}/colmap_${exp_id}"
rgb_dir=$(awk -F, 'NR==2 { split($2,a,"/"); print a[1]; exit }' "$rgb_csv")
rgb_path="${sequence_path}/${rgb_dir}"
# Get calibration model
read -r calibration_model more_ <<< $(python3 Baselines/colmap/get_calibration.py "$calibration_yaml" "$camera_name")
# Create colmap image list
colmap_image_list="${exp_folder_colmap}/colmap_image_list.txt"
python3 Baselines/colmap/create_colmap_image_list.py "$rgb_csv" "$colmap_image_list" "$camera_name"
# Create Colmap Database
database="${exp_folder_colmap}/colmap_database.db"
rm -rf ${database}
colmap database_creator --database_path ${database}
# Feature extractor
echo " colmap feature_extractor ..."
if [ "${calibration_model}" == "unknown" ]
then
echo " camera model : $calibration_model"
colmap feature_extractor \
--database_path ${database} \
--image_path ${rgb_path} \
--image_list_path ${colmap_image_list} \
--ImageReader.camera_model SIMPLE_PINHOLE \
--ImageReader.single_camera 1 \
--ImageReader.single_camera_per_folder 1 \
--FeatureExtraction.use_gpu ${use_gpu}
fi
if [ "${calibration_model}" == "pinhole" ]
then
read -r calibration_model fx fy cx cy <<< $(python3 Baselines/colmap/get_calibration.py "$calibration_yaml" "$camera_name")
echo " camera model : $calibration_model"
echo " fx: $fx , fy: $fy , cx: $cx , cy: $cy"
colmap feature_extractor \
--database_path ${database} \
--image_path ${rgb_path} \
--image_list_path ${colmap_image_list} \
--ImageReader.camera_model PINHOLE \
--ImageReader.single_camera 1 \
--ImageReader.single_camera_per_folder 1 \
--FeatureExtraction.use_gpu ${use_gpu} \
--ImageReader.camera_params "${fx},${fy},${cx},${cy}"
fi
if [ "${calibration_model}" == "radtan4" ]
then
read -r calibration_model fx fy cx cy k1 k2 p1 p2 <<< $(python3 Baselines/colmap/get_calibration.py "$calibration_yaml" "$camera_name")
echo " camera model : $calibration_model"
echo " fx: $fx , fy: $fy , cx: $cx , cy: $cy"
echo " k1: $k1 , k2: $k2 , p1: $p1 , p2: $p2"
colmap feature_extractor \
--database_path ${database} \
--image_path ${rgb_path} \
--image_list_path ${colmap_image_list} \
--ImageReader.camera_model "OPENCV" \
--ImageReader.single_camera 1 \
--ImageReader.single_camera_per_folder 1 \
--FeatureExtraction.use_gpu ${use_gpu} \
--ImageReader.camera_params "${fx},${fy},${cx},${cy},${k1},${k2},${p1},${p2}"
fi
if [ "${calibration_model}" == "radtan5" ]
then
read -r calibration_model fx fy cx cy k1 k2 p1 p2 k3 <<< $(python3 Baselines/colmap/get_calibration.py "$calibration_yaml" "$camera_name")
echo " camera model : $calibration_model"
echo " fx: $fx , fy: $fy , cx: $cx , cy: $cy"
echo " k1: $k1 , k2: $k2 , p1: $p1 , p2: $p2, k3: $k3"
colmap feature_extractor \
--database_path ${database} \
--image_path ${rgb_path} \
--image_list_path ${colmap_image_list} \
--ImageReader.camera_model "FULL_OPENCV" \
--ImageReader.single_camera 1 \
--ImageReader.single_camera_per_folder 1 \
--FeatureExtraction.use_gpu ${use_gpu} \
--ImageReader.camera_params "${fx},${fy},${cx},${cy},${k1},${k2},${p1},${p2},${k3},0,0,0"
fi
if [ "${calibration_model}" == "equid4" ]
then
read -r calibration_model fx fy cx cy k1 k2 k3 k4 <<< $(python3 Baselines/colmap/get_calibration.py "$calibration_yaml" "$camera_name")
echo " camera model : $calibration_model"
echo " fx: $fx , fy: $fy , cx: $cx , cy: $cy"
echo " k1: $k1 , k2: $k2 , k3: $k3 , k4: $k4"
colmap feature_extractor \
--database_path ${database} \
--image_path ${rgb_path} \
--image_list_path ${colmap_image_list} \
--ImageReader.camera_model "OPENCV_FISHEYE"\
--ImageReader.single_camera 1 \
--ImageReader.single_camera_per_folder 1 \
--FeatureExtraction.use_gpu ${use_gpu} \
--ImageReader.camera_params "${fx},${fy},${cx},${cy},${k1},${k2},${k3},${k4}"
fi
# Exhaustive Feature Matcher
if [ "${matcher_type}" == "exhaustive" ]
then
echo " colmap exhaustive_matcher ..."
colmap exhaustive_matcher \
--database_path ${database} \
--FeatureMatching.use_gpu ${use_gpu}
fi
# Sequential Feature Matcher
if [ "${matcher_type}" == "sequential" ]
then
num_rgb=$(( $(wc -l < "$rgb_csv") - 1 ))
# Pick vocabulary tree based on the number of images
vocabulary_tree="Baselines/colmap/vocab_tree_flickr100K_words32K.bin"
if [ "$num_rgb" -gt 1000 ]; then
vocabulary_tree="Baselines/colmap/vocab_tree_flickr100K_words256K.bin"
fi
if [ "$num_rgb" -gt 10000 ]; then
vocabulary_tree="Baselines/colmap/vocab_tree_flickr100K_words1M.bin"
fi
echo " colmap sequential_matcher ..."
echo " Vocabulary Tree: $vocabulary_tree"
colmap sequential_matcher \
--database_path "${database}" \
--SequentialMatching.loop_detection 1 \
--SequentialMatching.vocab_tree_path ${vocabulary_tree} \
--FeatureMatching.use_gpu "${use_gpu}"
fi
# LightGlue Feature Matcher
if [ "${matcher_type}" == "custom" ]
then
colmap exhaustive_matcher \
--database_path ${database} \
--FeatureMatching.use_gpu ${use_gpu}
pixi run -e lightglue python3 Baselines/colmap/feature_matcher.py --database ${database} --rgb_path ${rgb_path} --rgb_csv ${rgb_csv}
fi
|