Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2dc6a36

Browse files
committedJun 28, 2023
[codeFactor] add SEMANTIC enum for attr desc
1 parent d7e3003 commit 2dc6a36

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=' '):
121+
def __init__(self, groupDesc, name, label, description, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True, joinChar=' '):
116122
"""
117123
:param groupDesc: the description of the Attributes composing this group
118124
"""
@@ -211,7 +217,7 @@ def __init__(self, name, label, description, value, uid, group, advanced, semant
211217
class File(Attribute):
212218
"""
213219
"""
214-
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True):
220+
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True):
215221
super(File, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled)
216222

217223
def validateValue(self, value):
@@ -230,7 +236,7 @@ def checkValueTypes(self):
230236
class BoolParam(Param):
231237
"""
232238
"""
233-
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True):
239+
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True):
234240
super(BoolParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled)
235241

236242
def validateValue(self, value):
@@ -251,7 +257,7 @@ def checkValueTypes(self):
251257
class IntParam(Param):
252258
"""
253259
"""
254-
def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic='', enabled=True):
260+
def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True):
255261
self._range = range
256262
super(IntParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled)
257263

@@ -273,7 +279,7 @@ def checkValueTypes(self):
273279
class FloatParam(Param):
274280
"""
275281
"""
276-
def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic='', enabled=True):
282+
def __init__(self, name, label, description, value, range, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True):
277283
self._range = range
278284
super(FloatParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled)
279285

@@ -294,7 +300,7 @@ def checkValueTypes(self):
294300
class ChoiceParam(Param):
295301
"""
296302
"""
297-
def __init__(self, name, label, description, value, values, exclusive, uid, group='allParams', joinChar=' ', advanced=False, semantic='', enabled=True):
303+
def __init__(self, name, label, description, value, values, exclusive, uid, group='allParams', joinChar=' ', advanced=False, semantic=Semantic.NONE, enabled=True):
298304
assert values
299305
self._values = values
300306
self._exclusive = exclusive
@@ -332,7 +338,7 @@ def checkValueTypes(self):
332338
class StringParam(Param):
333339
"""
334340
"""
335-
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True, uidIgnoreValue=None):
341+
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True, uidIgnoreValue=None):
336342
super(StringParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled,
337343
uidIgnoreValue=uidIgnoreValue)
338344

@@ -350,7 +356,7 @@ def checkValueTypes(self):
350356
class ColorParam(Param):
351357
"""
352358
"""
353-
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic='', enabled=True):
359+
def __init__(self, name, label, description, value, uid, group='allParams', advanced=False, semantic=Semantic.NONE, enabled=True):
354360
super(ColorParam, self).__init__(name=name, label=label, description=description, value=value, uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled)
355361

356362
def validateValue(self, value):
@@ -510,7 +516,7 @@ class Node(object):
510516
"This is useful for development, we can invalidate the output of the node when we modify the code.\n"
511517
"It is displayed in bold font in the invalidation/comment messages tooltip.",
512518
value="",
513-
semantic="multiline",
519+
semantic=Semantic.MULTILINE,
514520
uid=[0],
515521
advanced=True,
516522
uidIgnoreValue="", # If the invalidation string is empty, it does not participate to the node's UID
@@ -521,7 +527,7 @@ class Node(object):
521527
description="User comments describing this specific node instance.\n"
522528
"It is displayed in regular font in the invalidation/comment messages tooltip.",
523529
value="",
524-
semantic="multiline",
530+
semantic=Semantic.MULTILINE,
525531
uid=[],
526532
),
527533
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
@@ -80,7 +80,7 @@ class ImageSegmentation(desc.AVCommandLineNode):
8080
name="masks",
8181
label="Masks",
8282
description="Generated segmentation masks.",
83-
semantic="image",
83+
semantic=desc.Semantic.IMAGE,
8484
value=desc.Node.internalFolder + "<VIEW_ID>.exr",
8585
group="",
8686
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
@@ -84,15 +84,15 @@ class PanoramaPostProcessing(desc.CommandLineNode):
8484
name="outputPanorama",
8585
label="Output Panorama",
8686
description="Generated panorama in EXR format.",
87-
semantic="image",
87+
semantic=desc.Semantic.IMAGE,
8888
value=desc.Node.internalFolder + "panorama.exr",
8989
uid=[],
9090
),
9191
desc.File(
9292
name="outputPanoramaPreview",
9393
label="Output Panorama Preview",
9494
description="Preview of the generated panorama in JPG format.",
95-
semantic="image",
95+
semantic=desc.Semantic.IMAGE,
9696
value=desc.Node.internalFolder + "panoramaPreview.jpg",
9797
uid=[],
9898
),

‎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)
Please sign in to comment.