colmap 三维重建脚本

2022-11-11  本文已影响0人  _49_

任务参数:task_params.sh

C_ID=dlzr3
SHOP_ID=cy
VIDEO_ID=V00
SEG_ID=seg_00

echo C_ID:${C_ID}
echo SHOP_ID:${SHOP_ID}
echo VIDEO_ID:${VIDEO_ID}
echo SEG_ID:${SEG_ID}

PanoSLAM:panoslam.sh

# [CPU]  PanoSLAM
# coscmd download -r dev_${ORG_PATH} ${ORG_PATH}
source task_params.sh

ORG_PATH=data/${C_ID}/${SHOP_ID}/org
PANOIMG_PATH=data/${C_ID}/${SHOP_ID}/pano_img

echo PanoSLAM ${ORG_PAHT} ${PANOIMG_PATH}

python dev/colmap_tools/src/cmd_tools/panoslam.py \
    --input_path ${ORG_PATH} \
    --output_path ${PANOIMG_PATH} 

PanoImages:panocut.sh

# [CPU] Pano images cut. 
source task_params.sh

PANOIMG_PATH=data/${C_ID}/${SHOP_ID}/pano_img
CUTIMG_PATH=data/${C_ID}/${SHOP_ID}/colmap/cut_img/${VIDEO_ID}

echo PanoImageCut ${PANOIMG_PATH}/${VIDEO_ID} ${CUTIMG_PATH}

python dev/colmap_tools/src/cmd_tools/panocutimg.py \
    --input_path ${PANOIMG_PATH}/${VIDEO_ID} \
    --output_path ${CUTIMG_PATH} \
    --fov 120 --arr_theta "[90]" --arr_phi "[0,60,120,180,240,300]" \
    --cut_size "[1500, 1500]" \
    --max_workers 16\
    --max_seg_count 1000 \
    --step 3


PanoVideo:panovideo.sh

source task_params.sh

PANOIMG_PATH=data/${C_ID}/${SHOP_ID}/pano_img/${VIDEO_ID}
PANOVIDEO_FULLPATH=data/${C_ID}/${SHOP_ID}/pano_video/${VIDEO_ID}.mp4

echo Panovideo ${PANOIMG_PATH}

python dev/colmap_tools/src/cmd_tools/images2video.py \
    --input_path ${PANOIMG_PATH} \
    --output_path ${PANOVIDEO_FULLPATH} \
    --overwrite "True"

FeatureExtractor:feature_extractor.sh

source task_params.sh

IMG_PATH=data/${C_ID}/${SHOP_ID}/colmap/cut_img/${VIDEO_ID}/${SEG_ID}
PROJ_PATH=data/${C_ID}/${SHOP_ID}/colmap/proj/${VIDEO_ID}/${SEG_ID}

# [CPU/GPU] SIFT 特征检测
mkdir -p ${PROJ_PATH}/feature_extractor
colmap feature_extractor \
    # --SiftExtraction.use_gpu 0 \
    --ImageReader.camera_model OPENCV \
    --ImageReader.single_camera_per_folder 1 \
    --SiftExtraction.estimate_affine_shape=true \
    --SiftExtraction.domain_size_pooling=true \
    --database_path "${PROJ_PATH}/feature_extractor/database.db" \
    --image_path ${IMG_PATH}

SequentialMatcher:sequential_matcher.sh

source task_params.sh

PROJ_PATH=data/${C_ID}/${SHOP_ID}/colmap/proj/${VIDEO_ID}/${SEG_ID}

# [GPU] SIFT 特征匹配  (强烈建议利用GPU,否则极慢)
mkdir -p ${PROJ_PATH}/sequential_matcher
cp ${PROJ_PATH}/feature_extractor/database.db ${PROJ_PATH}/sequential_matcher/database.db
colmap sequential_matcher \
    --SiftMatching.guided_matching=true \
    --SiftMatching.use_gpu 1 \
    --database_path "${PROJ_PATH}/sequential_matcher/database.db"

ExhaustiveMatcher:exhaustive_matcher.sh

source task_params.sh

PROJ_PATH=data/${C_ID}/${SHOP_ID}/colmap/proj/${VIDEO_ID}/${SEG_ID}

