|
| 1 | +__version__ = "1.0" |
| 2 | + |
| 3 | +from meshroom.core import desc |
| 4 | +from meshroom.core.utils import DESCRIBER_TYPES, VERBOSE_LEVEL |
| 5 | + |
| 6 | +import os.path |
| 7 | + |
| 8 | +class MaskProcessingNodeSize(desc.DynamicNodeSize): |
| 9 | + """ |
| 10 | + MaskProcessingNodeSize expresses a dependency to multiple input attributess to define |
| 11 | + the size of a Node in terms of individual tasks for parallelization. |
| 12 | + """ |
| 13 | + def __init__(self, param): |
| 14 | + self._params = param |
| 15 | + |
| 16 | + def computeSize(self, node): |
| 17 | + |
| 18 | + size = 0 |
| 19 | + |
| 20 | + for input in node.attribute(self._params).value: |
| 21 | + paramName = input.getFullName() |
| 22 | + param = node.attribute(paramName) |
| 23 | + if param.isLink: |
| 24 | + size = max(size, param.getLinkParam().node.size) |
| 25 | + |
| 26 | + return size |
| 27 | + |
| 28 | + |
| 29 | +class MaskProcessing(desc.AVCommandLineNode): |
| 30 | + commandLine = 'aliceVision_maskProcessing {allParams}' |
| 31 | + size = MaskProcessingNodeSize("inputs") |
| 32 | + |
| 33 | + category = 'Utils' |
| 34 | + documentation = ''' |
| 35 | + Perform operations on a list of masks with the same names |
| 36 | + ''' |
| 37 | + |
| 38 | + inputs = [ |
| 39 | + desc.ListAttribute( |
| 40 | + elementDesc=desc.File( |
| 41 | + name="input", |
| 42 | + label="Input Directory", |
| 43 | + description="A directory with a set of mask.", |
| 44 | + value="", |
| 45 | + ), |
| 46 | + name="inputs", |
| 47 | + label="Input directories", |
| 48 | + description="A set of directories containing masks with the same names.", |
| 49 | + exposed=True, |
| 50 | + ), |
| 51 | + desc.ChoiceParam( |
| 52 | + name="operator", |
| 53 | + label="Operator", |
| 54 | + description="Operator: Binary operator\n" |
| 55 | + "OR : applies binary OR between all the masks\n" |
| 56 | + "AND : applies binary AND between all the masks\n" |
| 57 | + "NOT : applies binary NOT to the first mask in the list\n", |
| 58 | + value="and", |
| 59 | + values=["or", "and", "not"], |
| 60 | + ), |
| 61 | + desc.ChoiceParam( |
| 62 | + name="verboseLevel", |
| 63 | + label="Verbose Level", |
| 64 | + description="Verbosity level (fatal, error, warning, info, debug, trace).", |
| 65 | + values=VERBOSE_LEVEL, |
| 66 | + value="info", |
| 67 | + ) |
| 68 | + ] |
| 69 | + |
| 70 | + outputs = [ |
| 71 | + desc.File( |
| 72 | + name="output", |
| 73 | + label="Output", |
| 74 | + description="Path to the output directory.", |
| 75 | + value=desc.Node.internalFolder, |
| 76 | + ), |
| 77 | + desc.File( |
| 78 | + name="masks", |
| 79 | + label="Masks", |
| 80 | + description="Processed segmentation masks.", |
| 81 | + semantic="imageList", |
| 82 | + value= desc.Node.internalFolder + "*.exr", |
| 83 | + group="", |
| 84 | + ), |
| 85 | + ] |
0 commit comments