Fix point cloud densification with non-NVIDIA cards

pull/1374/head
Piero Toffanin 2021-11-24 11:02:36 -05:00
rodzic 4eba4cf310
commit 1dd0b4b457
4 zmienionych plików z 34 dodań i 26 usunięć

Wyświetl plik

@ -1,18 +0,0 @@
cmake_minimum_required(VERSION 2.8)
project(OpenDroneMap C CXX)
# TODO(edgar): add option in order to point to CMAKE_PREFIX_PATH
# if we want to build SuperBuild in an external directory.
# It is assumed that SuperBuild have been compiled.
# Set third party libs location
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild/install")
# move binaries to the same bin directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
option(ODM_BUILD_SLAM "Build SLAM module" OFF)
# Add ODM sub-modules
add_subdirectory(modules)

Wyświetl plik

@ -35,6 +35,13 @@ if(UNIX)
endif()
endif()
if(WIN32)
SET(NVDRIVER "$ENV{SystemRoot}\\System32\\nvcuda.dll")
if (EXISTS ${NVDRIVER})
file(COPY ${NVDRIVER} DESTINATION "${SB_INSTALL_DIR}/bin")
endif()
endif()
ExternalProject_Add(${_proj_name}
DEPENDS ceres opencv vcg eigen34
PREFIX ${_SB_BINARY_DIR}

Wyświetl plik

@ -24,3 +24,20 @@ def has_gpus():
return len(platforms) > 0
except Exception as e:
return False
@lru_cache(maxsize=None)
def windows_no_cuda():
"""
Check if CUDA lib is available on Windows
Returns true if OS is windows and CUDA is not found.
"""
if sys.platform == 'win32':
nvcuda_path = os.path.join(os.environ.get('SYSTEMROOT'), 'system32', 'nvcuda.dll')
if os.path.isfile(nvcuda_path):
return False
else:
log.ODM_INFO("No CUDA drivers detected, using CPU")
return True
else:
return False

Wyświetl plik

@ -6,7 +6,7 @@ from opendm import system
from opendm import context
from opendm import point_cloud
from opendm import types
from opendm.gpu import gpu_disabled_by_user
from opendm.gpu import gpu_disabled_by_user, windows_no_cuda
from opendm.utils import get_depthmap_resolution
from opendm.osfm import OSFMContext
from opendm.multispectral import get_primary_band_name
@ -71,8 +71,10 @@ class ODMOpenMVSStage(types.ODM_Stage):
"-v 0"
]
if gpu_disabled_by_user():
config.append("--cuda-device -1")
gpu_config = []
if gpu_disabled_by_user() or windows_no_cuda():
gpu_config.append("--cuda-device -1")
if args.pc_tile:
config.append("--fusion-mode 1")
@ -82,7 +84,7 @@ class ODMOpenMVSStage(types.ODM_Stage):
system.run('%s "%s" %s' % (context.omvs_densify_path,
openmvs_scene_file,
' '.join(config)))
' '.join(config + gpu_config)))
self.update_progress(85)
files_to_remove = []
@ -98,7 +100,7 @@ class ODMOpenMVSStage(types.ODM_Stage):
]
system.run('%s "%s" %s' % (context.omvs_densify_path,
openmvs_scene_file,
' '.join(config)))
' '.join(config + gpu_config)))
scene_files = glob.glob(os.path.join(tree.openmvs, "scene_[0-9][0-9][0-9][0-9].mvs"))
if len(scene_files) == 0:
@ -130,10 +132,10 @@ class ODMOpenMVSStage(types.ODM_Stage):
]
try:
system.run('%s "%s" %s' % (context.omvs_densify_path, sf, ' '.join(config)))
system.run('%s "%s" %s' % (context.omvs_densify_path, sf, ' '.join(config + gpu_config)))
# Filter
system.run('%s "%s" --filter-point-cloud -1 -v 0' % (context.omvs_densify_path, scene_dense_mvs))
system.run('%s "%s" --filter-point-cloud -1 -v 0 %s' % (context.omvs_densify_path, scene_dense_mvs, ' '.join(gpu_config)))
except:
log.ODM_WARNING("Sub-scene %s could not be reconstructed, skipping..." % sf)
@ -162,7 +164,7 @@ class ODMOpenMVSStage(types.ODM_Stage):
'-i "%s"' % scene_dense,
"-v 0"
]
system.run('%s %s' % (context.omvs_densify_path, ' '.join(config)))
system.run('%s %s' % (context.omvs_densify_path, ' '.join(config + gpu_config)))
else:
raise system.ExitException("Cannot find scene_dense.mvs, dense reconstruction probably failed. Exiting...")