Skip to content

Commit

Permalink
[codeFactor] add SEMANTIC enum for attr desc
Browse files Browse the repository at this point in the history
  • Loading branch information
almarouk committed Jun 28, 2023
1 parent d7e3003 commit 2dc6a36
Show file tree
Hide file tree
Showing 15 changed files with 41 additions and 35 deletions.
28 changes: 17 additions & 11 deletions meshroom/core/desc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
import distutils.util
import shlex

class Semantic(Enum):
NONE = ""
IMAGE = "image"
MULTILINE = "multiline"
COLOR_HUE = "color/hue"

class Attribute(BaseObject):
"""
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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=' '):
def __init__(self, groupDesc, name, label, description, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True, joinChar=' '):
"""
:param groupDesc: the description of the Attributes composing this group
"""
Expand Down Expand Up @@ -211,7 +217,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):
Expand All @@ -230,7 +236,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):
Expand All @@ -251,7 +257,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)

Expand All @@ -273,7 +279,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)

Expand All @@ -294,7 +300,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
Expand Down Expand Up @@ -332,7 +338,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)

Expand All @@ -350,7 +356,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):
Expand Down Expand Up @@ -510,7 +516,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
Expand All @@ -521,7 +527,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(
Expand Down
4 changes: 2 additions & 2 deletions meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion meshroom/nodes/aliceVision/CheckerboardDetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '<VIEW_ID>.png',
group='', # do not export on the command line
uid=[],
Expand Down
10 changes: 5 additions & 5 deletions meshroom/nodes/aliceVision/DepthMap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "<VIEW_ID>_depthMap.exr",
uid=[],
group="", # do not export on the command line
Expand All @@ -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 + "<VIEW_ID>_simMap.exr",
uid=[],
group="", # do not export on the command line
Expand All @@ -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 + "<VIEW_ID>_depthMap_sgm.exr",
uid=[],
group="", # do not export on the command line
Expand All @@ -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 + "<VIEW_ID>_depthMap_sgmUpscaled.exr",
uid=[],
group="", # do not export on the command line
Expand All @@ -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 + "<VIEW_ID>_depthMap_refinedFused.exr",
uid=[],
group="", # do not export on the command line
Expand Down
4 changes: 2 additions & 2 deletions meshroom/nodes/aliceVision/DepthMapFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "<VIEW_ID>_depthMap.exr",
uid=[],
group="", # do not export on the command line
Expand All @@ -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 + "<VIEW_ID>_simMap.exr",
uid=[],
group="", # do not export on the command line
Expand Down
4 changes: 2 additions & 2 deletions meshroom/nodes/aliceVision/ExportDistortion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '<INTRINSIC_ID>_distort.exr',
group='', # do not export on the command line
uid=[],
Expand All @@ -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 + '<INTRINSIC_ID>_undistort.exr',
group='', # do not export on the command line
uid=[],
Expand Down
2 changes: 1 addition & 1 deletion meshroom/nodes/aliceVision/ImageMasking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion meshroom/nodes/aliceVision/ImageProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
Expand Down
2 changes: 1 addition & 1 deletion meshroom/nodes/aliceVision/ImageSegmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ImageSegmentation(desc.AVCommandLineNode):
name="masks",
label="Masks",
description="Generated segmentation masks.",
semantic="image",
semantic=desc.Semantic.IMAGE,
value=desc.Node.internalFolder + "<VIEW_ID>.exr",
group="",
uid=[],
Expand Down
2 changes: 1 addition & 1 deletion meshroom/nodes/aliceVision/PanoramaMerging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
),
Expand Down
4 changes: 2 additions & 2 deletions meshroom/nodes/aliceVision/PanoramaPostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ 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=[],
),
desc.File(
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=[],
),
Expand Down
2 changes: 1 addition & 1 deletion meshroom/nodes/aliceVision/PanoramaSeams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
),
Expand Down
6 changes: 3 additions & 3 deletions meshroom/nodes/aliceVision/PhotometricStereo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "<POSE_ID>_normals.exr",
uid=[],
group="", # do not export on the command line
Expand All @@ -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 + "<POSE_ID>_normals_w.exr",
uid=[],
group="", # do not export on the command line
Expand All @@ -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 + "<POSE_ID>_albedo.exr",
uid=[],
group="", # do not export on the command line
Expand Down
2 changes: 1 addition & 1 deletion meshroom/nodes/aliceVision/PrepareDenseScene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "<VIEW_ID>.{outputFileTypeValue}",
uid=[],
group="",
Expand Down
2 changes: 1 addition & 1 deletion meshroom/nodes/blender/ScenePreview.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "<FILENAME>_preview.jpg",
uid=[],
group="",
Expand Down

0 comments on commit 2dc6a36

Please sign in to comment.