From f0a8f7665d9a9b5ac596f26afecf5ca53bbb479d Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Tue, 11 Apr 2017 16:36:20 -0400 Subject: [PATCH] Added enum data type --- libs/odmOptions.js | 24 +++++++++++++++--------- tests/odm_options.json | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libs/odmOptions.js b/libs/odmOptions.js index 6c5bf6f..520eb8c 100644 --- a/libs/odmOptions.js +++ b/libs/odmOptions.js @@ -95,7 +95,7 @@ module.exports = { } if (Array.isArray(values.choices)){ - type = "string"; // TODO: change to enum + type = "enum"; domain = values.choices; } @@ -148,6 +148,9 @@ module.exports = { }, 'path': function(value){ return value; // No conversion needed + }, + 'enum': function(value){ + return value; // No conversion needed } }; @@ -202,18 +205,21 @@ module.exports = { return true; // All strings/paths are fine } } - - // TODO: handle enum ]; let checkDomain = function(domain, value){ - let matches, - dc = domainChecks.find(dc => matches = domain.match(dc.regex)); - - if (dc){ - if (!dc.validate(matches, value)) throw new Error(`Invalid value ${value} (out of range)`); + if (Array.isArray(domain)){ + // Special case for enum checks + if (domain.indexOf(value) === -1) throw new Error(`Invalid value ${value} (not in enum)`); }else{ - throw new Error(`Domain value cannot be handled: '${domain}' : '${value}'`); + let matches, + dc = domainChecks.find(dc => matches = domain.match(dc.regex)); + + if (dc){ + if (!dc.validate(matches, value)) throw new Error(`Invalid value ${value} (out of range)`); + }else{ + throw new Error(`Domain value cannot be handled: '${domain}' : '${value}'`); + } } }; diff --git a/tests/odm_options.json b/tests/odm_options.json index b516aef..0bdb2df 100644 --- a/tests/odm_options.json +++ b/tests/odm_options.json @@ -1 +1 @@ -{"--pmvs-num-cores": {"default": "1", "type": "", "metavar": "", "help": "The maximum number of cores to use in dense reconstruction. Default: %(default)s"}, "--cmvs-maxImages": {"default": "500", "type": "", "metavar": "", "help": "The maximum number of images per cluster. Default: %(default)s"}, "--odm_meshing-octreeDepth": {"default": "9", "type": "", "metavar": "", "help": "Oct-tree depth used in the mesh reconstruction, increase to get more vertices, recommended values are 8-12. Default: %(default)s"}, "--odm_meshing-maxVertexCount": {"default": "100000", "type": "", "metavar": "", "help": "The maximum vertex count of the output mesh Default: %(default)s"}, "--matcher-threshold": {"default": "2.0", "type": "", "metavar": "", "help": "Ignore matched keypoints if the two images share less than percent of keypoints. Default: %(default)s"}, "--min-num-features": {"default": "4000", "type": "", "metavar": "", "help": "Minimum number of features to extract per image. More features leads to better results but slower execution. Default: %(default)s"}, "--force-focal": {"type": "", "metavar": "", "help": "Override the focal length information for the images"}, "--resize-to": {"default": "2400", "type": "", "metavar": "", "help": "resizes images by the largest side"}, "--pmvs-level": {"default": "1", "type": "", "metavar": "", "help": "The level in the image pyramid that is used for the computation. see http://www.di.ens.fr/pmvs/documentation.html for more pmvs documentation. Default: %(default)s"}, "--pmvs-threshold": {"default": "0.7", "type": "", "metavar": "", "help": "A patch reconstruction is accepted as a success and kept if its associated photometric consistency measure is above this threshold. Default: %(default)s"}, "--pmvs-minImageNum": {"default": "3", "type": "", "metavar": "", "help": "Each 3D point must be visible in at least minImageNum images for being reconstructed. 3 is suggested in general. Default: %(default)s"}, "--odm_meshing-samplesPerNode": {"default": "1.0", "type": "", "metavar": "= 1.0>", "help": "Number of points per octree node, recommended and default value: %(default)s"}, "--mvs_texturing-skipHoleFilling": {"default": "false", "metavar": "", "help": "Skip filling of holes in the mesh. Default: %(default)s"}, "--project-path": {"metavar": "", "help": "Path to the project to process"}, "--start-with": {"default": "resize", "choices": "['resize', 'opensfm', 'cmvs', 'pmvs', 'odm_meshing', 'mvs_texturing', 'odm_georeferencing', 'odm_orthophoto']", "help": "Can be one of: resize | opensfm | cmvs | pmvs | odm_meshing | mvs_texturing | odm_georeferencing | odm_orthophoto", "metavar": ""}, "--mvs_texturing-skipGlobalSeamLeveling": {"default": "false", "metavar": "", "help": "Skip geometric visibility test. Default: %(default)s"}, "--force-ccd": {"type": "", "metavar": "", "help": "Override the ccd width information for the images"}, "-h": {"action": "help", "default": "==SUPPRESS==", "help": "show this help message and exit"}, "--time": {"action": "store_true", "default": "False", "help": "Generates a benchmark file with runtime info\nDefault: %(default)s"}, "--odm_texturing-textureResolution": {"default": "4096", "type": "", "metavar": "", "help": "The resolution of the output textures. Must be greater than textureWithSize. Default: %(default)s"}, "--matcher-distance": {"default": "0", "type": "", "metavar": "", "help": "Distance threshold in meters to find pre-matching images based on GPS exif data. Set to 0 to skip pre-matching. Default: %(default)s"}, "--zip-results": {"action": "store_true", "default": "False", "help": "compress the results using gunzip"}, "--pmvs-csize": {"default": "2", "type": "", "metavar": "< positive integer>", "help": "Cell size controls the density of reconstructionsDefault: %(default)s"}, "--odm_orthophoto-resolution": {"default": "20.0", "type": "", "metavar": " 0.0>", "help": "Orthophoto ground resolution in pixels/meterDefault: %(default)s"}, "--odm_meshing-solverDivide": {"default": "9", "type": "", "metavar": "", "help": "Oct-tree depth at which the Laplacian equation is solved in the surface reconstruction step. Increasing this value increases computation times slightly but helps reduce memory usage. Default: %(default)s"}, "--gcp": {"default": "gcp_list.txt", "metavar": "", "help": "path to the file containing the ground control points used for georeferencing. Default: %(default)s. The file needs to be on the following line format: \neasting northing height pixelrow pixelcol imagename"}, "--pmvs-wsize": {"default": "7", "type": "", "metavar": "", "help": "pmvs samples wsize x wsize pixel colors from each image to compute photometric consistency score. For example, when wsize=7, 7x7=49 pixel colors are sampled in each image. Increasing the value leads to more stable reconstructions, but the program becomes slower. Default: %(default)s"}, "--mvs_texturing-keepUnseenFaces": {"default": "false", "metavar": "", "help": "Keep faces in the mesh that are not seen in any camera. Default: %(default)s"}, "--odm_texturing-textureWithSize": {"default": "3600", "type": "", "metavar": "", "help": "The resolution to rescale the images performing the texturing. Default: %(default)s"}, "--mvs_texturing-outlierRemovalType": {"default": "none", "metavar": "", "help": "Type of photometric outlier removal method: [none, gauss_damping, gauss_clamping]. Default: %(default)s"}, "--matcher-neighbors": {"default": "8", "type": "", "metavar": "", "help": "Number of nearest images to pre-match based on GPS exif data. Set to 0 to skip pre-matching. Neighbors works together with Distance parameter, set both to 0 to not use pre-matching. OpenSFM uses both parameters at the same time, Bundler uses only one which has value, prefering the Neighbors parameter. Default: %(default)s"}, "--mvs_texturing-skipLocalSeamLeveling": {"default": "false", "metavar": "", "help": "Skip local seam blending. Default: %(default)s"}, "--end-with": {"default": "odm_orthophoto", "choices": "['resize', 'opensfm', 'cmvs', 'pmvs', 'odm_meshing', 'mvs_texturing', 'odm_georeferencing', 'odm_orthophoto']", "help": "Can be one of:resize | opensfm | cmvs | pmvs | odm_meshing | mvs_texturing | odm_georeferencing | odm_orthophoto", "metavar": ""}, "--mvs_texturing-dataTerm": {"default": "gmi", "metavar": "", "help": "Data term: [area, gmi]. Default: %(default)s"}, "--mvs_texturing-skipGeometricVisibilityTest": {"default": "false", "metavar": "", "help": "Skip geometric visibility test. Default: %(default)s"}, "--matcher-ratio": {"default": "0.6", "type": "", "metavar": "", "help": "Ratio of the distance to the next best matched keypoint. Default: %(default)s"}} +{"--pmvs-num-cores": {"default": "4", "type": "", "metavar": "", "help": "The maximum number of cores to use in dense reconstruction. Default: %(default)s"}, "--mesh-solver-divide": {"default": "9", "type": "", "metavar": "", "help": "Oct-tree depth at which the Laplacian equation is solved in the surface reconstruction step. Increasing this value increases computation times slightly but helps reduce memory usage. Default: %(default)s"}, "--cmvs-maxImages": {"default": "500", "type": "", "metavar": "", "help": "The maximum number of images per cluster. Default: %(default)s"}, "--matcher-threshold": {"default": "2.0", "type": "", "metavar": "", "help": "Ignore matched keypoints if the two images share less than percent of keypoints. Default: %(default)s"}, "--mesh-octree-depth": {"default": "9", "type": "", "metavar": "", "help": "Oct-tree depth used in the mesh reconstruction, increase to get more vertices, recommended values are 8-12. Default: %(default)s"}, "--min-num-features": {"default": "4000", "type": "", "metavar": "", "help": "Minimum number of features to extract per image. More features leads to better results but slower execution. Default: %(default)s"}, "--force-focal": {"type": "", "metavar": "", "help": "Override the focal length information for the images"}, "--resize-to": {"default": "2400", "type": "", "metavar": "", "help": "resizes images by the largest side"}, "--gcp": {"default": "None", "metavar": "", "help": "path to the file containing the ground control points used for georeferencing. Default: %(default)s. The file needs to be on the following line format: \neasting northing height pixelrow pixelcol imagename"}, "--texturing-keep-unseen-faces": {"action": "store_true", "default": "False", "help": "Keep faces in the mesh that are not seen in any camera. Default: %(default)s"}, "--25d-mesh-size": {"default": "50000", "type": "", "metavar": "", "help": "The maximum vertex count of the 2.5D output mesh Smaller values produce smoother orthophotos but could introduce distortion Applies to 2.5D mesh only. Default: %(default)s"}, "--pmvs-level": {"default": "1", "type": "", "metavar": "", "help": "The level in the image pyramid that is used for the computation. see http://www.di.ens.fr/pmvs/documentation.html for more pmvs documentation. Default: %(default)s"}, "--pmvs-threshold": {"default": "0.7", "type": "", "metavar": "", "help": "A patch reconstruction is accepted as a success and kept if its associated photometric consistency measure is above this threshold. Default: %(default)s"}, "--texturing-outlier-removal-type": {"default": "gauss_clamping", "choices": "['none', 'gauss_clamping', 'gauss_damping']", "help": "Type of photometric outlier removal method: [none, gauss_damping, gauss_clamping]. Default: %(default)s", "metavar": ""}, "--texturing-skip-hole-filling": {"action": "store_true", "default": "False", "help": "Skip filling of holes in the mesh. Default: %(default)s"}, "--project-path": {"metavar": "", "help": "Path to the project folder"}, "--start-with": {"default": "resize", "choices": "['resize', 'opensfm', 'slam', 'cmvs', 'pmvs', 'odm_meshing', 'odm_25dmeshing', 'mvs_texturing', 'odm_georeferencing', 'odm_orthophoto']", "help": "Can be one of: resize | opensfm | slam | cmvs | pmvs | odm_meshing | odm_25dmeshing | mvs_texturing | odm_georeferencing | odm_orthophoto", "metavar": ""}, "--orthophoto-resolution": {"default": "20.0", "type": "", "metavar": " 0.0>", "help": "Orthophoto ground resolution in pixels/meterDefault: %(default)s"}, "--skip-25dmesh": {"action": "store_true", "default": "False", "help": "Do not build a 2.5D mesh and use the poisson mesh to compute the orthophoto"}, "--force-ccd": {"type": "", "metavar": "", "help": "Override the ccd width information for the images"}, "--orthophoto-no-tiled": {"action": "store_true", "default": "False", "help": "Set this parameter if you want a stripped geoTIFF.\nDefault: %(default)s"}, "-h": {"action": "help", "default": "==SUPPRESS==", "help": "show this help message and exit"}, "--mesh-size": {"default": "100000", "type": "", "metavar": "", "help": "The maximum vertex count of the output mesh Default: %(default)s"}, "--orthophoto-compression": {"default": "DEFLATE", "choices": "['JPEG', 'LZW', 'PACKBITS', 'DEFLATE', 'LZMA', 'NONE']", "type": "", "help": "Set the compression to use. Note that this could break gdal_translate if you don't know what you are doing. Options: %(choices)s.\nDefault: %(default)s", "metavar": ""}, "--build-overviews": {"action": "store_true", "default": "False", "help": "Build orthophoto overviews using gdaladdo."}, "--matcher-distance": {"default": "0", "type": "", "metavar": "", "help": "Distance threshold in meters to find pre-matching images based on GPS exif data. Set both matcher-neighbors and this to 0 to skip pre-matching. Default: %(default)s"}, "--zip-results": {"action": "store_true", "default": "False", "help": "compress the results using gunzip"}, "--verbose": {"action": "store_true", "default": "False", "help": "Print additional messages to the console\nDefault: %(default)s"}, "--pmvs-csize": {"default": "2", "type": "", "metavar": "", "help": "Cell size controls the density of reconstructionsDefault: %(default)s"}, "--use-exif": {"action": "store_true", "default": "False", "help": "Use this tag if you have a gcp_list.txt but want to use the exif geotags instead"}, "--mesh-samples": {"default": "1.0", "type": "", "metavar": "= 1.0>", "help": "Number of points per octree node, recommended and default value: %(default)s"}, "--texturing-skip-local-seam-leveling": {"action": "store_true", "default": "False", "help": "Skip local seam blending. Default: %(default)s"}, "--orthophoto-bigtiff": {"default": "IF_SAFER", "type": "", "help": "Control whether the created orthophoto is a BigTIFF or classic TIFF. BigTIFF is a variant for files larger than 4GiB of data. Options are %(choices)s. See GDAL specs: https://www.gdal.org/frmt_gtiff.html for more info. \nDefault: %(default)s", "choices": "['YES', 'NO', 'IF_NEEDED', 'IF_SAFER']"}, "--pmvs-wsize": {"default": "7", "type": "", "metavar": "", "help": "pmvs samples wsize x wsize pixel colors from each image to compute photometric consistency score. For example, when wsize=7, 7x7=49 pixel colors are sampled in each image. Increasing the value leads to more stable reconstructions, but the program becomes slower. Default: %(default)s"}, "--orthophoto-target-srs": {"default": "None", "type": "", "metavar": "", "help": "Target spatial reference for orthophoto creation. Not implemented yet.\nDefault: %(default)s"}, "--texturing-data-term": {"default": "gmi", "choices": "['gmi', 'area']", "help": "Data term: [area, gmi]. Default: %(default)s", "metavar": ""}, "--mesh-wlop-iterations": {"default": "70", "type": "", "metavar": "", "help": "Iterations of the Weighted Locally Optimal Projection (WLOP) simplification algorithm. Higher values take longer but produce a smoother mesh. Applies to 2.5D mesh only. Default: %(default)s"}, "--images": {"metavar": "", "help": "Path to input images"}, "--mesh-remove-outliers": {"default": "2", "type": "", "metavar": "", "help": "Percentage of outliers to remove from the point set. Set to 0 to disable. Applies to 2.5D mesh only. Default: %(default)s"}, "--version": {"action": "version", "version": "OpenDroneMap 0.3-development", "help": "Displays version number and exits. "}, "name": {"type": "", "metavar": "", "help": "Name of Project (i.e subdirectory of projects folder)"}, "--texturing-tone-mapping": {"default": "none", "choices": "['none', 'gamma']", "help": "Turn on gamma tone mapping or none for no tone mapping. Choices are 'gamma' or 'none'. Default: %(default)s ", "metavar": ""}, "--video": {"metavar": "", "help": "Path to the video file to process"}, "--pmvs-min-images": {"default": "3", "type": "", "metavar": "", "help": "Each 3D point must be visible in at least minImageNum images for being reconstructed. 3 is suggested in general. Default: %(default)s"}, "--opensfm-processes": {"default": "4", "type": "", "metavar": "", "help": "The maximum number of processes to use in dense reconstruction. Default: %(default)s"}, "--end-with": {"default": "odm_orthophoto", "choices": "['resize', 'opensfm', 'slam', 'cmvs', 'pmvs', 'odm_meshing', 'odm_25dmeshing', 'mvs_texturing', 'odm_georeferencing', 'odm_orthophoto']", "help": "Can be one of:resize | opensfm | slam | cmvs | pmvs | odm_meshing | odm_25dmeshing | mvs_texturing | odm_georeferencing | odm_orthophoto", "metavar": ""}, "--texturing-skip-global-seam-leveling": {"action": "store_true", "default": "False", "help": "Skip global seam leveling. Useful for IR data.Default: %(default)s"}, "--texturing-skip-visibility-test": {"action": "store_true", "default": "False", "help": "Skip geometric visibility test. Default: %(default)s"}, "--slam-config": {"metavar": "", "help": "Path to config file for orb-slam"}, "--time": {"action": "store_true", "default": "False", "help": "Generates a benchmark file with runtime info\nDefault: %(default)s"}, "--matcher-ratio": {"default": "0.6", "type": "", "metavar": "", "help": "Ratio of the distance to the next best matched keypoint. Default: %(default)s"}, "--use-pmvs": {"action": "store_true", "default": "False", "help": "Use pmvs to compute point cloud alternatively"}, "--matcher-neighbors": {"default": "8", "type": "", "metavar": "", "help": "Number of nearest images to pre-match based on GPS exif data. Set to 0 to skip pre-matching. Neighbors works together with Distance parameter, set both to 0 to not use pre-matching. OpenSFM uses both parameters at the same time, Bundler uses only one which has value, prefering the Neighbors parameter. Default: %(default)s"}} \ No newline at end of file