kopia lustrzana https://github.com/OpenDroneMap/ODM
rodzic
9332a02de6
commit
4445c85db1
|
@ -16,6 +16,10 @@ parser = argparse.ArgumentParser(description='OpenDroneMap')
|
||||||
|
|
||||||
|
|
||||||
def config():
|
def config():
|
||||||
|
parser.add_argument('--images', '-i',
|
||||||
|
metavar='<string>',
|
||||||
|
help='Path to input images'),
|
||||||
|
|
||||||
parser.add_argument('--project-path',
|
parser.add_argument('--project-path',
|
||||||
metavar='<string>',
|
metavar='<string>',
|
||||||
help='Path to the project to process')
|
help='Path to the project to process')
|
||||||
|
|
|
@ -331,9 +331,13 @@ class ODM_GeoRef(object):
|
||||||
|
|
||||||
|
|
||||||
class ODM_Tree(object):
|
class ODM_Tree(object):
|
||||||
def __init__(self, root_path):
|
def __init__(self, root_path, images_path):
|
||||||
# root path to the project
|
# root path to the project
|
||||||
self.root_path = io.absolute_path_file(root_path)
|
self.root_path = io.absolute_path_file(root_path)
|
||||||
|
if not images_path:
|
||||||
|
self.input_images = io.join_paths(self.root_path, 'images')
|
||||||
|
else:
|
||||||
|
self.input_images = io.absolute_path_file(images_path)
|
||||||
|
|
||||||
# modules paths
|
# modules paths
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ from opendm import context
|
||||||
from opendm import io
|
from opendm import io
|
||||||
from opendm import types
|
from opendm import types
|
||||||
from opendm import log
|
from opendm import log
|
||||||
|
from opendm import system
|
||||||
|
from shutil import copyfile
|
||||||
|
|
||||||
|
|
||||||
def make_odm_photo(force_focal, force_ccd, path_file):
|
def make_odm_photo(force_focal, force_ccd, path_file):
|
||||||
|
@ -28,32 +30,41 @@ class ODMLoadDatasetCell(ecto.Cell):
|
||||||
outputs.declare("photos", "list of ODMPhotos", [])
|
outputs.declare("photos", "list of ODMPhotos", [])
|
||||||
|
|
||||||
def process(self, inputs, outputs):
|
def process(self, inputs, outputs):
|
||||||
# check if the extension is sopported
|
# check if the extension is supported
|
||||||
def supported_extension(file_name):
|
def supported_extension(file_name):
|
||||||
(pathfn, ext) = os.path.splitext(file_name)
|
(pathfn, ext) = os.path.splitext(file_name)
|
||||||
return ext.lower() in context.supported_extensions
|
return ext.lower() in context.supported_extensions
|
||||||
|
|
||||||
|
# Get supported images from dir
|
||||||
|
def get_images(in_dir):
|
||||||
|
# filter images for its extension type
|
||||||
|
log.ODM_DEBUG(in_dir)
|
||||||
|
return [f for f in io.get_files_list(in_dir) if supported_extension(f)]
|
||||||
|
|
||||||
log.ODM_INFO('Running ODM Load Dataset Cell')
|
log.ODM_INFO('Running ODM Load Dataset Cell')
|
||||||
|
|
||||||
# get inputs
|
# get inputs
|
||||||
tree = self.inputs.tree
|
tree = self.inputs.tree
|
||||||
|
|
||||||
# set images directory
|
# get images directory
|
||||||
images_dir = tree.dataset_resize
|
input_dir = tree.input_images
|
||||||
|
images_dir = tree.dataset_raw
|
||||||
|
resize_dir = tree.dataset_resize
|
||||||
|
|
||||||
if not io.dir_exists(images_dir):
|
# Check first if a project already exists. This is a mediocre way to check, by checking the resize dir
|
||||||
images_dir = tree.dataset_raw
|
if io.dir_exists(resize_dir):
|
||||||
|
log.ODM_DEBUG("resize dir: %s" % resize_dir)
|
||||||
|
images_dir = resize_dir
|
||||||
|
# if first time running, create project directory and copy images over to project/images
|
||||||
|
else:
|
||||||
if not io.dir_exists(images_dir):
|
if not io.dir_exists(images_dir):
|
||||||
log.ODM_ERROR("You must put your pictures into an <images> directory")
|
log.ODM_INFO("Project directory %s doesn't exist. Creating it now. " % images_dir)
|
||||||
return ecto.QUIT
|
system.mkdir_p(images_dir)
|
||||||
|
copied = [copyfile(io.join_paths(input_dir, f), io.join_paths(images_dir, f)) for f in get_images(input_dir)]
|
||||||
|
|
||||||
log.ODM_DEBUG('Loading dataset from: %s' % images_dir)
|
log.ODM_DEBUG('Loading dataset from: %s' % images_dir)
|
||||||
|
|
||||||
# find files in the given directory
|
files = get_images(images_dir)
|
||||||
files = io.get_files_list(images_dir)
|
|
||||||
|
|
||||||
# filter images for its extension type
|
|
||||||
files = [f for f in files if supported_extension(f)]
|
|
||||||
|
|
||||||
if files:
|
if files:
|
||||||
# create ODMPhoto list
|
# create ODMPhoto list
|
||||||
|
|
|
@ -78,7 +78,7 @@ class ODMApp(ecto.BlackBox):
|
||||||
return cells
|
return cells
|
||||||
|
|
||||||
def configure(self, p, _i, _o):
|
def configure(self, p, _i, _o):
|
||||||
tree = types.ODM_Tree(p.args.project_path)
|
tree = types.ODM_Tree(p.args.project_path, p.args.images)
|
||||||
self.tree = ecto.Constant(value=tree)
|
self.tree = ecto.Constant(value=tree)
|
||||||
|
|
||||||
# TODO(dakota) put this somewhere better maybe
|
# TODO(dakota) put this somewhere better maybe
|
||||||
|
|
Ładowanie…
Reference in New Issue