From 13105722ad0d39949a320d559036c51651540924 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Mon, 14 Nov 2022 16:30:20 +0000 Subject: [PATCH] Removed several flags --- opendm/config.py | 55 +---------------------------- opendm/dem/commands.py | 1 - opendm/log.py | 6 ---- opendm/orthophoto.py | 2 +- opendm/photo.py | 4 --- opendm/thermal_tools/dji_unpack.py | 2 +- opendm/types.py | 4 ++- opendm/utils.py | 56 ++++++++++++++---------------- stages/dataset.py | 14 ++++---- stages/mvstex.py | 6 ++-- stages/odm_app.py | 3 -- 11 files changed, 43 insertions(+), 110 deletions(-) diff --git a/opendm/config.py b/opendm/config.py index 89eb00e3..2d5ceadf 100755 --- a/opendm/config.py +++ b/opendm/config.py @@ -203,15 +203,6 @@ def config(argv=None, parser=None): 'processes. Peak memory requirement is ~1GB per ' 'thread and 2 megapixel image resolution. Default: %(default)s')) - parser.add_argument('--depthmap-resolution', - metavar='', - action=StoreValue, - type=float, - default=640, - help=('Controls the density of the point cloud by setting the resolution of the depthmap images. Higher values take longer to compute ' - 'but produce denser point clouds. Overrides the value calculated by --pc-quality.' - 'Default: %(default)s')) - parser.add_argument('--use-hybrid-bundle-adjustment', action=StoreTrue, nargs=0, @@ -437,20 +428,6 @@ def config(argv=None, parser=None): help='Simple Morphological Filter window radius parameter (meters). ' 'Default: %(default)s') - parser.add_argument('--texturing-data-term', - metavar='', - action=StoreValue, - default='gmi', - choices=['gmi', 'area'], - help=('When texturing the 3D mesh, for each triangle, choose to prioritize images with sharp features (gmi) or those that cover the largest area (area). Default: %(default)s')) - - parser.add_argument('--texturing-outlier-removal-type', - metavar='', - action=StoreValue, - default='gauss_clamping', - choices=['none', 'gauss_clamping', 'gauss_damping'], - help=('Type of photometric outlier removal method. Can be one of: %(choices)s. Default: %(default)s')) - parser.add_argument('--texturing-skip-global-seam-leveling', action=StoreTrue, nargs=0, @@ -470,15 +447,6 @@ def config(argv=None, parser=None): help=('Keep faces in the mesh that are not seen in any camera. ' 'Default: %(default)s')) - parser.add_argument('--texturing-tone-mapping', - metavar='', - action=StoreValue, - choices=['none', 'gamma'], - default='none', - help='Turn on gamma tone mapping or none for no tone ' - 'mapping. Can be one of %(choices)s. ' - 'Default: %(default)s ') - parser.add_argument('--gcp', metavar='', action=StoreValue, @@ -496,7 +464,7 @@ def config(argv=None, parser=None): action=StoreValue, default=None, help=('Path to the image geolocation file containing the camera center coordinates used for georeferencing. ' - 'Note that omega/phi/kappa are currently not supported (you can set them to 0). ' + 'If you don''t have values for omega/phi/kappa you can set them to 0. ' 'The file needs to ' 'use the following format: \n' 'EPSG: or <+proj definition>\n' @@ -570,13 +538,6 @@ def config(argv=None, parser=None): help=('Orthophoto resolution in cm / pixel. Note that this value is capped by a ground sampling distance (GSD) estimate. To remove the cap, check --ignore-gsd also. ' 'Default: %(default)s')) - parser.add_argument('--orthophoto-no-tiled', - action=StoreTrue, - nargs=0, - default=False, - help='Set this parameter if you want a striped GeoTIFF. ' - 'Default: %(default)s') - parser.add_argument('--orthophoto-png', action=StoreTrue, nargs=0, @@ -590,7 +551,6 @@ def config(argv=None, parser=None): default=False, help='Set this parameter if you want to generate a Google Earth (KMZ) rendering of the orthophoto. ' 'Default: %(default)s') - parser.add_argument('--orthophoto-compression', metavar='', @@ -659,19 +619,6 @@ def config(argv=None, parser=None): action=StoreValue, help='Copy output results to this folder after processing.') - parser.add_argument('--time', - action=StoreTrue, - nargs=0, - default=False, - help='Generates a benchmark file with runtime info. ' - 'Default: %(default)s') - - parser.add_argument('--debug', - action=StoreTrue, - nargs=0, - default=False, - help='Print debug messages. Default: %(default)s') - parser.add_argument('--version', action='version', version='ODM {0}'.format(__version__), diff --git a/opendm/dem/commands.py b/opendm/dem/commands.py index 4e79edfa..56b80b05 100755 --- a/opendm/dem/commands.py +++ b/opendm/dem/commands.py @@ -380,5 +380,4 @@ def window_filter_2d(arr, nodata, window, kernel_size, filter): win_arr = filter(win_arr) win_arr[nodata_locs] = nodata win_arr = win_arr[window[0] - expanded_window[0] : window[2] - expanded_window[0], window[1] - expanded_window[1] : window[3] - expanded_window[1]] - log.ODM_DEBUG("Filtered window: %s" % str(window)) return win_arr diff --git a/opendm/log.py b/opendm/log.py index 01b3b118..1ff6cfca 100644 --- a/opendm/log.py +++ b/opendm/log.py @@ -43,7 +43,6 @@ def memory(): class ODMLogger: def __init__(self): - self.show_debug = False self.json = None self.json_output_file = None self.start_time = datetime.datetime.now() @@ -134,10 +133,6 @@ class ODMLogger: def exception(self, msg): self.log(FAIL, msg, "EXCEPTION") - def debug(self, msg): - if self.show_debug: - self.log(OKGREEN, msg, "DEBUG") - def close(self): if self.json is not None and self.json_output_file is not None: try: @@ -154,4 +149,3 @@ ODM_INFO = logger.info ODM_WARNING = logger.warning ODM_ERROR = logger.error ODM_EXCEPTION = logger.exception -ODM_DEBUG = logger.debug diff --git a/opendm/orthophoto.py b/opendm/orthophoto.py index 9b25e6d1..465a8aad 100644 --- a/opendm/orthophoto.py +++ b/opendm/orthophoto.py @@ -18,7 +18,7 @@ from osgeo import gdal def get_orthophoto_vars(args): return { - 'TILED': 'NO' if args.orthophoto_no_tiled else 'YES', + 'TILED': 'YES', 'COMPRESS': args.orthophoto_compression, 'PREDICTOR': '2' if args.orthophoto_compression in ['LZW', 'DEFLATE'] else '1', 'BIGTIFF': 'IF_SAFER', diff --git a/opendm/photo.py b/opendm/photo.py index 733acd29..c4bc5a38 100644 --- a/opendm/photo.py +++ b/opendm/photo.py @@ -166,10 +166,6 @@ class ODM_Photo: # parse values from metadata self.parse_exif_values(path_file) - # print log message - log.ODM_DEBUG('Loaded {}'.format(self)) - - def __str__(self): return '{} | camera: {} {} | dimensions: {} x {} | lat: {} | lon: {} | alt: {} | band: {} ({})'.format( self.filename, self.camera_make, self.camera_model, self.width, self.height, diff --git a/opendm/thermal_tools/dji_unpack.py b/opendm/thermal_tools/dji_unpack.py index 4794ab41..eb706a4c 100644 --- a/opendm/thermal_tools/dji_unpack.py +++ b/opendm/thermal_tools/dji_unpack.py @@ -41,7 +41,7 @@ def extract_temperatures_dji(photo, image, dataset_tree): except ValueError as e: log.ODM_ERROR("Error during extracting temperature values for file %s : %s" % photo.filename, e) else: - log.ODM_DEBUG("Only DJI M2EA currently supported, please wait for new updates") + log.ODM_WARNING("Only DJI M2EA currently supported, please wait for new updates") return image # Extract raw sensor values from generated image into numpy array raw_sensor_np = np.array(img) diff --git a/opendm/types.py b/opendm/types.py index 97b95c59..af04a334 100644 --- a/opendm/types.py +++ b/opendm/types.py @@ -364,8 +364,10 @@ class ODM_Stage: if outputs.get('tree') is None: raise Exception("Assert violation: tree variable is missing from outputs dictionary.") - if self.args.time: + try: system.benchmark(start_time, outputs['tree'].benchmarking, self.name) + except Exception as e: + log.ODM_WARNING("Cannot write benchmark file: %s" % str(e)) log.ODM_INFO('Finished %s stage' % self.name) self.update_progress_end() diff --git a/opendm/utils.py b/opendm/utils.py index 2be031ad..0729eb7c 100644 --- a/opendm/utils.py +++ b/opendm/utils.py @@ -5,37 +5,33 @@ from osgeo import gdal from opendm.loghelpers import double_quote def get_depthmap_resolution(args, photos): - if 'depthmap_resolution_is_set' in args: - # Override pc-quality - return int(args.depthmap_resolution) + max_dims = find_largest_photo_dims(photos) + min_dim = 320 # Never go lower than this + + if max_dims is not None: + w, h = max_dims + max_dim = max(w, h) + + megapixels = (w * h) / 1e6 + multiplier = 1 + + if megapixels < 6: + multiplier = 2 + elif megapixels > 42: + multiplier = 0.5 + + pc_quality_scale = { + 'ultra': 0.5, + 'high': 0.25, + 'medium': 0.125, + 'low': 0.0675, + 'lowest': 0.03375 + } + + return max(min_dim, int(max_dim * pc_quality_scale[args.pc_quality] * multiplier)) else: - max_dims = find_largest_photo_dims(photos) - min_dim = 320 # Never go lower than this - - if max_dims is not None: - w, h = max_dims - max_dim = max(w, h) - - megapixels = (w * h) / 1e6 - multiplier = 1 - - if megapixels < 6: - multiplier = 2 - elif megapixels > 42: - multiplier = 0.5 - - pc_quality_scale = { - 'ultra': 0.5, - 'high': 0.25, - 'medium': 0.125, - 'low': 0.0675, - 'lowest': 0.03375 - } - - return max(min_dim, int(max_dim * pc_quality_scale[args.pc_quality] * multiplier)) - else: - log.ODM_WARNING("Cannot compute max image dimensions, going with default depthmap_resolution of 640") - return 640 # Sensible default + log.ODM_WARNING("Cannot compute max image dimensions, going with default depthmap_resolution of 640") + return 640 # Sensible default def get_raster_stats(geotiff): stats = [] diff --git a/stages/dataset.py b/stages/dataset.py index 8d01703f..a167b845 100644 --- a/stages/dataset.py +++ b/stages/dataset.py @@ -49,12 +49,15 @@ class ODMLoadDatasetStage(types.ODM_Stage): tree = types.ODM_Tree(args.project_path, args.gcp, args.geo) outputs['tree'] = tree - if args.time and io.file_exists(tree.benchmarking): + if io.file_exists(tree.benchmarking): # Delete the previously made file - os.remove(tree.benchmarking) - 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)) - + try: + os.remove(tree.benchmarking) + 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)) + except Exception as e: + log.ODM_WARNING("Cannot write benchmark file: %s" % str(e)) + # check if the image filename is supported def valid_image_filename(filename): (pathfn, ext) = os.path.splitext(filename) @@ -62,7 +65,6 @@ class ODMLoadDatasetStage(types.ODM_Stage): # Get supported images from dir def get_images(in_dir): - log.ODM_DEBUG(in_dir) entries = os.listdir(in_dir) valid, rejects = [], [] for f in entries: diff --git a/stages/mvstex.py b/stages/mvstex.py index 082b13de..da8fd433 100644 --- a/stages/mvstex.py +++ b/stages/mvstex.py @@ -93,12 +93,12 @@ class ODMMvsTexStage(types.ODM_Stage): 'bin': context.mvstex_path, 'out_dir': os.path.join(r['out_dir'], "odm_textured_model_geo"), 'model': r['model'], - 'dataTerm': args.texturing_data_term, - 'outlierRemovalType': args.texturing_outlier_removal_type, + 'dataTerm': 'gmi', + 'outlierRemovalType': 'gauss_clamping', 'skipGlobalSeamLeveling': skipGlobalSeamLeveling, 'skipLocalSeamLeveling': skipLocalSeamLeveling, 'keepUnseenFaces': keepUnseenFaces, - 'toneMapping': args.texturing_tone_mapping, + 'toneMapping': 'none', 'nadirMode': nadir, 'maxTextureSize': '--max_texture_size=%s' % max_texture_size, 'nvm_file': r['nvm_file'], diff --git a/stages/odm_app.py b/stages/odm_app.py index b82228e8..79a09c09 100644 --- a/stages/odm_app.py +++ b/stages/odm_app.py @@ -26,9 +26,6 @@ class ODMApp: """ Initializes the application and defines the ODM application pipeline stages """ - if args.debug: - log.logger.show_debug = True - json_log_paths = [os.path.join(args.project_path, "log.json")] if args.copy_to: json_log_paths.append(args.copy_to)