Handle large images with GPU_SIFT, update OpenMVS

pull/1383/head
Piero Toffanin 2021-12-17 11:57:03 -05:00
rodzic b8cf083020
commit 70face0492
5 zmienionych plików z 36 dodań i 9 usunięć

Wyświetl plik

@ -52,7 +52,7 @@ ExternalProject_Add(${_proj_name}
#--Download step--------------
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
GIT_REPOSITORY https://github.com/OpenDroneMap/openMVS
GIT_TAG 268
GIT_TAG 270
#--Update/Patch step----------
UPDATE_COMMAND ""
#--Configure step-------------

Wyświetl plik

@ -19,7 +19,7 @@ ExternalProject_Add(${_proj_name}
#--Download step--------------
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
GIT_REPOSITORY https://github.com/OpenDroneMap/OpenSfM/
GIT_TAG 268
GIT_TAG 270
#--Update/Patch step----------
UPDATE_COMMAND git submodule update --init --recursive
#--Configure step-------------

Wyświetl plik

@ -8,10 +8,13 @@ def gpu_disabled_by_user():
return bool(os.environ.get('ODM_NO_GPU'))
@lru_cache(maxsize=None)
def has_popsift():
def has_popsift_and_can_handle_texsize(width, height):
try:
from opensfm import pypopsift
return True
fits = pypopsift.fits_texture(width, height)
if not fits:
log.ODM_WARNING("Image size (%sx%spx) would not fit in GPU memory, falling back to CPU" % (width, height))
return fits
except:
return False

Wyświetl plik

@ -14,14 +14,14 @@ from opendm import context
from opendm import camera
from opendm import location
from opendm.utils import get_depthmap_resolution
from opendm.photo import find_largest_photo_dim
from opendm.photo import find_largest_photo_dim, find_largest_photo
from opensfm.large import metadataset
from opensfm.large import tools
from opensfm.actions import undistort
from opensfm.dataset import DataSet
from opensfm import report
from opendm.multispectral import get_photos_by_band
from opendm.gpu import has_popsift, has_gpu
from opendm.gpu import has_popsift_and_can_handle_texsize, has_gpu
from opensfm import multiview, exif
from opensfm.actions.export_geocoords import _transform
@ -201,9 +201,19 @@ class OSFMContext:
config.append("matcher_type: %s" % osfm_matchers[matcher_type])
# GPU acceleration?
if has_gpu() and has_popsift() and feature_type == "SIFT":
log.ODM_INFO("Using GPU for extracting SIFT features")
feature_type = "SIFT_GPU"
if has_gpu():
max_photo = find_largest_photo(photos)
w, h = max_photo.width, max_photo.height
if w > h:
h = (h / w) * feature_process_size
w = feature_process_size
else:
w = (w / h) * feature_process_size
h = feature_process_size
if has_popsift_and_can_handle_texsize(w, h) and feature_type == "SIFT":
log.ODM_INFO("Using GPU for extracting SIFT features")
feature_type = "SIFT_GPU"
config.append("feature_type: %s" % feature_type)

Wyświetl plik

@ -41,6 +41,20 @@ def find_largest_photo_dim(photos):
return max_dim
def find_largest_photo(photos):
max_p = None
max_area = 0
for p in photos:
if p.width is None:
continue
area = p.width * p.height
if area > max_area:
max_area = area
max_p = p
return p
def get_mm_per_unit(resolution_unit):
"""Length of a resolution unit in millimeters.