# [GPU] SIFT 特征匹配  (强烈建议利用GPU,否则极慢)
mkdir -p ${PROJ_PATH}/exhaustive_matcher
cp ${PROJ_PATH}/feature_extractor/database.db ${PROJ_PATH}/exhaustive_matcher/database.db
colmap exhaustive_matcher \
    --SiftMatching.guided_matching=true \
    --SiftMatching.use_gpu 1 \
    --database_path "${PROJ_PATH}/exhaustive_matcher/database.db"

Mapper:mapper.sh

目前 云端服务器 Mapper 速度明显慢于台式机。此问题还待解决。。。。

source task_params.sh

IMG_PATH=data/${C_ID}/${SHOP_ID}/colmap/cut_img/${VIDEO_ID}/${SEG_ID}
PROJ_PATH=data/${C_ID}/${SHOP_ID}/colmap/proj/${VIDEO_ID}/${SEG_ID}
DB_PATH=${PROJ_PATH}/sequential_matcher/database.db
OUTPUT_PATH=${PROJ_PATH}/sparse

# [CPU] 稀疏重建  (仅用到了CPU, 建议采用CPU服务器计算,效费比更高)
mkdir -p ${OUTPUT_PATH}
colmap mapper \
    --database_path ${DB_PATH} \
    --image_path ${IMG_PATH} \
    --output_path ${OUTPUT_PATH} \
    # --Mapper.ba_global_max_num_iterations 10

Hierarchical Mapper:hierarchical_mapper.sh

目前 云端服务器 Hierarchical Mapper 速度明显慢于台式机。此问题还待解决。。。。

source task_params.sh

IMG_PATH=data/${C_ID}/${SHOP_ID}/colmap/cut_img/${VIDEO_ID}/${SEG_ID}
PROJ_PATH=data/${C_ID}/${SHOP_ID}/colmap/proj/${VIDEO_ID}/${SEG_ID}
DB_PATH=${PROJ_PATH}/sequential_matcher/database.db
OUTPUT_PATH=${PROJ_PATH}/sparse

# [CPU] 稀疏重建  (仅用到了CPU, 建议采用CPU服务器计算,效费比更高)
mkdir -p ${OUTPUT_PATH}
colmap hierarchical_mapper \
    --database_path ${DB_PATH} \
    --image_path ${IMG_PATH} \
    --output_path ${OUTPUT_PATH} \
    # --Mapper.ba_global_max_num_iterations 10

稠密重建:第一步 undistorter.sh

source task_params.sh

IMG_PATH=data/${C_ID}/${SHOP_ID}/colmap/cut_img/${VIDEO_ID}/${SEG_ID}
PROJ_PATH=data/${C_ID}/${SHOP_ID}/colmap/proj/${VIDEO_ID}/${SEG_ID}
SPARSE_PATH=${PROJ_PATH}/sparse
DENSE_PATH=${PROJ_PATH}/dense

# [CPU] 稠密重建 第一步 去畸变
mkdir -p ${DENSE_PATH}
colmap image_undistorter \
    --image_path ${IMG_PATH} \
    --input_path ${SPARSE_PATH}/0 \
    --output_path ${DENSE_PATH} \
    --output_type COLMAP \
    --max_image_size 3840

稠密重建:第二步 stereo.sh

source task_params.sh

PROJ_PATH=data/${C_ID}/${SHOP_ID}/colmap/proj/${VIDEO_ID}/${SEG_ID}
DENSE_PATH=${PROJ_PATH}/dense

# [GPU] 稠密重建 第二步 stereo 
colmap patch_match_stereo \
    --workspace_path ${DENSE_PATH} \
    --workspace_format COLMAP \
    --PatchMatchStereo.max_image_size 1500 \
    --PatchMatchStereo.window_radius 9 \
    --PatchMatchStereo.geom_consistency true \
    --PatchMatchStereo.filter_min_ncc 0.07

稠密重建:第三步 fusion.sh

source task_params.sh

PROJ_PATH=data/${C_ID}/${SHOP_ID}/colmap/proj/${VIDEO_ID}/${SEG_ID}
DENSE_PATH=${PROJ_PATH}/dense

# [GPU] 稠密重建 第三步 fusion
colmap stereo_fusion \
    --workspace_path ${DENSE_PATH} \
    --workspace_format COLMAP \
    --input_type geometric \
    --output_path ${DENSE_PATH}/fused.ply
上一篇下一篇

猜你喜欢

热点阅读