Skip to content

Commit 8e0697d

Browse files
almaroukcbentejac
authored andcommitted
[codeFactor] add SEMANTIC enum for attr desc
1 parent e8f1c03 commit 8e0697d

15 files changed

+41
-35
lines changed

meshroom/core/desc.py

+17-11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
import distutils.util
1111
import shlex
1212

13+
class Semantic(Enum):
14+
NONE = ""
15+
IMAGE = "image"
16+
MULTILINE = "multiline"
17+
COLOR_HUE = "color/hue"
18+
1319
class Attribute(BaseObject):
1420
"""
1521
"""
@@ -72,7 +78,7 @@ def matchDescription(self, value, strict=True):
7278

7379
class ListAttribute(Attribute):
7480
""" A list of Attributes """
75-
def __init__(self, elementDesc, name, label, description, group='allParams', advanced=False, semantic='', enabled=True, joinChar=' '):
81+
def __init__(self, elementDesc, name, label, description, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True, joinChar=' '):
7682
"""
7783
:param elementDesc: the Attribute description of elements to store in that list
7884
"""
@@ -112,7 +118,7 @@ def matchDescription(self, value, strict=True):
112118

113119
class GroupAttribute(Attribute):
114120
""" A macro Attribute composed of several Attributes """
115-
def __init__(self, groupDesc, name, label, description, group='allParams', advanced=False, semantic='', enabled=True, joinChar=' ', brackets=None):
121+
def __init__(self, groupDesc, name, label, description, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True, joinChar=' ', brackets=None):
116122
"""
117123
:param groupDesc: the description of the Attributes composing this group
118124
"""
@@ -213,7 +219,7 @@ def __init__(self, name, label, description, value, uid, group, advanced, semant
213219
class File(Attribute):
214220
"""
215221
"""
216-
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True):
222+
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True):
217223
super(File, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled)
218224

219225
def validateValue(self, value):
@@ -232,7 +238,7 @@ def checkValueTypes(self):
232238
class BoolParam(Param):
233239
"""
234240
"""
235-
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True):
241+
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True):
236242
super(BoolParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled)
237243

238244
def validateValue(self, value):
@@ -253,7 +259,7 @@ def checkValueTypes(self):
253259
class IntParam(Param):
254260
"""
255261
"""
256-
def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic='', enabled=True):
262+
def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True):
257263
self._range = range
258264
super(IntParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled)
259265

@@ -275,7 +281,7 @@ def checkValueTypes(self):
275281
class FloatParam(Param):
276282
"""
277283
"""
278-
def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic='', enabled=True):
284+
def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True):
279285
self._range = range
280286
super(FloatParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled)
281287

@@ -296,7 +302,7 @@ def checkValueTypes(self):
296302
class ChoiceParam(Param):
297303
"""
298304
"""
299-
def __init__(self, name, label, description, value, values, exclusive, uid, group='allParams', joinChar=' ', advanced=False, semantic='', enabled=True):
305+
def __init__(self, name, label, description, value, values, exclusive, uid, group='allParams', joinChar=' ', advanced=False, semantic=Semantic.NONE, enabled=True):
300306
assert values
301307
self._values = values
302308
self._exclusive = exclusive
@@ -334,7 +340,7 @@ def checkValueTypes(self):
334340
class StringParam(Param):
335341
"""
336342
"""
337-
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True, uidIgnoreValue=None):
343+
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True, uidIgnoreValue=None):
338344
super(StringParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled,
339345
uidIgnoreValue=uidIgnoreValue)
340346

@@ -352,7 +358,7 @@ def checkValueTypes(self):
352358
class ColorParam(Param):
353359
"""
354360
"""
355-
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True):
361+
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True):
356362
super(ColorParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled)
357363

