Added fast-orthophoto param, modified ODM pipeline to skip dense reconstruction

Former-commit-id: 6492a4e1c3
pull/1161/head
Piero Toffanin 2018-01-02 12:38:15 -05:00
rodzic faecd136d2
commit 2603d2eddb
5 zmienionych plików z 61 dodań i 33 usunięć

Wyświetl plik

@ -104,7 +104,7 @@ def config():
parser.add_argument('--min-num-features',
metavar='<integer>',
default=4000,
default=8000,
type=int,
help=('Minimum number of features to extract per image. '
'More features leads to better results but slower '
@ -492,10 +492,6 @@ def config():
args = parser.parse_args()
if args.fast_orthophoto:
log.ODM_INFO('Fast orthophoto is turned on, automatically setting --use-25dmesh')
args.use_25dmesh = True
# check that the project path setting has been set properly
if not args.project_path:
log.ODM_ERROR('You need to set the project path in the '
@ -504,4 +500,13 @@ def config():
'run.py --help` for more information. ')
sys.exit(1)
if args.fast_orthophoto:
log.ODM_INFO('Fast orthophoto is turned on, automatically setting --use-25dmesh')
args.use_25dmesh = True
# Cannot use pmvs
if args.use_pmvs:
log.ODM_INFO('Fast orthophoto is turned on, cannot use pmvs (removing --use-pmvs)')
args.use_pmvs = False
return args

Wyświetl plik

@ -53,6 +53,9 @@ class ODMMvsTexCell(ecto.Cell):
'model': tree.odm_mesh
}]
if args.fast_orthophoto:
runs = []
if args.use_25dmesh:
runs += [{
'out_dir': tree.odm_25dtexturing,

Wyświetl plik

@ -92,6 +92,10 @@ class ODMGeoreferencingCell(ecto.Cell):
'texturing_dir': tree.odm_texturing,
'model': os.path.join(tree.odm_texturing, tree.odm_textured_model_obj)
}]
if args.fast_orthophoto:
runs = []
if args.use_25dmesh:
runs += [{
'georeferencing_dir': tree.odm_25dgeoreferencing,
@ -126,7 +130,10 @@ class ODMGeoreferencingCell(ecto.Cell):
}
if not args.use_pmvs:
kwargs['pc'] = tree.opensfm_model
if args.fast_orthophoto:
kwargs['pc'] = os.path.join(tree.opensfm, 'reconstruction.ply')
else:
kwargs['pc'] = tree.opensfm_model
else:
kwargs['pc'] = tree.pmvs_model

Wyświetl plik

@ -1,4 +1,4 @@
import ecto
import ecto, os
from opendm import log
from opendm import io
@ -52,32 +52,37 @@ class ODMeshingCell(ecto.Cell):
infile = tree.opensfm_model
if args.use_pmvs:
infile = tree.pmvs_model
elif args.fast_orthophoto:
infile = os.path.join(tree.opensfm, 'reconstruction.ply')
if not io.file_exists(tree.odm_mesh) or rerun_cell:
log.ODM_DEBUG('Writing ODM Mesh file in: %s' % tree.odm_mesh)
# Do not create full 3D model with fast_orthophoto
if not args.fast_orthophoto:
if not io.file_exists(tree.odm_mesh) or rerun_cell:
log.ODM_DEBUG('Writing ODM Mesh file in: %s' % tree.odm_mesh)
kwargs = {
'bin': context.odm_modules_path,
'outfile': tree.odm_mesh,
'infile': infile,
'log': tree.odm_meshing_log,
'max_vertex': self.params.max_vertex,
'oct_tree': self.params.oct_tree,
'samples': self.params.samples,
'solver': self.params.solver,
'verbose': verbose
}
kwargs = {
'bin': context.odm_modules_path,
'outfile': tree.odm_mesh,
'infile': infile,
'log': tree.odm_meshing_log,
'max_vertex': self.params.max_vertex,
'oct_tree': self.params.oct_tree,
'samples': self.params.samples,
'solver': self.params.solver,
'verbose': verbose
}
# run meshing binary
system.run('{bin}/odm_meshing -inputFile {infile} '
'-outputFile {outfile} -logFile {log} '
'-maxVertexCount {max_vertex} -octreeDepth {oct_tree} {verbose} '
'-samplesPerNode {samples} -solverDivide {solver}'.format(**kwargs))
else:
log.ODM_WARNING('Found a valid ODM Mesh file in: %s' %
tree.odm_mesh)
# run meshing binary
system.run('{bin}/odm_meshing -inputFile {infile} '
'-outputFile {outfile} -logFile {log} '
'-maxVertexCount {max_vertex} -octreeDepth {oct_tree} {verbose} '
'-samplesPerNode {samples} -solverDivide {solver}'.format(**kwargs))
else:
log.ODM_WARNING('Found a valid ODM Mesh file in: %s' %
tree.odm_mesh)
# Do we need to generate a 2.5D mesh also?
# This is always set if fast_orthophoto is set
if args.use_25dmesh:
if not io.file_exists(tree.odm_25dmesh) or rerun_cell:
log.ODM_DEBUG('Writing ODM 2.5D Mesh file in: %s' % tree.odm_25dmesh)
@ -89,15 +94,15 @@ class ODMeshingCell(ecto.Cell):
'log': tree.odm_25dmeshing_log,
'verbose': verbose,
'max_vertex': self.params.max_vertex,
'remove_outliers': self.params.remove_outliers,
'wlop_iterations': self.params.wlop_iterations
'neighbors': args.mesh_neighbors,
'resolution': args.mesh_resolution
}
# run 2.5D meshing binary
system.run('{bin}/odm_25dmeshing -inputFile {infile} '
'-outputFile {outfile} -logFile {log} '
'-maxVertexCount {max_vertex} -outliersRemovalPercentage {remove_outliers} '
'-wlopIterations {wlop_iterations} {verbose}'.format(**kwargs))
'-maxVertexCount {max_vertex} -neighbors {neighbors} '
'-resolution {resolution} {verbose}'.format(**kwargs))
else:
log.ODM_WARNING('Found a valid ODM 2.5D Mesh file in: %s' %
tree.odm_25dmesh)

Wyświetl plik

@ -141,8 +141,16 @@ class ODMOpenSfMCell(ecto.Cell):
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' %
# Skip dense reconstruction if necessary and export
# sparse reconstruction instead
if args.fast_orthophoto:
system.run('PYTHONPATH=%s %s/bin/opensfm export_ply --no-cameras %s' %
(context.pyopencv_path, context.opensfm_path, tree.opensfm))
else:
system.run('PYTHONPATH=%s %s/bin/opensfm compute_depthmaps %s' %
(context.pyopencv_path, context.opensfm_path, tree.opensfm))
else:
log.ODM_WARNING('Found a valid OpenSfM reconstruction file in: %s' %
tree.opensfm_reconstruction)