2015-11-26 12:15:02 +00:00
|
|
|
import ecto
|
2016-02-29 14:45:00 +00:00
|
|
|
import os
|
2015-11-26 12:15:02 +00:00
|
|
|
|
2015-11-27 16:52:27 +00:00
|
|
|
from opendm import context
|
2015-12-10 11:01:41 +00:00
|
|
|
from opendm import types
|
|
|
|
from opendm import config
|
2016-02-29 14:45:00 +00:00
|
|
|
from opendm import io
|
2016-02-29 14:47:54 +00:00
|
|
|
from opendm import system
|
2015-11-27 16:52:27 +00:00
|
|
|
|
2015-11-26 12:15:02 +00:00
|
|
|
from dataset import ODMLoadDatasetCell
|
2015-11-27 16:52:27 +00:00
|
|
|
from resize import ODMResizeCell
|
2015-11-30 15:51:29 +00:00
|
|
|
from opensfm import ODMOpenSfMCell
|
|
|
|
from pmvs import ODMPmvsCell
|
2015-12-10 11:01:41 +00:00
|
|
|
from cmvs import ODMCmvsCell
|
2015-11-30 15:51:29 +00:00
|
|
|
from odm_meshing import ODMeshingCell
|
2016-03-24 17:35:29 +00:00
|
|
|
#from odm_texturing import ODMTexturingCell
|
|
|
|
from mvstex import ODMMvsTexCell
|
2015-12-01 16:27:44 +00:00
|
|
|
from odm_georeferencing import ODMGeoreferencingCell
|
|
|
|
from odm_orthophoto import ODMOrthoPhotoCell
|
2015-11-26 12:15:02 +00:00
|
|
|
|
2016-02-26 18:50:12 +00:00
|
|
|
|
2015-11-26 12:15:02 +00:00
|
|
|
class ODMApp(ecto.BlackBox):
|
2016-02-26 18:50:12 +00:00
|
|
|
"""ODMApp - a class for ODM Activities
|
|
|
|
"""
|
|
|
|
|
2015-11-26 12:15:02 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
ecto.BlackBox.__init__(self, *args, **kwargs)
|
2016-02-26 18:50:12 +00:00
|
|
|
self.tree = None
|
2015-11-26 12:15:02 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def declare_direct_params(p):
|
|
|
|
p.declare("args", "The application arguments.", {})
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def declare_cells(p):
|
|
|
|
"""
|
|
|
|
Implement the virtual function from the base class
|
|
|
|
Only cells from which something is forwarded have to be declared
|
|
|
|
"""
|
2016-02-26 18:50:12 +00:00
|
|
|
cells = {'args': ecto.Constant(value=p.args),
|
2016-03-08 18:26:58 +00:00
|
|
|
'dataset': ODMLoadDatasetCell(force_focal=p.args.force_focal,
|
|
|
|
force_ccd=p.args.force_ccd),
|
|
|
|
'resize': ODMResizeCell(resize_to=p.args.resize_to),
|
2016-02-26 18:50:12 +00:00
|
|
|
'opensfm': ODMOpenSfMCell(use_exif_size=False,
|
2016-03-08 18:26:58 +00:00
|
|
|
feature_process_size=p.args.resize_to,
|
|
|
|
feature_min_frames=p.args.min_num_features,
|
2016-02-26 18:50:12 +00:00
|
|
|
processes=context.num_cores,
|
2016-03-08 18:26:58 +00:00
|
|
|
matching_gps_neighbors=p.args.matcher_neighbors,
|
|
|
|
matching_gps_distance=p.args.matcher_distance),
|
|
|
|
'cmvs': ODMCmvsCell(max_images=p.args.cmvs_maxImages),
|
|
|
|
'pmvs': ODMPmvsCell(level=p.args.pmvs_level,
|
|
|
|
csize=p.args.pmvs_csize,
|
|
|
|
thresh=p.args.pmvs_threshold,
|
|
|
|
wsize=p.args.pmvs_wsize,
|
|
|
|
min_imgs=p.args.pmvs_minImageNum,
|
|
|
|
cores=p.args.pmvs_num_cores),
|
|
|
|
'meshing': ODMeshingCell(max_vertex=p.args.odm_meshing_maxVertexCount,
|
|
|
|
oct_tree=p.args.odm_meshing_octreeDepth,
|
|
|
|
samples=p.args.odm_meshing_samplesPerNode,
|
|
|
|
solver=p.args.odm_meshing_solverDivide),
|
2016-06-30 17:57:33 +00:00
|
|
|
'texturing': ODMMvsTexCell(data_term=p.args.mvs_texturing_dataTerm,
|
|
|
|
outlier_rem_type=p.args.mvs_texturing_outlierRemovalType,
|
|
|
|
skip_vis_test=p.args.mvs_texturing_skipGeometricVisibilityTest,
|
|
|
|
skip_glob_seam_leveling=p.args.mvs_texturing_skipGlobalSeamLeveling,
|
|
|
|
skip_loc_seam_leveling=p.args.mvs_texturing_skipLocalSeamLeveling,
|
|
|
|
skip_hole_fill=p.args.mvs_texturing_skipHoleFilling,
|
|
|
|
keep_unseen_faces=p.args.mvs_texturing_keepUnseenFaces),
|
|
|
|
# Old odm_texturing
|
|
|
|
# 'texturing': ODMTexturingCell(resize=p.args['resize_to'],
|
|
|
|
# resolution=p.args['odm_texturing_textureResolution'],
|
2016-03-08 18:26:58 +00:00
|
|
|
'georeferencing': ODMGeoreferencingCell(img_size=p.args.resize_to,
|
|
|
|
gcp_file=p.args.odm_georeferencing_gcpFile,
|
|
|
|
use_gcp=p.args.odm_georeferencing_useGcp),
|
|
|
|
'orthophoto': ODMOrthoPhotoCell(resolution=p.args.odm_orthophoto_resolution)
|
2016-02-26 18:50:12 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return cells
|
2015-11-26 12:15:02 +00:00
|
|
|
|
2015-12-10 11:01:41 +00:00
|
|
|
def configure(self, p, _i, _o):
|
2016-03-08 18:26:58 +00:00
|
|
|
tree = types.ODM_Tree(p.args.project_path)
|
2015-12-10 11:01:41 +00:00
|
|
|
self.tree = ecto.Constant(value=tree)
|
2015-11-27 16:52:27 +00:00
|
|
|
|
2016-02-29 14:45:00 +00:00
|
|
|
# TODO(dakota) put this somewhere better maybe
|
2016-03-08 18:26:58 +00:00
|
|
|
if p.args.time and io.file_exists(tree.benchmarking):
|
2016-02-29 14:45:00 +00:00
|
|
|
# Delete the previously made file
|
|
|
|
os.remove(tree.benchmarking)
|
2016-02-29 14:47:54 +00:00
|
|
|
with open(tree.benchmarking, 'a') as b:
|
|
|
|
b.write('ODM Benchmarking file created %s\nNumber of Cores: %s\n\n' % (system.now(), context.num_cores))
|
2016-02-29 14:45:00 +00:00
|
|
|
|
2015-12-10 11:01:41 +00:00
|
|
|
def connections(self, _p):
|
|
|
|
# define initial task
|
2016-02-26 18:50:12 +00:00
|
|
|
# TODO: What is this?
|
|
|
|
# initial_task = _p.args['start_with']
|
|
|
|
# initial_task_id = config.processopts.index(initial_task)
|
2015-11-26 12:15:02 +00:00
|
|
|
|
2016-02-26 18:50:12 +00:00
|
|
|
# define the connections like you would for the plasm
|
|
|
|
# connections = []
|
2015-12-01 16:27:44 +00:00
|
|
|
|
2016-02-26 18:50:12 +00:00
|
|
|
# load the dataset
|
|
|
|
connections = [self.tree[:] >> self.dataset['tree']]
|
2015-12-10 11:01:41 +00:00
|
|
|
|
2015-12-11 21:26:39 +00:00
|
|
|
# run resize cell
|
2016-02-26 18:50:12 +00:00
|
|
|
connections += [self.tree[:] >> self.resize['tree'],
|
|
|
|
self.args[:] >> self.resize['args'],
|
|
|
|
self.dataset['photos'] >> self.resize['photos']]
|
2015-12-11 21:26:39 +00:00
|
|
|
|
|
|
|
# run opensfm with images from load dataset
|
2016-02-26 18:50:12 +00:00
|
|
|
connections += [self.tree[:] >> self.opensfm['tree'],
|
|
|
|
self.args[:] >> self.opensfm['args'],
|
|
|
|
self.resize['photos'] >> self.opensfm['photos']]
|
|
|
|
|
2015-12-11 21:26:39 +00:00
|
|
|
# run cmvs
|
2016-02-26 18:50:12 +00:00
|
|
|
connections += [self.tree[:] >> self.cmvs['tree'],
|
|
|
|
self.args[:] >> self.cmvs['args'],
|
|
|
|
self.opensfm['reconstruction'] >> self.cmvs['reconstruction']]
|
|
|
|
|
2015-12-11 21:26:39 +00:00
|
|
|
# run pmvs
|
2016-02-26 18:50:12 +00:00
|
|
|
connections += [self.tree[:] >> self.pmvs['tree'],
|
|
|
|
self.args[:] >> self.pmvs['args'],
|
|
|
|
self.cmvs['reconstruction'] >> self.pmvs['reconstruction']]
|
|
|
|
|
2015-12-11 21:26:39 +00:00
|
|
|
# create odm mesh
|
2016-02-26 18:50:12 +00:00
|
|
|
connections += [self.tree[:] >> self.meshing['tree'],
|
|
|
|
self.args[:] >> self.meshing['args'],
|
|
|
|
self.pmvs['reconstruction'] >> self.meshing['reconstruction']]
|
|
|
|
|
2015-12-11 21:26:39 +00:00
|
|
|
# create odm texture
|
2016-02-26 18:50:12 +00:00
|
|
|
connections += [self.tree[:] >> self.texturing['tree'],
|
|
|
|
self.args[:] >> self.texturing['args'],
|
|
|
|
self.meshing['reconstruction'] >> self.texturing['reconstruction']]
|
|
|
|
|
2015-12-11 21:26:39 +00:00
|
|
|
# create odm georeference
|
2016-02-26 18:50:12 +00:00
|
|
|
connections += [self.tree[:] >> self.georeferencing['tree'],
|
|
|
|
self.args[:] >> self.georeferencing['args'],
|
|
|
|
self.dataset['photos'] >> self.georeferencing['photos'],
|
|
|
|
self.texturing['reconstruction'] >> self.georeferencing['reconstruction']]
|
|
|
|
|
|
|
|
# create odm orthophoto
|
|
|
|
connections += [self.tree[:] >> self.orthophoto['tree'],
|
|
|
|
self.args[:] >> self.orthophoto['args'],
|
|
|
|
self.georeferencing['reconstruction'] >> self.orthophoto['reconstruction']]
|
2015-12-01 16:27:44 +00:00
|
|
|
|
2015-12-30 14:36:56 +00:00
|
|
|
return connections
|