kopia lustrzana https://github.com/OpenDroneMap/ODM
Merge pull request #389 from paulinus/dense
Add option to use OpenSfM to compute the point cloud
Former-commit-id: 4883fa0ee7
pull/1161/head
commit
75b0991cc1
|
@ -8,8 +8,8 @@ ExternalProject_Add(${_proj_name}
|
||||||
STAMP_DIR ${_SB_BINARY_DIR}/stamp
|
STAMP_DIR ${_SB_BINARY_DIR}/stamp
|
||||||
#--Download step--------------
|
#--Download step--------------
|
||||||
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
|
DOWNLOAD_DIR ${SB_DOWNLOAD_DIR}
|
||||||
URL https://github.com/mapillary/OpenSfM/archive/a4b07056aec1184692c1432fbdd1074710aec32b.zip
|
URL https://github.com/mapillary/OpenSfM/archive/odm-3.zip
|
||||||
URL_MD5 42B2B1994C3309BBF4525C8CC1F6F741
|
URL_MD5 a0853c6fe6d8193f7006e17dd896154e
|
||||||
#--Update/Patch step----------
|
#--Update/Patch step----------
|
||||||
UPDATE_COMMAND ""
|
UPDATE_COMMAND ""
|
||||||
#--Configure step-------------
|
#--Configure step-------------
|
||||||
|
@ -17,6 +17,8 @@ ExternalProject_Add(${_proj_name}
|
||||||
CONFIGURE_COMMAND cmake <SOURCE_DIR>/${_proj_name}/src
|
CONFIGURE_COMMAND cmake <SOURCE_DIR>/${_proj_name}/src
|
||||||
-DCERES_ROOT_DIR=${SB_INSTALL_DIR}
|
-DCERES_ROOT_DIR=${SB_INSTALL_DIR}
|
||||||
-DOpenCV_DIR=${SB_INSTALL_DIR}/share/OpenCV
|
-DOpenCV_DIR=${SB_INSTALL_DIR}/share/OpenCV
|
||||||
|
-DOPENSFM_BUILD_TESTS=off
|
||||||
|
|
||||||
#--Build step-----------------
|
#--Build step-----------------
|
||||||
BINARY_DIR ${_SB_BINARY_DIR}
|
BINARY_DIR ${_SB_BINARY_DIR}
|
||||||
#--Install step---------------
|
#--Install step---------------
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
## Set up library paths
|
||||||
|
RUNPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
export PYTHONPATH=$RUNPATH/SuperBuild/install/lib/python2.7/dist-packages:$RUNPATH/SuperBuild/src/opensfm:$PYTHONPATH
|
||||||
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$RUNPATH/SuperBuild/install/lib
|
||||||
|
|
||||||
## Before installing
|
## Before installing
|
||||||
echo "Updating the system"
|
echo "Updating the system"
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
|
@ -53,7 +58,8 @@ sudo apt-get install -y -qq python-networkx \
|
||||||
libboost-regex-dev \
|
libboost-regex-dev \
|
||||||
libboost-python-dev \
|
libboost-python-dev \
|
||||||
libboost-date-time-dev \
|
libboost-date-time-dev \
|
||||||
libboost-thread-dev
|
libboost-thread-dev \
|
||||||
|
python-pyproj
|
||||||
|
|
||||||
sudo pip install -U PyYAML \
|
sudo pip install -U PyYAML \
|
||||||
exifread \
|
exifread \
|
||||||
|
|
|
@ -110,6 +110,12 @@ def config():
|
||||||
'images based on GPS exif data. Set to 0 to skip '
|
'images based on GPS exif data. Set to 0 to skip '
|
||||||
'pre-matching. Default: %(default)s')
|
'pre-matching. Default: %(default)s')
|
||||||
|
|
||||||
|
parser.add_argument('--use-opensfm-pointcloud',
|
||||||
|
action='store_true',
|
||||||
|
default=False,
|
||||||
|
help='Use OpenSfM to compute the point cloud instead '
|
||||||
|
'of PMVS')
|
||||||
|
|
||||||
parser.add_argument('--cmvs-maxImages',
|
parser.add_argument('--cmvs-maxImages',
|
||||||
metavar='<integer>',
|
metavar='<integer>',
|
||||||
default=500,
|
default=500,
|
||||||
|
|
|
@ -360,6 +360,7 @@ class ODM_Tree(object):
|
||||||
self.opensfm_bundle_list = io.join_paths(self.opensfm, 'list_r000.out')
|
self.opensfm_bundle_list = io.join_paths(self.opensfm, 'list_r000.out')
|
||||||
self.opensfm_image_list = io.join_paths(self.opensfm, 'image_list.txt')
|
self.opensfm_image_list = io.join_paths(self.opensfm, 'image_list.txt')
|
||||||
self.opensfm_reconstruction = io.join_paths(self.opensfm, 'reconstruction.json')
|
self.opensfm_reconstruction = io.join_paths(self.opensfm, 'reconstruction.json')
|
||||||
|
self.opensfm_model = io.join_paths(self.opensfm, 'depthmaps/merged.ply')
|
||||||
|
|
||||||
# pmvs
|
# pmvs
|
||||||
self.pmvs_rec_path = io.join_paths(self.pmvs, 'recon0')
|
self.pmvs_rec_path = io.join_paths(self.pmvs, 'recon0')
|
||||||
|
|
|
@ -85,6 +85,10 @@ class ODMMvsTexCell(ecto.Cell):
|
||||||
'keepUnseenFaces': keepUnseenFaces
|
'keepUnseenFaces': keepUnseenFaces
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if args.use_opensfm_pointcloud:
|
||||||
|
kwargs['nvm_file'] = io.join_paths(tree.opensfm,
|
||||||
|
"reconstruction.nvm")
|
||||||
|
else:
|
||||||
log.ODM_DEBUG('Generating .nvm file from pmvs output: %s'
|
log.ODM_DEBUG('Generating .nvm file from pmvs output: %s'
|
||||||
% '{nvm_file}'.format(**kwargs))
|
% '{nvm_file}'.format(**kwargs))
|
||||||
|
|
||||||
|
|
|
@ -110,6 +110,12 @@ class ODMApp(ecto.BlackBox):
|
||||||
self.args[:] >> self.opensfm['args'],
|
self.args[:] >> self.opensfm['args'],
|
||||||
self.resize['photos'] >> self.opensfm['photos']]
|
self.resize['photos'] >> self.opensfm['photos']]
|
||||||
|
|
||||||
|
if _p.args.use_opensfm_pointcloud:
|
||||||
|
# create odm mesh from opensfm point cloud
|
||||||
|
connections += [self.tree[:] >> self.meshing['tree'],
|
||||||
|
self.args[:] >> self.meshing['args'],
|
||||||
|
self.opensfm['reconstruction'] >> self.meshing['reconstruction']]
|
||||||
|
else:
|
||||||
# run cmvs
|
# run cmvs
|
||||||
connections += [self.tree[:] >> self.cmvs['tree'],
|
connections += [self.tree[:] >> self.cmvs['tree'],
|
||||||
self.args[:] >> self.cmvs['args'],
|
self.args[:] >> self.cmvs['args'],
|
||||||
|
@ -120,7 +126,7 @@ class ODMApp(ecto.BlackBox):
|
||||||
self.args[:] >> self.pmvs['args'],
|
self.args[:] >> self.pmvs['args'],
|
||||||
self.cmvs['reconstruction'] >> self.pmvs['reconstruction']]
|
self.cmvs['reconstruction'] >> self.pmvs['reconstruction']]
|
||||||
|
|
||||||
# create odm mesh
|
# create odm mesh from pmvs point cloud
|
||||||
connections += [self.tree[:] >> self.meshing['tree'],
|
connections += [self.tree[:] >> self.meshing['tree'],
|
||||||
self.args[:] >> self.meshing['args'],
|
self.args[:] >> self.meshing['args'],
|
||||||
self.pmvs['reconstruction'] >> self.meshing['reconstruction']]
|
self.pmvs['reconstruction'] >> self.meshing['reconstruction']]
|
||||||
|
|
|
@ -85,7 +85,6 @@ class ODMGeoreferencingCell(ecto.Cell):
|
||||||
'imgs': tree.dataset_resize,
|
'imgs': tree.dataset_resize,
|
||||||
'imgs_list': tree.opensfm_bundle_list,
|
'imgs_list': tree.opensfm_bundle_list,
|
||||||
'model': tree.odm_textured_model_obj,
|
'model': tree.odm_textured_model_obj,
|
||||||
'pc': tree.pmvs_model,
|
|
||||||
'log': tree.odm_georeferencing_log,
|
'log': tree.odm_georeferencing_log,
|
||||||
'coords': tree.odm_georeferencing_coords,
|
'coords': tree.odm_georeferencing_coords,
|
||||||
'pc_geo': tree.odm_georeferencing_model_ply_geo,
|
'pc_geo': tree.odm_georeferencing_model_ply_geo,
|
||||||
|
@ -95,6 +94,10 @@ class ODMGeoreferencingCell(ecto.Cell):
|
||||||
'gcp': gcpfile,
|
'gcp': gcpfile,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if args.use_opensfm_pointcloud:
|
||||||
|
kwargs['pc'] = tree.opensfm_model
|
||||||
|
else:
|
||||||
|
kwargs['pc'] = tree.pmvs_model
|
||||||
|
|
||||||
if self.params.use_gcp and \
|
if self.params.use_gcp and \
|
||||||
io.file_exists(gcpfile):
|
io.file_exists(gcpfile):
|
||||||
|
|
|
@ -52,7 +52,6 @@ class ODMeshingCell(ecto.Cell):
|
||||||
|
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'bin': context.odm_modules_path,
|
'bin': context.odm_modules_path,
|
||||||
'infile': tree.pmvs_model,
|
|
||||||
'outfile': tree.odm_mesh,
|
'outfile': tree.odm_mesh,
|
||||||
'log': tree.odm_meshing_log,
|
'log': tree.odm_meshing_log,
|
||||||
'max_vertex': self.params.max_vertex,
|
'max_vertex': self.params.max_vertex,
|
||||||
|
@ -60,6 +59,10 @@ class ODMeshingCell(ecto.Cell):
|
||||||
'samples': self.params.samples,
|
'samples': self.params.samples,
|
||||||
'solver': self.params.solver
|
'solver': self.params.solver
|
||||||
}
|
}
|
||||||
|
if args.use_opensfm_pointcloud:
|
||||||
|
kwargs['infile'] = tree.opensfm_model
|
||||||
|
else:
|
||||||
|
kwargs['infile'] = tree.pmvs_model
|
||||||
|
|
||||||
# run meshing binary
|
# run meshing binary
|
||||||
system.run('{bin}/odm_meshing -inputFile {infile} '
|
system.run('{bin}/odm_meshing -inputFile {infile} '
|
||||||
|
|
|
@ -48,9 +48,13 @@ class ODMOpenSfMCell(ecto.Cell):
|
||||||
(args.rerun_from is not None and
|
(args.rerun_from is not None and
|
||||||
'opensfm' in args.rerun_from)
|
'opensfm' in args.rerun_from)
|
||||||
|
|
||||||
# check if reconstruction was done before
|
if args.use_opensfm_pointcloud:
|
||||||
|
output_file = tree.opensfm_model
|
||||||
|
else:
|
||||||
|
output_file = tree.opensfm_reconstruction
|
||||||
|
|
||||||
if not io.file_exists(tree.opensfm_reconstruction) or rerun_cell:
|
# check if reconstruction was done before
|
||||||
|
if not io.file_exists(output_file) or rerun_cell:
|
||||||
# create file list
|
# create file list
|
||||||
list_path = io.join_paths(tree.opensfm, 'image_list.txt')
|
list_path = io.join_paths(tree.opensfm, 'image_list.txt')
|
||||||
with open(list_path, 'w') as fout:
|
with open(list_path, 'w') as fout:
|
||||||
|
@ -77,12 +81,18 @@ class ODMOpenSfMCell(ecto.Cell):
|
||||||
# run OpenSfM reconstruction
|
# run OpenSfM reconstruction
|
||||||
system.run('PYTHONPATH=%s %s/bin/run_all %s' %
|
system.run('PYTHONPATH=%s %s/bin/run_all %s' %
|
||||||
(context.pyopencv_path, context.opensfm_path, tree.opensfm))
|
(context.pyopencv_path, context.opensfm_path, tree.opensfm))
|
||||||
|
if args.use_opensfm_pointcloud:
|
||||||
|
system.run('PYTHONPATH=%s %s/bin/opensfm export_visualsfm %s' %
|
||||||
|
(context.pyopencv_path, context.opensfm_path, tree.opensfm))
|
||||||
|
system.run('PYTHONPATH=%s %s/bin/opensfm undistort %s' %
|
||||||
|
(context.pyopencv_path, context.opensfm_path, tree.opensfm))
|
||||||
|
system.run('PYTHONPATH=%s %s/bin/opensfm compute_depthmaps %s' %
|
||||||
|
(context.pyopencv_path, context.opensfm_path, tree.opensfm))
|
||||||
else:
|
else:
|
||||||
log.ODM_WARNING('Found a valid OpenSfM file in: %s' %
|
log.ODM_WARNING('Found a valid OpenSfM file in: %s' %
|
||||||
tree.opensfm_reconstruction)
|
tree.opensfm_reconstruction)
|
||||||
|
|
||||||
# check if reconstruction was exported to bundler before
|
# check if reconstruction was exported to bundler before
|
||||||
|
|
||||||
if not io.file_exists(tree.opensfm_bundle_list) or rerun_cell:
|
if not io.file_exists(tree.opensfm_bundle_list) or rerun_cell:
|
||||||
# convert back to bundler's format
|
# convert back to bundler's format
|
||||||
system.run('PYTHONPATH=%s %s/bin/export_bundler %s' %
|
system.run('PYTHONPATH=%s %s/bin/export_bundler %s' %
|
||||||
|
@ -91,8 +101,8 @@ class ODMOpenSfMCell(ecto.Cell):
|
||||||
log.ODM_WARNING('Found a valid Bundler file in: %s' %
|
log.ODM_WARNING('Found a valid Bundler file in: %s' %
|
||||||
tree.opensfm_reconstruction)
|
tree.opensfm_reconstruction)
|
||||||
|
|
||||||
|
if not args.use_opensfm_pointcloud:
|
||||||
# check if reconstruction was exported to pmvs before
|
# check if reconstruction was exported to pmvs before
|
||||||
|
|
||||||
if not io.file_exists(tree.pmvs_visdat) or rerun_cell:
|
if not io.file_exists(tree.pmvs_visdat) or rerun_cell:
|
||||||
# run PMVS converter
|
# run PMVS converter
|
||||||
system.run('PYTHONPATH=%s %s/bin/export_pmvs %s --output %s' %
|
system.run('PYTHONPATH=%s %s/bin/export_pmvs %s --output %s' %
|
||||||
|
|
Ładowanie…
Reference in New Issue