Last active
November 30, 2021 22:43
-
-
Save readicculus/552ed02ce1d4c4296a5b6212db6478cb to your computer and use it in GitHub Desktop.
Camera Model Generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colmap exhaustive_matcher \ | |
--database_path fl09.db \ | |
--SiftMatching.num_threads=-1 \ | |
--SiftMatching.use_gpu=1 \ | |
--SiftMatching.gpu_index=0 \ | |
--SiftMatching.max_ratio=0.80000000000000004 \ | |
--SiftMatching.max_distance=0.69999999999999996 \ | |
--SiftMatching.cross_check=1 \ | |
--SiftMatching.max_error=4 \ | |
--SiftMatching.max_num_matches=32768 \ | |
--SiftMatching.confidence=0.999 \ | |
--SiftMatching.max_num_trials=10000 \ | |
--SiftMatching.min_inlier_ratio=0.25 \ | |
--SiftMatching.min_num_inliers=15 \ | |
--SiftMatching.multiple_models=0 \ | |
--SiftMatching.guided_matching=0 \ | |
--ExhaustiveMatching.block_size=50 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colmap feature_extractor \ | |
--database_path fl09.db \ | |
--image_path images \ | |
--ImageReader.camera_model=OPENCV \ | |
--ImageReader.single_camera=0 \ | |
--ImageReader.single_camera_per_folder=1 \ | |
--ImageReader.existing_camera_id=-1 \ | |
--ImageReader.default_focal_length_factor=1.2 \ | |
--SiftExtraction.num_threads=-1 \ | |
--SiftExtraction.use_gpu=1 \ | |
--SiftExtraction.gpu_index=-1 \ | |
--SiftExtraction.max_image_size=3200 \ | |
--SiftExtraction.max_num_features=8192 \ | |
--SiftExtraction.first_octave=-1 \ | |
--SiftExtraction.num_octaves=4 \ | |
--SiftExtraction.octave_resolution=3 \ | |
--SiftExtraction.peak_threshold=0.0066666666666666671 \ | |
--SiftExtraction.edge_threshold=10 \ | |
--SiftExtraction.estimate_affine_shape=0 \ | |
--SiftExtraction.max_num_orientations=2 \ | |
--SiftExtraction.upright=0 \ | |
--SiftExtraction.domain_size_pooling=0 \ | |
--SiftExtraction.dsp_min_scale=0.16666666666666666 \ | |
--SiftExtraction.dsp_max_scale=3 \ | |
--SiftExtraction.dsp_num_scales=10 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
colmap mapper \ | |
--database_path fl09.db \ | |
--image_path images \ | |
--output_path sparse \ | |
--Mapper.min_num_matches=15 \ | |
--Mapper.ignore_watermarks=0 \ | |
--Mapper.multiple_models=1 \ | |
--Mapper.max_num_models=50 \ | |
--Mapper.max_model_overlap=20 \ | |
--Mapper.min_model_size=10 \ | |
--Mapper.init_image_id1=-1 \ | |
--Mapper.init_image_id2=-1 \ | |
--Mapper.init_num_trials=200 \ | |
--Mapper.extract_colors=1 \ | |
--Mapper.num_threads=-1 \ | |
--Mapper.min_focal_length_ratio=0.10000000000000001 \ \ | |
--Mapper.max_focal_length_ratio=10 \ | |
--Mapper.max_extra_param=1 \ | |
--Mapper.ba_refine_focal_length=1 \ | |
--Mapper.ba_refine_principal_point=0 \ | |
--Mapper.ba_refine_extra_params=1 \ | |
--Mapper.ba_min_num_residuals_for_multi_threading=50000 \ | |
--Mapper.ba_local_num_images=6 \ | |
--Mapper.ba_local_max_num_iterations=25 \ | |
--Mapper.ba_global_use_pba=0 \ | |
--Mapper.ba_global_pba_gpu_index=-1 \ | |
--Mapper.ba_global_images_ratio=1.1000000000000001 \ | |
--Mapper.ba_global_points_ratio=1.1000000000000001 \ | |
--Mapper.ba_global_images_freq=500 \ | |
--Mapper.ba_global_points_freq=250000 \ | |
--Mapper.ba_global_max_num_iterations=50 \ | |
--Mapper.ba_global_max_refinements=5 \ | |
--Mapper.ba_global_max_refinement_change=0.00050000000000000001 \ | |
--Mapper.ba_local_max_refinements=2 \ | |
--Mapper.ba_local_max_refinement_change=0.001 \ | |
--Mapper.snapshot_path arg \ | |
--Mapper.snapshot_images_freq=0 \ | |
--Mapper.fix_existing_images=0 \ | |
--Mapper.init_min_num_inliers=100 \ | |
--Mapper.init_max_error=4 \ | |
--Mapper.init_max_forward_motion=0.94999999999999996 \ | |
--Mapper.init_min_tri_angle=16 \ | |
--Mapper.init_max_reg_trials=2 \ | |
--Mapper.abs_pose_max_error=12 \ | |
--Mapper.abs_pose_min_num_inliers=30 \ | |
--Mapper.abs_pose_min_inlier_ratio=0.25 \ | |
--Mapper.filter_max_reproj_error=4 \ | |
--Mapper.filter_min_tri_angle=1.5 \ | |
--Mapper.max_reg_trials=3 \ | |
--Mapper.tri_max_transitivity=1 \ | |
--Mapper.tri_create_max_angle_error=2 \ | |
--Mapper.tri_continue_max_angle_error=2 \ | |
--Mapper.tri_merge_max_reproj_error=4 \ | |
--Mapper.tri_complete_max_reproj_error=4 \ | |
--Mapper.tri_complete_max_transitivity=5 \ | |
--Mapper.tri_re_max_angle_error=5 \ | |
--Mapper.tri_re_min_ratio=0.20000000000000001 \ | |
--Mapper.tri_re_max_trials=1 \ | |
--Mapper.tri_min_angle=1.5 \ | |
--Mapper.tri_ignore_two_view_tracks=1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import subprocess | |
from copy import copy | |
import matplotlib.pyplot as plt | |
def model_analyze(path): | |
result = subprocess.run(['colmap', 'model_analyzer', '--path', path], stdout=subprocess.PIPE) | |
print('\n=================') | |
print("Model: %s" % path) | |
print(result.stdout.decode('utf-8')) | |
sparse_folder_path = 'sparse_temp' | |
models = sorted([os.path.join(sparse_folder_path, x) for x in os.listdir(sparse_folder_path)]) | |
print('All Models: ' + str(models)) | |
for s in models: | |
model_analyze(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
import cv2 | |
import numpy as np | |
def normalize(im): | |
# min = np.amin(im, axis=tuple(range(3 - 1))) | |
# max = np.amax(im, axis=tuple(range(3 - 1))) | |
# im_ir = ((im - min) / (max - min)) | |
# im_ir = im_ir*255.0 | |
# im_ir = im_ir.astype(np.uint8) | |
# return im_ir | |
im_ir = ((im - np.min(im)) / (0.0 + np.max(im) - np.min(im))) | |
im_ir = im_ir*255.0 | |
im_ir = im_ir.astype(np.uint8) | |
return im_ir | |
def process_dir(input_dir, ext_pattern, output_dir, preproc_fn=None): | |
os.makedirs(output_dir, exist_ok=True) | |
files = os.listdir(input_dir) | |
images = [] | |
for fn in files: | |
if fn.endswith(ext_pattern): | |
images.append(os.path.abspath(os.path.join(input_dir,fn))) | |
total = len(images) | |
for idx, im_fp in enumerate(images): | |
print(f'{idx}/{total}') | |
dest_fp = os.path.abspath(os.path.join(output_dir, os.path.basename(im_fp))) | |
if os.path.isfile(dest_fp): | |
print(f'skipping {dest_fp} already exists') | |
continue | |
if preproc_fn: | |
im = cv2.imread(im_fp, -1) | |
im = normalize(im) | |
cv2.imwrite(dest_fp, im) | |
print(f'Wrote {dest_fp}') | |
x=1 | |
else: | |
shutil.copy(im_fp, dest_fp) | |
print(f'Copied {dest_fp}') | |
x=1 | |
process_dir('images/center_view/', 'uv.jpg', 'project/images/center_view_uv/', preproc_fn=normalize) | |
process_dir('images/left_view/', 'uv.jpg', 'project/images/left_view_uv/', preproc_fn=normalize) | |
process_dir('images/right_view/', 'uv.jpg', 'project/images/right_view_uv/', preproc_fn=normalize) | |
process_dir('images/center_view/', 'rgb.jpg', 'project/images/center_view_rgb/') | |
process_dir('images/left_view/', 'rgb.jpg', 'project/images/left_view_rgb/') | |
process_dir('images/right_view/', 'rgb.jpg', 'project/images/right_view_rgb/') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment