Add --feature-quality, deprecate --resize-to

Former-commit-id: 8ed2c3474f
pull/1161/head
Piero Toffanin 2020-09-11 14:44:19 -04:00
rodzic 9c89aa69e7
commit 8d26620d58
2 zmienionych plików z 39 dodań i 3 usunięć

Wyświetl plik

@ -90,9 +90,9 @@ def config(argv=None):
action=StoreValue,
default=2048,
type=int,
help='Resizes images by the largest side for feature extraction purposes only. '
help='Legacy option (use --feature-quality instead). Resizes images by the largest side for feature extraction purposes only. '
'Set to -1 to disable. This does not affect the final orthophoto '
' resolution quality and will not resize the original images. Default: %(default)s')
'resolution quality and will not resize the original images. Default: %(default)s')
parser.add_argument('--end-with', '-e',
metavar='<string>',
@ -146,6 +146,15 @@ def config(argv=None):
help=('Choose the algorithm for extracting keypoints and computing descriptors. '
'Can be one of: [sift, hahog]. Default: '
'%(default)s'))
parser.add_argument('--feature-quality',
metavar='<string>',
action=StoreValue,
default='high',
choices=['ultra', 'high', 'medium', 'low', 'lowest'],
help=('Set feature extraction quality. Higher quality computes better features, but requires more memory takes longer. '
'Can be one of: [ultra, high, medium, low, lowest]. Default: '
'%(default)s'))
parser.add_argument('--matcher-neighbors',
metavar='<integer>',

Wyświetl plik

@ -130,12 +130,39 @@ class OSFMContext:
with open(os.path.join(self.opensfm_project_path, "exif_overrides.json"), 'w') as f:
f.write(json.dumps(exif_overrides))
# Compute feature_process_size
feature_process_size = 2048 # default
if 'resize_to_is_set' in args:
# Legacy
log.ODM_WARNING("Legacy option --resize-to (this might be removed in a future version). Use --feature-quality instead.")
feature_process_size = int(args.resize_to)
else:
feature_quality_scale = {
'ultra': 1,
'high': 0.5,
'medium': 0.25,
'low': 0.125,
'lowest': 0.0675,
}
# Find largest photo dimension
max_dim = 0
for p in photos:
if p.width is None:
continue
max_dim = max(max_dim, max(p.width, p.height))
if max_dim > 0:
log.ODM_INFO("Maximum photo dimensions: %spx" % str(max_dim))
feature_process_size = int(max_dim * feature_quality_scale[args.feature_quality])
else:
log.ODM_WARNING("Cannot compute max image dimensions, going with defaults")
# create config file for OpenSfM
config = [
"use_exif_size: no",
"flann_algorithm: KDTREE", # more stable, faster than KMEANS
"feature_process_size: %s" % args.resize_to,
"feature_process_size: %s" % feature_process_size,
"feature_min_frames: %s" % args.min_num_features,
"processes: %s" % args.max_concurrency,
"matching_gps_neighbors: %s" % matcher_neighbors,