Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaptive feature quality #1714

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions opendm/osfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from opendm import context
from opendm import camera
from opendm import location
from opendm.photo import find_largest_photo_dim, find_largest_photo
from opendm.photo import find_largest_photo_dims, find_largest_photo
from opensfm.large import metadataset
from opensfm.large import tools
from opensfm.actions import undistort
Expand Down Expand Up @@ -211,11 +211,25 @@ def setup(self, args, images_path, reconstruction, append_config = [], rerun=Fal
'lowest': 0.0675,
}

max_dim = find_largest_photo_dim(photos)
max_dims = find_largest_photo_dims(photos)

if max_dim > 0:
if max_dims is not None:
w, h = max_dims
max_dim = max(w, h)
log.ODM_INFO("Maximum photo dimensions: %spx" % str(max_dim))
feature_process_size = int(max_dim * feature_quality_scale[args.feature_quality])

lower_limit = 320
upper_limit = 4480
megapixels = (w * h) / 1e6
multiplier = 1

if megapixels < 2:
multiplier = 2
elif megapixels > 42:
multiplier = 0.5

factor = min(1, feature_quality_scale[args.feature_quality] * multiplier)
feature_process_size = min(upper_limit, max(lower_limit, int(max_dim * factor)))
log.ODM_INFO("Photo dimensions for feature extraction: %ipx" % feature_process_size)
else:
log.ODM_WARNING("Cannot compute max image dimensions, going with defaults")
Expand Down Expand Up @@ -283,9 +297,8 @@ def setup(self, args, images_path, reconstruction, append_config = [], rerun=Fal
config.append("matcher_type: %s" % osfm_matchers[matcher_type])

# GPU acceleration?
if has_gpu(args):
max_photo = find_largest_photo(photos)
w, h = max_photo.width, max_photo.height
if has_gpu(args) and max_dims is not None:
w, h = max_dims
if w > h:
h = int((h / w) * feature_process_size)
w = int(feature_process_size)
Expand Down