358364
def validateValue(self, value):
@@ -512,7 +518,7 @@ class Node(object):
512518
"This is useful for development, we can invalidate the output of the node when we modify the code.\n"
513519
"It is displayed in bold font in the invalidation/comment messages tooltip.",
514520
value="",
515-
semantic="multiline",
521+
semantic=Semantic.MULTILINE,
516522
uid=[0],
517523
advanced=True,
518524
uidIgnoreValue="", # If the invalidation string is empty, it does not participate to the node's UID
@@ -523,7 +529,7 @@ class Node(object):
523529
description="User comments describing this specific node instance.\n"
524530
"It is displayed in regular font in the invalidation/comment messages tooltip.",
525531
value="",
526-
semantic="multiline",
532+
semantic=Semantic.MULTILINE,
527533
uid=[],
528534
),
529535
StringParam(

meshroom/core/node.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ def hasImageOutputAttribute(self):
11321132
Return True if at least one attribute has the 'image' semantic (and can thus be loaded in the 2D Viewer), False otherwise.
11331133
"""
11341134
for attr in self._attributes:
1135-
if attr.enabled and attr.isOutput and attr.desc.semantic == "image":
1135+
if attr.enabled and attr.isOutput and attr.desc.semantic == desc.Semantic.IMAGE:
11361136
return True
11371137
return False
11381138

@@ -1221,7 +1221,7 @@ def __init__(self, nodeType, position=None, parent=None, **kwargs):
12211221

12221222
# List attributes per uid
12231223
for attr in self._attributes:
1224-
if attr.isOutput and attr.desc.semantic == "image":
1224+
if attr.isOutput and attr.desc.semantic == desc.Semantic.IMAGE:
12251225
attr.enabledChanged.connect(self.outputAttrEnabledChanged)
12261226
for uidIndex in attr.attributeDesc.uid:
12271227
self.attributesPerUid[uidIndex].add(attr)

meshroom/nodes/aliceVision/CheckerboardDetection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class CheckerboardDetection(desc.AVCommandLineNode):
5959
enabled= lambda node: node.exportDebugImages.value,
6060
label='Checker Lines',
6161
description='Debug Images.',
62-
semantic='image',
62+
semantic=desc.Semantic.IMAGE,
6363
value=desc.Node.internalFolder + '<VIEW_ID>.png',
6464
group='', # do not export on the command line
6565
uid=[],

meshroom/nodes/aliceVision/DepthMap.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ class DepthMap(desc.AVCommandLineNode):
616616
name="depth",
617617
label="Depth Maps",
618618
description="Generated depth maps.",
619-
semantic="image",
619+
semantic=desc.Semantic.IMAGE,
620620
value=desc.Node.internalFolder + "<VIEW_ID>_depthMap.exr",
621621
uid=[],
622622
group="", # do not export on the command line
@@ -625,7 +625,7 @@ class DepthMap(desc.AVCommandLineNode):
625625
name="sim",
626626
label="Sim Maps",
627627
description="Generated sim maps.",
628-
semantic="image",
628+
semantic=desc.Semantic.IMAGE,
629629
value=desc.Node.internalFolder + "<VIEW_ID>_simMap.exr",
630630
uid=[],
631631
group="", # do not export on the command line
@@ -643,7 +643,7 @@ class DepthMap(desc.AVCommandLineNode):
643643
name="depthSgm",
644644
label="Depth Maps SGM",
645645
description="Debug: Depth maps SGM",
646-
semantic="image",
646+
semantic=desc.Semantic.IMAGE,
647647
value=desc.Node.internalFolder + "<VIEW_ID>_depthMap_sgm.exr",
648648
uid=[],
649649
group="", # do not export on the command line
@@ -653,7 +653,7 @@ class DepthMap(desc.AVCommandLineNode):
653653
name="depthSgmUpscaled",
654654
label="Depth Maps SGM Upscaled",
655655
description="Debug: Depth maps SGM upscaled.",
656-
semantic="image",
656+
semantic=desc.Semantic.IMAGE,
657657
value=desc.Node.internalFolder + "<VIEW_ID>_depthMap_sgmUpscaled.exr",
658658
uid=[],
659659
group="", # do not export on the command line
@@ -663,7 +663,7 @@ class DepthMap(desc.AVCommandLineNode):
663663
name="depthRefined",
664664
label="Depth Maps Refined",
665665
description="Debug: Depth maps after refinement",
666-
semantic="image",
666+
semantic=desc.Semantic.IMAGE,
667667
value=desc.Node.internalFolder + "<VIEW_ID>_depthMap_refinedFused.exr",
668668
uid=[],
669669
group="", # do not export on the command line

meshroom/nodes/aliceVision/DepthMapFilter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class DepthMapFilter(desc.AVCommandLineNode):
135135
name="depth",
136136
label="Depth Maps",
137137
description="Filtered depth maps.",
138-
semantic="image",
138+
semantic=desc.Semantic.IMAGE,
139139
value=desc.Node.internalFolder + "<VIEW_ID>_depthMap.exr",
140140
uid=[],
141141
group="", # do not export on the command line
@@ -144,7 +144,7 @@ class DepthMapFilter(desc.AVCommandLineNode):
144144
name="sim",
145145
label="Sim Maps",
146146
description="Filtered sim maps.",
147-
semantic="image",
147+
semantic=desc.Semantic.IMAGE,
148148
value=desc.Node.internalFolder + "<VIEW_ID>_simMap.exr",
149149
uid=[],
150150
group="", # do not export on the command line

meshroom/nodes/aliceVision/ExportDistortion.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ExportDistortion(desc.AVCommandLineNode):
3232
name='distoStMap',
3333
label='Distortion ST Map',
3434
description='Calibrated distortion ST map.',
35-
semantic='image',
35+
semantic=desc.Semantic.IMAGE,
3636
value=desc.Node.internalFolder + '<INTRINSIC_ID>_distort.exr',
3737
group='', # do not export on the command line
3838
uid=[],
@@ -41,7 +41,7 @@ class ExportDistortion(desc.AVCommandLineNode):
4141
name='undistoStMap',
4242
label='Undistortion ST Map',
4343
description='Calibrated undistortion ST map.',
44-
semantic='image',
44+
semantic=desc.Semantic.IMAGE,
4545
value=desc.Node.internalFolder + '<INTRINSIC_ID>_undistort.exr',
4646
group='', # do not export on the command line
4747
uid=[],

meshroom/nodes/aliceVision/ImageMasking.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ImageMasking(desc.AVCommandLineNode):
4444
label="Hue",
4545
description="Hue value to isolate in [0,1] range.\n"
4646
"0 = red, 0.33 = green, 0.66 = blue, 1 = red.",
47-
semantic="color/hue",
47+
semantic=desc.Semantic.COLOR_HUE,
4848
value=0.33,
4949
range=(0.0, 1.0, 0.01),
5050
uid=[0]

meshroom/nodes/aliceVision/ImageProcessing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ class ImageProcessing(desc.AVCommandLineNode):
656656
name="outputImages",
657657
label="Images",
658658
description="Output images.",
659-
semantic="image",
659+
semantic=desc.Semantic.IMAGE,
660660
value= outputImagesValueFunct,
661661
group="", # do not export on the command line
662662
uid=[],

meshroom/nodes/aliceVision/ImageSegmentation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ImageSegmentation(desc.AVCommandLineNode):
7676
name="masks",
7777
label="Masks",
7878
description="Generated segmentation masks.",
79-
semantic="image",
79+
semantic=desc.Semantic.IMAGE,
8080
value=desc.Node.internalFolder + "<VIEW_ID>.exr",
8181
group="",
8282
uid=[],

meshroom/nodes/aliceVision/PanoramaMerging.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class PanoramaMerging(desc.AVCommandLineNode):
7878
name="outputPanorama",
7979
label="Panorama",
8080
description="Output merged panorama image.",
81-
semantic="image",
81+
semantic=desc.Semantic.IMAGE,
8282
value=desc.Node.internalFolder + "panorama.{outputFileTypeValue}",
8383
uid=[],
8484
),

meshroom/nodes/aliceVision/PanoramaPostProcessing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ class PanoramaPostProcessing(desc.CommandLineNode):
9999
name="outputPanorama",
100100
label="Output Panorama",
101101
description="Generated panorama in EXR format.",
102-
semantic="image",
102+
semantic=desc.Semantic.IMAGE,
103103
value=desc.Node.internalFolder + "panorama.exr",
104104
uid=[],
105105
),
106106
desc.File(
107107
name="outputPanoramaPreview",
108108
label="Output Panorama Preview",
109109
description="Preview of the generated panorama in JPG format.",
110-
semantic="image",
110+
semantic=desc.Semantic.IMAGE,
111111
value=desc.Node.internalFolder + "panoramaPreview.jpg",
112112
uid=[],
113113
),

meshroom/nodes/aliceVision/PanoramaSeams.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class PanoramaSeams(desc.AVCommandLineNode):
6363
name="output",
6464
label="Labels",
6565
description="",
66-
semantic="image",
66+
semantic=desc.Semantic.IMAGE,
6767
value=desc.Node.internalFolder + "labels.exr",
6868
uid=[],
6969
),

meshroom/nodes/aliceVision/PhotometricStereo.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class PhotometricStereo(desc.CommandLineNode):
121121
name="normals",
122122
label="Normal Maps Camera",
123123
description="Generated normal maps in the camera coordinate system.",
124-
semantic="image",
124+
semantic=desc.Semantic.IMAGE,
125125
value=desc.Node.internalFolder + "<POSE_ID>_normals.exr",
126126
uid=[],
127127
group="", # do not export on the command line
@@ -130,7 +130,7 @@ class PhotometricStereo(desc.CommandLineNode):
130130
name="normalsWorld",
131131
label="Normal Maps World",
132132
description="Generated normal maps in the world coordinate system.",
133-
semantic="image",
133+
semantic=desc.Semantic.IMAGE,
134134
value=desc.Node.internalFolder + "<POSE_ID>_normals_w.exr",
135135
uid=[],
136136
group="", # do not export on the command line
@@ -139,7 +139,7 @@ class PhotometricStereo(desc.CommandLineNode):
139139
name="albedo",
140140
label="Albedo Maps",
141141
description="Generated albedo maps.",
142-
semantic="image",
142+
semantic=desc.Semantic.IMAGE,
143143
value=desc.Node.internalFolder + "<POSE_ID>_albedo.exr",
144144
uid=[],
145145
group="", # do not export on the command line

meshroom/nodes/aliceVision/PrepareDenseScene.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class PrepareDenseScene(desc.AVCommandLineNode):
103103
name="undistorted",
104104
label="Undistorted Images",
105105
description="List of undistorted images.",
106-
semantic="image",
106+
semantic=desc.Semantic.IMAGE,
107107
value=desc.Node.internalFolder + "<VIEW_ID>.{outputFileTypeValue}",
108108
uid=[],
109109
group="",

meshroom/nodes/blender/ScenePreview.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class ScenePreview(desc.CommandLineNode):
133133
name="frames",
134134
label="Frames",
135135
description="Frames rendered in Blender.",
136-
semantic="image",
136+
semantic=desc.Semantic.IMAGE,
137137
value=desc.Node.internalFolder + "<FILENAME>_preview.jpg",
138138
uid=[],
139139
group="",

0 commit comments

Comments
 (0)