diff --git a/meshroom/core/desc.py b/meshroom/core/desc.py index d62c0c21bf..6a9ec46258 100644 --- a/meshroom/core/desc.py +++ b/meshroom/core/desc.py @@ -10,6 +10,12 @@ import distutils.util import shlex +class Semantic(Enum): + NONE = "" + IMAGE = "image" + MULTILINE = "multiline" + COLOR_HUE = "color/hue" + class Attribute(BaseObject): """ """ @@ -72,7 +78,7 @@ def matchDescription(self, value, strict=True): class ListAttribute(Attribute): """ A list of Attributes """ - def __init__(self, elementDesc, name, label, description, group='allParams', advanced=False, semantic='', enabled=True, joinChar=' '): + def __init__(self, elementDesc, name, label, description, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True, joinChar=' '): """ :param elementDesc: the Attribute description of elements to store in that list """ @@ -112,7 +118,7 @@ def matchDescription(self, value, strict=True): class GroupAttribute(Attribute): """ A macro Attribute composed of several Attributes """ - def __init__(self, groupDesc, name, label, description, group='allParams', advanced=False, semantic='', enabled=True, joinChar=' ', brackets=None): + def __init__(self, groupDesc, name, label, description, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True, joinChar=' ', brackets=None): """ :param groupDesc: the description of the Attributes composing this group """ @@ -213,7 +219,7 @@ def __init__(self, name, label, description, value, uid, group, advanced, semant class File(Attribute): """ """ - def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True): + def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True): super(File, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled) def validateValue(self, value): @@ -232,7 +238,7 @@ def checkValueTypes(self): class BoolParam(Param): """ """ - def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True): + def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True): super(BoolParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled) def validateValue(self, value): @@ -253,7 +259,7 @@ def checkValueTypes(self): class IntParam(Param): """ """ - def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic='', enabled=True): + def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True): self._range = range super(IntParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled) @@ -275,7 +281,7 @@ def checkValueTypes(self): class FloatParam(Param): """ """ - def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic='', enabled=True): + def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True): self._range = range super(FloatParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled) @@ -296,7 +302,7 @@ def checkValueTypes(self): class ChoiceParam(Param): """ """ - def __init__(self, name, label, description, value, values, exclusive, uid, group='allParams', joinChar=' ', advanced=False, semantic='', enabled=True): + def __init__(self, name, label, description, value, values, exclusive, uid, group='allParams', joinChar=' ', advanced=False, semantic=Semantic.NONE, enabled=True): assert values self._values = values self._exclusive = exclusive @@ -334,7 +340,7 @@ def checkValueTypes(self): class StringParam(Param): """ """ - def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True, uidIgnoreValue=None): + def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True, uidIgnoreValue=None): super(StringParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled, uidIgnoreValue=uidIgnoreValue) @@ -352,7 +358,7 @@ def checkValueTypes(self): class ColorParam(Param): """ """ - def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True): + def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True): super(ColorParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled) def validateValue(self, value): @@ -512,7 +518,7 @@ class Node(object): "This is useful for development, we can invalidate the output of the node when we modify the code.\n" "It is displayed in bold font in the invalidation/comment messages tooltip.", value="", - semantic="multiline", + semantic=Semantic.MULTILINE, uid=[0], advanced=True, uidIgnoreValue="", # If the invalidation string is empty, it does not participate to the node's UID @@ -523,7 +529,7 @@ class Node(object): description="User comments describing this specific node instance.\n" "It is displayed in regular font in the invalidation/comment messages tooltip.", value="", - semantic="multiline", + semantic=Semantic.MULTILINE, uid=[], ), StringParam( diff --git a/meshroom/core/node.py b/meshroom/core/node.py index 2a17564821..8a696262fb 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -1132,7 +1132,7 @@ def hasImageOutputAttribute(self): Return True if at least one attribute has the 'image' semantic (and can thus be loaded in the 2D Viewer), False otherwise. """ for attr in self._attributes: - if attr.enabled and attr.isOutput and attr.desc.semantic == "image": + if attr.enabled and attr.isOutput and attr.desc.semantic == desc.Semantic.IMAGE: return True return False @@ -1221,7 +1221,7 @@ def __init__(self, nodeType, position=None, parent=None, **kwargs): # List attributes per uid for attr in self._attributes: - if attr.isOutput and attr.desc.semantic == "image": + if attr.isOutput and attr.desc.semantic == desc.Semantic.IMAGE: attr.enabledChanged.connect(self.outputAttrEnabledChanged) for uidIndex in attr.attributeDesc.uid: self.attributesPerUid[uidIndex].add(attr) diff --git a/meshroom/nodes/aliceVision/CheckerboardDetection.py b/meshroom/nodes/aliceVision/CheckerboardDetection.py index 0dcba781ff..0f5f1962e7 100644 --- a/meshroom/nodes/aliceVision/CheckerboardDetection.py +++ b/meshroom/nodes/aliceVision/CheckerboardDetection.py @@ -59,7 +59,7 @@ class CheckerboardDetection(desc.AVCommandLineNode): enabled= lambda node: node.exportDebugImages.value, label='Checker Lines', description='Debug Images.', - semantic='image', + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + '.png', group='', # do not export on the command line uid=[], diff --git a/meshroom/nodes/aliceVision/DepthMap.py b/meshroom/nodes/aliceVision/DepthMap.py index d4443139d2..ce3aca92f9 100644 --- a/meshroom/nodes/aliceVision/DepthMap.py +++ b/meshroom/nodes/aliceVision/DepthMap.py @@ -616,7 +616,7 @@ class DepthMap(desc.AVCommandLineNode): name="depth", label="Depth Maps", description="Generated depth maps.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "_depthMap.exr", uid=[], group="", # do not export on the command line @@ -625,7 +625,7 @@ class DepthMap(desc.AVCommandLineNode): name="sim", label="Sim Maps", description="Generated sim maps.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "_simMap.exr", uid=[], group="", # do not export on the command line @@ -643,7 +643,7 @@ class DepthMap(desc.AVCommandLineNode): name="depthSgm", label="Depth Maps SGM", description="Debug: Depth maps SGM", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "_depthMap_sgm.exr", uid=[], group="", # do not export on the command line @@ -653,7 +653,7 @@ class DepthMap(desc.AVCommandLineNode): name="depthSgmUpscaled", label="Depth Maps SGM Upscaled", description="Debug: Depth maps SGM upscaled.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "_depthMap_sgmUpscaled.exr", uid=[], group="", # do not export on the command line @@ -663,7 +663,7 @@ class DepthMap(desc.AVCommandLineNode): name="depthRefined", label="Depth Maps Refined", description="Debug: Depth maps after refinement", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "_depthMap_refinedFused.exr", uid=[], group="", # do not export on the command line diff --git a/meshroom/nodes/aliceVision/DepthMapFilter.py b/meshroom/nodes/aliceVision/DepthMapFilter.py index 487a4074fe..348655323e 100644 --- a/meshroom/nodes/aliceVision/DepthMapFilter.py +++ b/meshroom/nodes/aliceVision/DepthMapFilter.py @@ -135,7 +135,7 @@ class DepthMapFilter(desc.AVCommandLineNode): name="depth", label="Depth Maps", description="Filtered depth maps.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "_depthMap.exr", uid=[], group="", # do not export on the command line @@ -144,7 +144,7 @@ class DepthMapFilter(desc.AVCommandLineNode): name="sim", label="Sim Maps", description="Filtered sim maps.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "_simMap.exr", uid=[], group="", # do not export on the command line diff --git a/meshroom/nodes/aliceVision/ExportDistortion.py b/meshroom/nodes/aliceVision/ExportDistortion.py index fa9d070fa9..bc210e109f 100644 --- a/meshroom/nodes/aliceVision/ExportDistortion.py +++ b/meshroom/nodes/aliceVision/ExportDistortion.py @@ -32,7 +32,7 @@ class ExportDistortion(desc.AVCommandLineNode): name='distoStMap', label='Distortion ST Map', description='Calibrated distortion ST map.', - semantic='image', + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + '_distort.exr', group='', # do not export on the command line uid=[], @@ -41,7 +41,7 @@ class ExportDistortion(desc.AVCommandLineNode): name='undistoStMap', label='Undistortion ST Map', description='Calibrated undistortion ST map.', - semantic='image', + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + '_undistort.exr', group='', # do not export on the command line uid=[], diff --git a/meshroom/nodes/aliceVision/ImageMasking.py b/meshroom/nodes/aliceVision/ImageMasking.py index 48a810169a..58ded15cbd 100644 --- a/meshroom/nodes/aliceVision/ImageMasking.py +++ b/meshroom/nodes/aliceVision/ImageMasking.py @@ -44,7 +44,7 @@ class ImageMasking(desc.AVCommandLineNode): label="Hue", description="Hue value to isolate in [0,1] range.\n" "0 = red, 0.33 = green, 0.66 = blue, 1 = red.", - semantic="color/hue", + semantic=desc.Semantic.COLOR_HUE, value=0.33, range=(0.0, 1.0, 0.01), uid=[0] diff --git a/meshroom/nodes/aliceVision/ImageProcessing.py b/meshroom/nodes/aliceVision/ImageProcessing.py index ad12c8cf02..cd9d8ecb26 100644 --- a/meshroom/nodes/aliceVision/ImageProcessing.py +++ b/meshroom/nodes/aliceVision/ImageProcessing.py @@ -656,7 +656,7 @@ class ImageProcessing(desc.AVCommandLineNode): name="outputImages", label="Images", description="Output images.", - semantic="image", + semantic=desc.Semantic.IMAGE, value= outputImagesValueFunct, group="", # do not export on the command line uid=[], diff --git a/meshroom/nodes/aliceVision/ImageSegmentation.py b/meshroom/nodes/aliceVision/ImageSegmentation.py index 8912820b9a..4d776b48d3 100644 --- a/meshroom/nodes/aliceVision/ImageSegmentation.py +++ b/meshroom/nodes/aliceVision/ImageSegmentation.py @@ -76,7 +76,7 @@ class ImageSegmentation(desc.AVCommandLineNode): name="masks", label="Masks", description="Generated segmentation masks.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + ".exr", group="", uid=[], diff --git a/meshroom/nodes/aliceVision/PanoramaMerging.py b/meshroom/nodes/aliceVision/PanoramaMerging.py index 3e12c4e2cd..b9bcce15bc 100644 --- a/meshroom/nodes/aliceVision/PanoramaMerging.py +++ b/meshroom/nodes/aliceVision/PanoramaMerging.py @@ -78,7 +78,7 @@ class PanoramaMerging(desc.AVCommandLineNode): name="outputPanorama", label="Panorama", description="Output merged panorama image.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "panorama.{outputFileTypeValue}", uid=[], ), diff --git a/meshroom/nodes/aliceVision/PanoramaPostProcessing.py b/meshroom/nodes/aliceVision/PanoramaPostProcessing.py index 91edede7a0..e7f29a2334 100644 --- a/meshroom/nodes/aliceVision/PanoramaPostProcessing.py +++ b/meshroom/nodes/aliceVision/PanoramaPostProcessing.py @@ -99,7 +99,7 @@ class PanoramaPostProcessing(desc.CommandLineNode): name="outputPanorama", label="Output Panorama", description="Generated panorama in EXR format.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "panorama.exr", uid=[], ), @@ -107,7 +107,7 @@ class PanoramaPostProcessing(desc.CommandLineNode): name="outputPanoramaPreview", label="Output Panorama Preview", description="Preview of the generated panorama in JPG format.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "panoramaPreview.jpg", uid=[], ), diff --git a/meshroom/nodes/aliceVision/PanoramaSeams.py b/meshroom/nodes/aliceVision/PanoramaSeams.py index 4bc35453c3..25e4f6f471 100644 --- a/meshroom/nodes/aliceVision/PanoramaSeams.py +++ b/meshroom/nodes/aliceVision/PanoramaSeams.py @@ -63,7 +63,7 @@ class PanoramaSeams(desc.AVCommandLineNode): name="output", label="Labels", description="", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "labels.exr", uid=[], ), diff --git a/meshroom/nodes/aliceVision/PhotometricStereo.py b/meshroom/nodes/aliceVision/PhotometricStereo.py index 047865bc14..9222d36fab 100644 --- a/meshroom/nodes/aliceVision/PhotometricStereo.py +++ b/meshroom/nodes/aliceVision/PhotometricStereo.py @@ -121,7 +121,7 @@ class PhotometricStereo(desc.CommandLineNode): name="normals", label="Normal Maps Camera", description="Generated normal maps in the camera coordinate system.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "_normals.exr", uid=[], group="", # do not export on the command line @@ -130,7 +130,7 @@ class PhotometricStereo(desc.CommandLineNode): name="normalsWorld", label="Normal Maps World", description="Generated normal maps in the world coordinate system.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "_normals_w.exr", uid=[], group="", # do not export on the command line @@ -139,7 +139,7 @@ class PhotometricStereo(desc.CommandLineNode): name="albedo", label="Albedo Maps", description="Generated albedo maps.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "_albedo.exr", uid=[], group="", # do not export on the command line diff --git a/meshroom/nodes/aliceVision/PrepareDenseScene.py b/meshroom/nodes/aliceVision/PrepareDenseScene.py index a1e1a7c0ca..be665973b1 100644 --- a/meshroom/nodes/aliceVision/PrepareDenseScene.py +++ b/meshroom/nodes/aliceVision/PrepareDenseScene.py @@ -103,7 +103,7 @@ class PrepareDenseScene(desc.AVCommandLineNode): name="undistorted", label="Undistorted Images", description="List of undistorted images.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + ".{outputFileTypeValue}", uid=[], group="", diff --git a/meshroom/nodes/blender/ScenePreview.py b/meshroom/nodes/blender/ScenePreview.py index fb39467e5e..3de62a9b8e 100644 --- a/meshroom/nodes/blender/ScenePreview.py +++ b/meshroom/nodes/blender/ScenePreview.py @@ -133,7 +133,7 @@ class ScenePreview(desc.CommandLineNode): name="frames", label="Frames", description="Frames rendered in Blender.", - semantic="image", + semantic=desc.Semantic.IMAGE, value=desc.Node.internalFolder + "_preview.jpg", uid=[], group="",