Esempio n. 1
0
    def attributeDescFromValue(attrName, value, isOutput):
        """
        Generate an attribute description (desc.Attribute) that best matches 'value'.

        Args:
            attrName (str): the name of the attribute
            value: the value of the attribute
            isOutput (bool): whether the attribute is an output

        Returns:
            desc.Attribute: the generated attribute description
        """
        params = {
            "name": attrName,
            "label": attrName,
            "description": "Incompatible parameter",
            "value": value,
            "uid": (),
            "group": "incompatible"
        }
        if isinstance(value, bool):
            return desc.BoolParam(**params)
        if isinstance(value, int):
            return desc.IntParam(range=None, **params)
        elif isinstance(value, float):
            return desc.FloatParam(range=None, **params)
        elif isinstance(value, pyCompatibility.basestring):
            if isOutput or os.path.isabs(value) or Attribute.isLinkExpression(
                    value):
                return desc.File(**params)
            else:
                return desc.StringParam(**params)
        # List/GroupAttribute: recursively build descriptions
        elif isinstance(value, (list, dict)):
            del params["value"]
            del params["uid"]
            attrDesc = None
            if isinstance(value, list):
                elt = value[
                    0] if value else ""  # fallback: empty string value if list is empty
                eltDesc = CompatibilityNode.attributeDescFromValue(
                    "element", elt, isOutput)
                attrDesc = desc.ListAttribute(elementDesc=eltDesc, **params)
            elif isinstance(value, dict):
                groupDesc = []
                for key, value in value.items():
                    eltDesc = CompatibilityNode.attributeDescFromValue(
                        key, value, isOutput)
                    groupDesc.append(eltDesc)
                attrDesc = desc.GroupAttribute(groupDesc=groupDesc, **params)
            # override empty default value with
            attrDesc._value = value
            return attrDesc
        # handle any other type of parameters as Strings
        return desc.StringParam(**params)
Esempio n. 2
0
class SampleNodeV2(desc.Node):
    """ Changes from V1:
        * 'input' has been renamed to 'in'
    """
    inputs = [
        desc.File(
            name='in',
            label='Input',
            description='',
            value='',
            uid=[0],
        ),
        desc.StringParam(name='paramA',
                         label='ParamA',
                         description='',
                         value='',
                         uid=[]),  # No impact on UID
    ]
    outputs = [
        desc.File(name='output',
                  label='Output',
                  description='',
                  value=desc.Node.internalFolder,
                  uid=[])
    ]
Esempio n. 3
0
class SampleNodeV1(desc.Node):
    """ Version 1 Sample Node """
    inputs = [
        desc.File(name='input', label='Input', description='', value='', uid=[0],),
        desc.StringParam(name='paramA', label='ParamA', description='', value='', uid=[])  # No impact on UID
    ]
    outputs = [
        desc.File(name='output', label='Output', description='', value=desc.Node.internalFolder, uid=[])
    ]
Esempio n. 4
0
class ImageProcessing(desc.CommandLineNode):
    commandLine = 'aliceVision_utils_imageProcessing {allParams}'
    size = desc.DynamicNodeSize('input')
    # parallelization = desc.Parallelization(blockSize=40)
    # commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}'

    documentation = '''
Convert or apply filtering to the input images.
'''

    inputs = [
        desc.File(
            name='input',
            label='Input',
            description=
            'SfMData file input, image filenames or regex(es) on the image file path.\nsupported regex: \'#\' matches a single digit, \'@\' one or more digits, \'?\' one character and \'*\' zero or more.',
            value='',
            uid=[0],
        ),
        desc.ListAttribute(
            elementDesc=desc.File(
                name="inputFolder",
                label="input Folder",
                description="",
                value="",
                uid=[0],
            ),
            name="inputFolders",
            label="Images input Folders",
            description='Use images from specific folder(s).',
        ),
        desc.ListAttribute(
            elementDesc=desc.StringParam(
                name="metadataFolder",
                label="Metadata Folder",
                description="",
                value="",
                uid=[0],
            ),
            name="metadataFolders",
            label="Metadata input Folders",
            description='Use images metadata from specific folder(s).',
        ),
        desc.ChoiceParam(
            name='extension',
            label='Output File Extension',
            description='Output Image File Extension.',
            value='',
            values=['', 'exr', 'jpg', 'tiff', 'png'],
            exclusive=True,
            uid=[0],
        ),
        desc.BoolParam(
            name='reconstructedViewsOnly',
            label='Only Reconstructed Views',
            description='Process Only Reconstructed Views',
            value=False,
            uid=[0],
        ),
        desc.BoolParam(
            name='fixNonFinite',
            label='Fix Non-Finite',
            description=
            'Fix non-finite pixels based on neighboring pixels average.',
            value=False,
            uid=[0],
        ),
        desc.BoolParam(
            name='exposureCompensation',
            label='Exposure Compensation',
            description='Exposure Compensation',
            value=False,
            uid=[0],
        ),
        desc.FloatParam(
            name='scaleFactor',
            label='ScaleFactor',
            description='Scale Factor.',
            value=1.0,
            range=(0.0, 1.0, 0.01),
            uid=[0],
        ),
        desc.FloatParam(
            name='contrast',
            label='Contrast',
            description='Contrast.',
            value=1.0,
            range=(0.0, 100.0, 0.1),
            uid=[0],
        ),
        desc.IntParam(
            name='medianFilter',
            label='Median Filter',
            description='Median Filter.',
            value=0,
            range=(0, 10, 1),
            uid=[0],
        ),
        desc.BoolParam(
            name='fillHoles',
            label='Fill Holes',
            description='Fill holes based on the alpha channel.\n'
            'Note: It will enable fixNonFinite, as it is required for the image pyramid construction used to fill holes.',
            value=False,
            uid=[0],
        ),
        desc.GroupAttribute(name="sharpenFilter",
                            label="Sharpen Filter",
                            description="Sharpen Filtering Parameters.",
                            joinChar=":",
                            groupDesc=[
                                desc.BoolParam(
                                    name='sharpenFilterEnabled',
                                    label='Enable',
                                    description='Use sharpen.',
                                    value=False,
                                    uid=[0],
                                ),
                                desc.IntParam(
                                    name='width',
                                    label='Width',
                                    description='Sharpen Width.',
                                    value=3,
                                    range=(1, 9, 2),
                                    uid=[0],
                                    enabled=lambda node: node.sharpenFilter.
                                    sharpenFilterEnabled.value,
                                ),
                                desc.FloatParam(
                                    name='contrast',
                                    label='Contrast',
                                    description='Sharpen Contrast.',
                                    value=1.0,
                                    range=(0.0, 100.0, 0.1),
                                    uid=[0],
                                    enabled=lambda node: node.sharpenFilter.
                                    sharpenFilterEnabled.value,
                                ),
                                desc.FloatParam(
                                    name='threshold',
                                    label='Threshold',
                                    description='Sharpen Threshold.',
                                    value=0.0,
                                    range=(0.0, 1.0, 0.01),
                                    uid=[0],
                                    enabled=lambda node: node.sharpenFilter.
                                    sharpenFilterEnabled.value,
                                ),
                            ]),
        desc.GroupAttribute(
            name="bilateralFilter",
            label="Bilateral Filter",
            description="Bilateral Filtering Parameters.",
            joinChar=":",
            groupDesc=[
                desc.BoolParam(
                    name='bilateralFilterEnabled',
                    label='Enable',
                    description='Bilateral Filter.',
                    value=False,
                    uid=[0],
                ),
                desc.IntParam(
                    name='bilateralFilterDistance',
                    label='Distance',
                    description=
                    'Diameter of each pixel neighborhood that is used during bilateral filtering.\nCould be very slow for large filters, so it is recommended to use 5.',
                    value=0,
                    range=(0, 9, 1),
                    uid=[0],
                    enabled=lambda node: node.bilateralFilter.
                    bilateralFilterEnabled.value,
                ),
                desc.FloatParam(
                    name='bilateralFilterSigmaSpace',
                    label='Sigma Coordinate Space',
                    description=
                    'Bilateral Filter sigma in the coordinate space.',
                    value=0.0,
                    range=(0.0, 150.0, 0.01),
                    uid=[0],
                    enabled=lambda node: node.bilateralFilter.
                    bilateralFilterEnabled.value,
                ),
                desc.FloatParam(
                    name='bilateralFilterSigmaColor',
                    label='Sigma Color Space',
                    description='Bilateral Filter sigma in the color space.',
                    value=0.0,
                    range=(0.0, 150.0, 0.01),
                    uid=[0],
                    enabled=lambda node: node.bilateralFilter.
                    bilateralFilterEnabled.value,
                ),
            ]),
        desc.GroupAttribute(
            name="claheFilter",
            label="Clahe Filter",
            description="Clahe Filtering Parameters.",
            joinChar=":",
            groupDesc=[
                desc.BoolParam(
                    name='claheEnabled',
                    label='Enable',
                    description=
                    'Use Contrast Limited Adaptive Histogram Equalization (CLAHE) Filter.',
                    value=False,
                    uid=[0],
                ),
                desc.FloatParam(
                    name='claheClipLimit',
                    label='Clip Limit',
                    description='Sets Threshold For Contrast Limiting.',
                    value=4.0,
                    range=(0.0, 8.0, 1.0),
                    uid=[0],
                    enabled=lambda node: node.claheFilter.claheEnabled.value,
                ),
                desc.IntParam(
                    name='claheTileGridSize',
                    label='Tile Grid Size',
                    description=
                    'Sets Size Of Grid For Histogram Equalization. Input Image Will Be Divided Into Equally Sized Rectangular Tiles.',
                    value=8,
                    range=(4, 64, 4),
                    uid=[0],
                    enabled=lambda node: node.claheFilter.claheEnabled.value,
                ),
            ]),
        desc.GroupAttribute(
            name="noiseFilter",
            label="Noise Filter",
            description="Noise Filtering Parameters.",
            joinChar=":",
            groupDesc=[
                desc.BoolParam(
                    name='noiseEnabled',
                    label='Enable',
                    description='Add Noise.',
                    value=False,
                    uid=[0],
                ),
                desc.ChoiceParam(
                    name='noiseMethod',
                    label='Method',
                    description=
                    " * method: There are several noise types to choose from:\n"
                    " * uniform: adds noise values uninformly distributed on range [A,B).\n"
                    " * gaussian: adds Gaussian (normal distribution) noise values with mean value A and standard deviation B.\n"
                    " * salt: changes to value A a portion of pixels given by B.\n",
                    value='uniform',
                    values=['uniform', 'gaussian', 'salt'],
                    exclusive=True,
                    uid=[0],
                    enabled=lambda node: node.noiseFilter.noiseEnabled.value,
                ),
                desc.FloatParam(
                    name='noiseA',
                    label='A',
                    description=
                    'Parameter that have a different interpretation depending on the method chosen.',
                    value=0.0,
                    range=(0.0, 1.0, 0.0001),
                    uid=[0],
                    enabled=lambda node: node.noiseFilter.noiseEnabled.value,
                ),
                desc.FloatParam(
                    name='noiseB',
                    label='B',
                    description=
                    'Parameter that have a different interpretation depending on the method chosen.',
                    value=1.0,
                    range=(0.0, 1.0, 0.0001),
                    uid=[0],
                    enabled=lambda node: node.noiseFilter.noiseEnabled.value,
                ),
                desc.BoolParam(
                    name='noiseMono',
                    label='Mono',
                    description=
                    'If is Checked, a single noise value will be applied to all channels otherwise a separate noise value will be computed for each channel.',
                    value=True,
                    uid=[0],
                    enabled=lambda node: node.noiseFilter.noiseEnabled.value,
                ),
            ]),
        desc.ChoiceParam(
            name='outputFormat',
            label='Output Image Format',
            description='Allows you to choose the format of the output image.',
            value='rgba',
            values=['rgba', 'rgb', 'grayscale'],
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='storageDataType',
            label='Storage Data Type for EXR output',
            description='Storage image data type:\n'
            ' * float: Use full floating point (32 bits per channel)\n'
            ' * half: Use half float (16 bits per channel)\n'
            ' * halfFinite: Use half float, but clamp values to avoid non-finite values\n'
            ' * auto: Use half float if all values can fit, else use full float\n',
            value='float',
            values=['float', 'half', 'halfFinite', 'auto'],
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='verboseLevel',
            label='Verbose Level',
            description=
            'verbosity level (fatal, error, warning, info, debug, trace).',
            value='info',
            values=['fatal', 'error', 'warning', 'info', 'debug', 'trace'],
            exclusive=True,
            uid=[],
        )
    ]

    outputs = [
        desc.File(
            name='outSfMData',
            label='Output sfmData',
            description='Output sfmData.',
            value=lambda attr: (desc.Node.internalFolder + os.path.basename(
                attr.node.input.value)) if (os.path.splitext(
                    attr.node.input.value)[1] in ['.abc', '.sfm']) else '',
            uid=[],
            group='',  # do not export on the command line
        ),
        desc.File(
            name='output',
            label='Output Folder',
            description='Output Images Folder.',
            value=desc.Node.internalFolder,
            uid=[],
        ),
        desc.File(
            name='outputImages',
            label='Output Images',
            description='Output Image Files.',
            value=outputImagesValueFunct,
            group='',  # do not export on the command line
            uid=[],
        ),
    ]
Esempio n. 5
0
class SfMAlignment(desc.CommandLineNode):
    commandLine = 'aliceVision_utils_sfmAlignment {allParams}'
    size = desc.DynamicNodeSize('input')

    inputs = [
        desc.File(
            name='input',
            label='Input',
            description='''SfMData file .''',
            value='',
            uid=[0],
        ),
        desc.File(
            name='reference',
            label='Reference',
            description=
            '''Path to the scene used as the reference coordinate system.''',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='method',
            label='Alignment Method',
            description="Alignment Method:\n"
            " * from_cameras_viewid: Align cameras with same view Id\n"
            " * from_cameras_poseid: Align cameras with same pose Id\n"
            " * from_cameras_filepath: Align cameras with a filepath matching, using 'fileMatchingPattern'\n"
            " * from_cameras_metadata: Align cameras with matching metadata, using 'metadataMatchingList'\n"
            " * from_markers: Align from markers with the same Id\n",
            value='from_cameras_viewid',
            values=[
                'from_cameras_viewid', 'from_cameras_poseid',
                'from_cameras_filepath', 'from_cameras_metadata',
                'from_markers'
            ],
            exclusive=True,
            uid=[0],
        ),
        desc.StringParam(
            name='fileMatchingPattern',
            label='File Matching Pattern',
            description=
            'Matching regular expression for the "from_cameras_filepath" method. '
            'You should capture specific parts of the filepath with parenthesis to define matching elements.\n'
            'Some examples of patterns:\n'
            ' - Match the filename without extension (default value): ".*\/(.*?)\.\w{3}"\n'
            ' - Match the filename suffix after "_": ".*\/.*(_.*?\.\w{3})"\n'
            ' - Match the filename prefix before "_": ".*\/(.*?)_.*\.\w{3}"\n',
            value='.*\/(.*?)\.\w{3}',
            uid=[0],
        ),
        desc.ListAttribute(
            elementDesc=desc.File(
                name="metadataMatching",
                label="Metadata",
                description="",
                value="",
                uid=[0],
            ),
            name="metadataMatchingList",
            label="Metadata Matching List",
            description=
            'List of metadata that should match to create the correspondences. If the list is empty, the default value will be used: ["Make", "Model", "Exif:BodySerialNumber", "Exif:LensSerialNumber"].',
        ),
        desc.BoolParam(name='applyScale',
                       label='Scale',
                       description='Apply scale transformation.',
                       value=True,
                       uid=[0]),
        desc.BoolParam(name='applyRotation',
                       label='Rotation',
                       description='Apply rotation transformation.',
                       value=True,
                       uid=[0]),
        desc.BoolParam(name='applyTranslation',
                       label='Translation',
                       description='Apply translation transformation.',
                       value=True,
                       uid=[0]),
        desc.ChoiceParam(
            name='verboseLevel',
            label='Verbose Level',
            description=
            '''verbosity level (fatal, error, warning, info, debug, trace).''',
            value='info',
            values=['fatal', 'error', 'warning', 'info', 'debug', 'trace'],
            exclusive=True,
            uid=[],
        ),
    ]

    outputs = [
        desc.File(
            name='output',
            label='Output',
            description='''Aligned SfMData file .''',
            value=desc.Node.internalFolder + 'alignedSfM.abc',
            uid=[],
        ),
    ]
Esempio n. 6
0
class SfMTransform(desc.CommandLineNode):
    commandLine = 'aliceVision_utils_sfmTransform {allParams}'
    size = desc.DynamicNodeSize('input')

    documentation = '''
This node allows to change the coordinate system of one SfM scene.

The transformation can be based on:
 * transformation: Apply a given transformation
 * auto_from_cameras: Fit all cameras into a box [-1,1]
 * auto_from_landmarks: Fit all landmarks into a box [-1,1]
 * from_single_camera: Use a specific camera as the origin of the coordinate system
 * from_markers: Align specific markers to custom coordinates

'''

    inputs = [
        desc.File(
            name='input',
            label='Input',
            description='''SfMData file .''',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='method',
            label='Transformation Method',
            description="Transformation method:\n"
                        " * transformation: Apply a given transformation\n"
                        " * manual: Apply the gizmo transformation (show the transformed input)\n"
                        " * auto_from_cameras: Use cameras\n"
                        " * auto_from_landmarks: Use landmarks\n"
                        " * from_single_camera: Use a specific camera as the origin of the coordinate system\n"
                        " * from_markers: Align specific markers to custom coordinates",
            value='auto_from_landmarks',
            values=['transformation', 'manual', 'auto_from_cameras', 'auto_from_landmarks', 'from_single_camera', 'from_markers'],
            exclusive=True,
            uid=[0],
        ),
        desc.StringParam(
            name='transformation',
            label='Transformation',
            description="Required only for 'transformation' and 'from_single_camera' methods:\n"
                        " * transformation: Align [X,Y,Z] to +Y-axis, rotate around Y by R deg, scale by S; syntax: X,Y,Z;R;S\n"
                        " * from_single_camera: Camera UID or image filename",
            value='',
            uid=[0],
            enabled=lambda node: node.method.value == "transformation" or node.method.value == "from_single_camera",
        ),
        desc.GroupAttribute(
            name="manualTransform",
            label="Manual Transform (Gizmo)",
            description="Translation, rotation (Euler ZXY) and uniform scale.",
            groupDesc=[
                desc.GroupAttribute(
                    name="manualTranslation",
                    label="Translation",
                    description="Translation in space.",
                    groupDesc=[
                        desc.FloatParam(
                            name="x", label="x", description="X Offset",
                            value=0.0,
                            uid=[0],
                            range=(-20.0, 20.0, 0.01)
                        ),
                        desc.FloatParam(
                            name="y", label="y", description="Y Offset",
                            value=0.0,
                            uid=[0],
                            range=(-20.0, 20.0, 0.01)
                        ),
                        desc.FloatParam(
                            name="z", label="z", description="Z Offset",
                            value=0.0,
                            uid=[0],
                            range=(-20.0, 20.0, 0.01)
                        )
                    ],
                    joinChar=","
                ),
                desc.GroupAttribute(
                    name="manualRotation",
                    label="Euler Rotation",
                    description="Rotation in Euler degrees.",
                    groupDesc=[
                        desc.FloatParam(
                            name="x", label="x", description="Euler X Rotation",
                            value=0.0,
                            uid=[0],
                            range=(-90.0, 90.0, 1)
                        ),
                        desc.FloatParam(
                            name="y", label="y", description="Euler Y Rotation",
                            value=0.0,
                            uid=[0],
                            range=(-180.0, 180.0, 1)
                        ),
                        desc.FloatParam(
                            name="z", label="z", description="Euler Z Rotation",
                            value=0.0,
                            uid=[0],
                            range=(-180.0, 180.0, 1)
                        )
                    ],
                    joinChar=","
                ),
                desc.FloatParam(
                    name="manualScale",
                    label="Scale",
                    description="Uniform Scale.",
                    value=1.0,
                    uid=[0],
                    range=(0.0, 20.0, 0.01)
                )
            ],
            joinChar=",",
            enabled=lambda node: node.method.value == "manual",
        ),
        desc.ChoiceParam(
            name='landmarksDescriberTypes',
            label='Landmarks Describer Types',
            description='Image describer types used to compute the mean of the point cloud. (only for "landmarks" method).',
            value=['sift', 'dspsift', 'akaze'],
            values=['sift', 'sift_float', 'sift_upright', 'dspsift', 'akaze', 'akaze_liop', 'akaze_mldb', 'cctag3', 'cctag4', 'sift_ocv', 'akaze_ocv', 'unknown'],
            exclusive=False,
            uid=[0],
            joinChar=',',
        ),
        desc.FloatParam(
            name='scale',
            label='Additional Scale',
            description='Additional scale to apply.',
            value=1.0,
            range=(0.0, 100.0, 0.1),
            uid=[0],
        ),
        desc.ListAttribute(
            name="markers",
            elementDesc=desc.GroupAttribute(name="markerAlign", label="Marker Align", description="", joinChar=":", groupDesc=[
                desc.IntParam(name="markerId", label="Marker", description="Marker Id", value=0, uid=[0], range=(0, 32, 1)),
                desc.GroupAttribute(name="markerCoord", label="Coord", description="", joinChar=",", groupDesc=[
                    desc.FloatParam(name="x", label="x", description="", value=0.0, uid=[0], range=(-2.0, 2.0, 1.0)),
                    desc.FloatParam(name="y", label="y", description="", value=0.0, uid=[0], range=(-2.0, 2.0, 1.0)),
                    desc.FloatParam(name="z", label="z", description="", value=0.0, uid=[0], range=(-2.0, 2.0, 1.0)),
                ])
            ]),
            label="Markers",
            description="Markers alignment points",
        ),
        desc.BoolParam(
            name='applyScale',
            label='Scale',
            description='Apply scale transformation.',
            value=True,
            uid=[0],
            enabled=lambda node: node.method.value != "manual",
        ),
        desc.BoolParam(
            name='applyRotation',
            label='Rotation',
            description='Apply rotation transformation.',
            value=True,
            uid=[0],
            enabled=lambda node: node.method.value != "manual",
        ),
        desc.BoolParam(
            name='applyTranslation',
            label='Translation',
            description='Apply translation transformation.',
            value=True,
            uid=[0],
            enabled=lambda node: node.method.value != "manual",
        ),
        desc.ChoiceParam(
            name='verboseLevel',
            label='Verbose Level',
            description='''verbosity level (fatal, error, warning, info, debug, trace).''',
            value='info',
            values=['fatal', 'error', 'warning', 'info', 'debug', 'trace'],
            exclusive=True,
            uid=[],
        ),
    ]

    outputs = [
        desc.File(
            name='output',
            label='Output SfMData File',
            description='''Aligned SfMData file .''',
            value=lambda attr: desc.Node.internalFolder + (os.path.splitext(os.path.basename(attr.node.input.value))[0] or 'sfmData') + '.abc',
            uid=[],
        ),
        desc.File(
            name='outputViewsAndPoses',
            label='Output Poses',
            description='''Path to the output sfmdata file with cameras (views and poses).''',
            value=desc.Node.internalFolder + 'cameras.sfm',
            uid=[],
        ),
    ]
Esempio n. 7
0
class LDRToHDR(desc.CommandLineNode):
    commandLine = 'aliceVision_convertLDRToHDR {allParams}'

    inputs = [
        desc.ListAttribute(
            elementDesc=desc.File(
                name='inputFolder',
                label='Input File/Folder',
                description="Folder containing LDR images",
                value='',
                uid=[0],
                ),
            name="input",
            label="Input Files or Folders",
            description='Folders containing LDR images.',
        ),
        desc.BoolParam(
            name='fisheyeLens',
            label='Fisheye Lens',
            description="Enable if a fisheye lens has been used.\n "
                        "This will improve the estimation of the Camera's Response Function by considering only the pixels in the center of the image\n"
                        "and thus ignore undefined/noisy pixels outside the circle defined by the fisheye lens.",
            value=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='calibrationMethod',
            label='Calibration Method',
            description="Method used for camera calibration \n"
                        " * linear \n"
                        " * robertson \n"
                        " * debevec \n"
                        " * grossberg",
            values=['linear', 'robertson', 'debevec', 'grossberg'],
            value='linear',
            exclusive=True,
            uid=[0],
        ),
        desc.File(
            name='inputResponse',
            label='Input Response',
            description="external camera response file path to fuse all LDR images together.",
            value='',
            uid=[0],
        ),
        desc.StringParam(
            name='targetExposureImage',
            label='Target Exposure Image',
            description="LDR image(s) name(s) at the target exposure for the output HDR image(s) to be centered.",
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='calibrationWeight',
            label='Calibration Weight',
            description="Weight function used to calibrate camera response \n"
                        " * default (automatically selected according to the calibrationMethod) \n"
                        " * gaussian \n"
                        " * triangle \n"
                        " * plateau",
            value='default',
            values=['default', 'gaussian', 'triangle', 'plateau'],
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='fusionWeight',
            label='Fusion Weight',
            description="Weight function used to fuse all LDR images together \n"
                        " * gaussian \n"
                        " * triangle \n" 
                        " * plateau",
            value='gaussian',
            values=['gaussian', 'triangle', 'plateau'],
            exclusive=True,
            uid=[0],
        ),
        desc.FloatParam(
            name='expandDynamicRange',
            label='Expand Dynamic Range',
            description="Correction of clamped high values in dynamic range: \n"
                        " - use 0 for no correction \n"
                        " - use 0.5 for interior lighting \n" 
                        " - use 1 for outdoor lighting",
            value=1,
            range=(0, 1, 0.1),
            uid=[0],
        ),
        desc.ChoiceParam(
            name='verboseLevel',
            label='Verbose Level',
            description="Verbosity level (fatal, error, warning, info, debug, trace).",
            value='info',
            values=['fatal', 'error', 'warning', 'info', 'debug', 'trace'],
            exclusive=True,
            uid=[],
        ),
        desc.File(
            name='recoverPath',
            label='Output Recovered Files',
            description="(debug) Folder for recovered LDR images at target exposures.",
            advanced=True,
            value='',
            uid=[],
        ),
    ]

    outputs = [
        desc.File(
            name='output',
            label='Output Folder',
            description="Output folder for HDR images",
            value=desc.Node.internalFolder,
            uid=[],
        ),
        desc.File(
            name='outputResponse',
            label='Output Response',
            description="Output response function path.",
            value=desc.Node.internalFolder + 'response.csv',
            uid=[],
        ),
    ]
Esempio n. 8
0
class SketchfabUpload(desc.Node):
    size = desc.DynamicNodeSize('inputFiles')

    documentation = '''
Upload a textured mesh on Sketchfab.
'''

    inputs = [
        desc.ListAttribute(
            elementDesc=desc.File(
                name="input",
                label="Input",
                description="",
                value="",
                uid=[0],
            ),
            name="inputFiles",
            label="Input Files",
            description="Input Files to export.",
            group="",
        ),
        desc.StringParam(
            name='apiToken',
            label='API Token',
            description=
            'Get your token from https://sketchfab.com/settings/password',
            value='',
            uid=[0],
        ),
        desc.StringParam(
            name='title',
            label='Title',
            description='Title cannot be longer than 48 characters.',
            value='',
            uid=[0],
        ),
        desc.StringParam(
            name='description',
            label='Description',
            description='Description cannot be longer than 1024 characters.',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='license',
            label='License',
            description='License label.',
            value='CC Attribution',
            values=[
                'CC Attribution', 'CC Attribution-ShareAlike',
                'CC Attribution-NoDerivs', 'CC Attribution-NonCommercial',
                'CC Attribution-NonCommercial-ShareAlike',
                'CC Attribution-NonCommercial-NoDerivs'
            ],
            exclusive=True,
            uid=[0],
        ),
        desc.ListAttribute(
            elementDesc=desc.StringParam(
                name='tag',
                label='Tag',
                description='Tag cannot be longer than 48 characters.',
                value='',
                uid=[0],
            ),
            name="tags",
            label="Tags",
            description="Maximum of 42 separate tags.",
            group="",
        ),
        desc.ChoiceParam(
            name='category',
            label='Category',
            description=
            'Adding categories helps improve the discoverability of your model.',
            value='none',
            values=[
                'none', 'animals-pets', 'architecture', 'art-abstract',
                'cars-vehicles', 'characters-creatures',
                'cultural-heritage-history', 'electronics-gadgets',
                'fashion-style', 'food-drink', 'furniture-home', 'music',
                'nature-plants', 'news-politics', 'people', 'places-travel',
                'science-technology', 'sports-fitness', 'weapons-military'
            ],
            exclusive=True,
            uid=[0],
        ),
        desc.BoolParam(
            name='isPublished',
            label='Publish',
            description=
            'If the model is not published it will be saved as a draft.',
            value=False,
            uid=[0],
        ),
        desc.BoolParam(
            name='isInspectable',
            label='Inspectable',
            description='Allow 2D view in model inspector.',
            value=True,
            uid=[0],
        ),
        desc.BoolParam(
            name='isPrivate',
            label='Private',
            description='Requires a pro account.',
            value=False,
            uid=[0],
        ),
        desc.StringParam(
            name='password',
            label='Password',
            description='Requires a pro account.',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='verboseLevel',
            label='Verbose Level',
            description=
            '''verbosity level (critical, error, warning, info, debug).''',
            value='info',
            values=['critical', 'error', 'warning', 'info', 'debug'],
            exclusive=True,
            uid=[],
        ),
    ]

    def upload(self, apiToken, modelFile, data, chunk):
        modelEndpoint = 'https://api.sketchfab.com/v3/models'
        f = open(modelFile, 'rb')
        file = {'modelFile': (os.path.basename(modelFile), f.read())}
        file.update(data)
        f.close()
        (files, contentType
         ) = requests.packages.urllib3.filepost.encode_multipart_formdata(file)
        headers = {
            'Authorization': 'Token {}'.format(apiToken),
            'Content-Type': contentType
        }
        body = BufferReader(files,
                            progressUpdate,
                            cb_kwargs={'logManager': chunk.logManager},
                            stopped=self.stopped)
        chunk.logger.info('Uploading...')
        try:
            r = requests.post(modelEndpoint, **{
                'data': body,
                'headers': headers
            })
            chunk.logManager.completeProgressBar()
        except requests.exceptions.RequestException as e:
            chunk.logger.error(u'An error occured: {}'.format(e))
            raise RuntimeError()
        if r.status_code != requests.codes.created:
            chunk.logger.error(u'Upload failed with error: {}'.format(
                r.json()))
            raise RuntimeError()

    def resolvedPaths(self, inputFiles):
        paths = []
        for inputFile in inputFiles:
            if os.path.isdir(inputFile.value):
                for path, subdirs, files in os.walk(inputFile.value):
                    for name in files:
                        paths.append(os.path.join(path, name))
            else:
                for f in glob.glob(inputFile.value):
                    paths.append(f)
        return paths

    def stopped(self):
        return self._stopped

    def processChunk(self, chunk):
        try:
            self._stopped = False
            chunk.logManager.start(chunk.node.verboseLevel.value)
            uploadFile = ''

            if not chunk.node.inputFiles:
                chunk.logger.warning('Nothing to upload')
                return
            if chunk.node.apiToken.value == '':
                chunk.logger.error('Need API token.')
                raise RuntimeError()
            if len(chunk.node.title.value) > 48:
                chunk.logger.error(
                    'Title cannot be longer than 48 characters.')
                raise RuntimeError()
            if len(chunk.node.description.value) > 1024:
                chunk.logger.error(
                    'Description cannot be longer than 1024 characters.')
                raise RuntimeError()
            tags = [
                i.value.replace(' ', '-')
                for i in chunk.node.tags.value.values()
            ]
            if all(len(i) > 48 for i in tags) and len(tags) > 0:
                chunk.logger.error('Tags cannot be longer than 48 characters.')
                raise RuntimeError()
            if len(tags) > 42:
                chunk.logger.error('Maximum of 42 separate tags.')
                raise RuntimeError()

            data = {
                'name': chunk.node.title.value,
                'description': chunk.node.description.value,
                'license': chunk.node.license.value,
                'tags': str(tags),
                'isPublished': chunk.node.isPublished.value,
                'isInspectable': chunk.node.isInspectable.value,
                'private': chunk.node.isPrivate.value,
                'password': chunk.node.password.value
            }
            if chunk.node.category.value != 'none':
                data.update({'categories': chunk.node.category.value})
            chunk.logger.debug('Data to be sent: {}'.format(str(data)))

            # pack files into .zip to reduce file size and simplify process
            uploadFile = os.path.join(chunk.node.internalFolder, 'temp.zip')
            files = self.resolvedPaths(chunk.node.inputFiles.value)
            zf = zipfile.ZipFile(uploadFile, 'w')
            for file in files:
                zf.write(file, os.path.basename(file))
            zf.close()
            chunk.logger.debug('Files added to zip: {}'.format(str(files)))
            chunk.logger.debug('Created {}'.format(uploadFile))
            chunk.logger.info('File size: {}MB'.format(
                round(os.path.getsize(uploadFile) / (1024 * 1024), 3)))

            self.upload(chunk.node.apiToken.value, uploadFile, data, chunk)
            chunk.logger.info(
                'Upload successful. Your model is being processed on Sketchfab. It may take some time to show up on your "models" page.'
            )
        except Exception as e:
            chunk.logger.error(e)
            raise RuntimeError()
        finally:
            if os.path.isfile(uploadFile):
                os.remove(uploadFile)
                chunk.logger.debug('Deleted {}'.format(uploadFile))

            chunk.logManager.end()

    def stopProcess(self, chunk):
        self._stopped = True
Esempio n. 9
0
class FeatureRepeatability(desc.CommandLineNode):
    commandLine = 'aliceVision_samples_repeatabilityDataset {allParams}'
    size = desc.DynamicNodeSize('input')
    # parallelization = desc.Parallelization(blockSize=40)
    # commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}'

    category = 'Utils'
    documentation = '''
Compare feature/descriptor matching repeatability on some dataset with known homography motions.
'''

    inputs = [
        desc.File(
            name='input',
            label='Input Folder',
            description='Input Folder with evaluation datasets.',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='describerTypes',
            label='Describer Types',
            description='Describer types used to describe an image.',
            value=['sift'],
            values=[
                'sift', 'sift_float', 'sift_upright', 'dspsift', 'akaze',
                'akaze_liop', 'akaze_mldb', 'cctag3', 'cctag4', 'sift_ocv',
                'akaze_ocv'
            ],
            exclusive=False,
            uid=[0],
            joinChar=',',
        ),
        desc.ChoiceParam(
            name='describerPreset',
            label='Describer Density',
            description=
            'Control the ImageDescriber density (low, medium, normal, high, ultra).\n'
            'Warning: Use ULTRA only on small datasets.',
            value='normal',
            values=['low', 'medium', 'normal', 'high', 'ultra'],
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='describerQuality',
            label='Describer Quality',
            description=
            'Control the ImageDescriber quality (low, medium, normal, high, ultra).',
            value='normal',
            values=['low', 'medium', 'normal', 'high', 'ultra'],
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='contrastFiltering',
            label='Contrast Filtering',
            description=
            "Contrast filtering method to ignore features with too low contrast that can be considered as noise:\n"
            "* Static: Fixed threshold.\n"
            "* AdaptiveToMedianVariance: Based on image content analysis.\n"
            "* NoFiltering: Disable contrast filtering.\n"
            "* GridSortOctaves: Grid Sort but per octaves (and only per scale at the end).\n"
            "* GridSort: Grid sort per octaves and at the end (scale * peakValue).\n"
            "* GridSortScaleSteps: Grid sort per octaves and at the end (scale and then peakValue).\n"
            "* NonExtremaFiltering: Filter non-extrema peakValues.\n",
            value='Static',
            values=[
                'Static', 'AdaptiveToMedianVariance', 'NoFiltering',
                'GridSortOctaves', 'GridSort', 'GridSortScaleSteps',
                'GridSortOctaveSteps', 'NonExtremaFiltering'
            ],
            exclusive=True,
            advanced=True,
            uid=[0],
        ),
        desc.FloatParam(
            name='relativePeakThreshold',
            label='Relative Peak Threshold',
            description='Peak Threshold relative to median of gradiants.',
            value=0.01,
            range=(0.01, 1.0, 0.001),
            advanced=True,
            uid=[0],
            enabled=lambda node:
            (node.contrastFiltering.value == 'AdaptiveToMedianVariance'),
        ),
        desc.BoolParam(
            name='gridFiltering',
            label='Grid Filtering',
            description=
            'Enable grid filtering. Highly recommended to ensure usable number of features.',
            value=True,
            advanced=True,
            uid=[0],
        ),
        desc.BoolParam(
            name='forceCpuExtraction',
            label='Force CPU Extraction',
            description='Use only CPU feature extraction.',
            value=True,
            uid=[],
            advanced=True,
        ),
        desc.IntParam(
            name='invalidate',
            label='Invalidate',
            description='Invalidate.',
            value=0,
            range=(0, 10000, 1),
            group="",
            uid=[0],
        ),
        desc.StringParam(
            name="comments",
            label="Comments",
            description="Comments",
            value="",
            group="",
            uid=[],
        ),
        desc.ChoiceParam(
            name='verboseLevel',
            label='Verbose Level',
            description=
            'verbosity level (fatal, error, warning, info, debug, trace).',
            value='info',
            values=['fatal', 'error', 'warning', 'info', 'debug', 'trace'],
            exclusive=True,
            uid=[],
        )
    ]

    outputs = [
        desc.File(
            name='output',
            label='Output Folder',
            description=
            'Output path for the features and descriptors files (*.feat, *.desc).',
            value=desc.Node.internalFolder,
            uid=[],
        ),
    ]
Esempio n. 10
0
                  description="Rig Parameters",
                  value=-1,
                  uid=[0],
                  range=None),
    desc.IntParam(name="subPoseId",
                  label="Rig Sub-Pose",
                  description="Rig Sub-Pose Parameters",
                  value=-1,
                  uid=[0],
                  range=None),
    desc.StringParam(
        name="metadata",
        label="Image Metadata",
        description=
        "The configuration of the Viewpoints is based on the images metadata.\n"
        "The important ones are:\n"
        " * Focal Length: the focal length in mm.\n"
        " * Make and Model: this information allows to convert the focal in mm into a focal length in pixel using an embedded sensor database.\n"
        " * Serial Number: allows to uniquely identify a device so multiple devices with the same Make, Model can be differentiated and their internal parameters are optimized separately.",
        value="",
        uid=[],
        advanced=True),
]

Intrinsic = [
    desc.IntParam(name="intrinsicId",
                  label="Id",
                  description="Intrinsic UID",
                  value=-1,
                  uid=[0],
                  range=None),
    desc.FloatParam(
Esempio n. 11
0
class CameraLocalization(desc.CommandLineNode):
    commandLine = 'aliceVision_cameraLocalization {allParams}'

    inputs = [
        desc.File(
            name='sfmdata',
            label='SfM Data',
            description=
            '''The sfm_data.json kind of file generated by AliceVision.''',
            value='',
            uid=[0],
        ),
        desc.File(
            name='mediafile',
            label='Media File',
            description=
            '''The folder path or the filename for the media to track''',
            value='',
            uid=[0],
        ),
        desc.File(
            name='visualDebug',
            label='Visual Debug Folder',
            description=
            '''If a folder is provided it enables visual debug and saves all the debugging info in that folder''',
            value='',
            uid=[0],
        ),
        desc.File(
            name='descriptorPath',
            label='Descriptor Path',
            description=
            '''Folder containing the descriptors for all the images (ie the *.desc.)''',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='matchDescTypes',
            label='Match Desc Types',
            description='''Describer types to use for the matching.''',
            value=['sift'],
            values=[
                'sift', 'sift_float', 'sift_upright', 'dspsift', 'akaze',
                'akaze_liop', 'akaze_mldb', 'cctag3', 'cctag4', 'sift_ocv',
                'akaze_ocv'
            ],
            exclusive=False,
            uid=[0],
            joinChar=',',
        ),
        desc.ChoiceParam(
            name='preset',
            label='Preset',
            description=
            '''Preset for the feature extractor when localizing a new image (low, medium, normal, high, ultra)''',
            value='normal',
            values=['low', 'medium', 'normal', 'high', 'ultra'],
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='resectionEstimator',
            label='Resection Estimator',
            description=
            '''The type of *sac framework to use for resection (acransac, loransac)''',
            value='acransac',
            values=['acransac', 'loransac'],
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='matchingEstimator',
            label='Matching Estimator',
            description=
            '''The type of *sac framework to use for matching (acransac, loransac)''',
            value='acransac',
            values=['acransac', 'loransac'],
            exclusive=True,
            uid=[0],
        ),
        desc.File(
            name='calibration',
            label='Calibration',
            description='''Calibration file''',
            value='',
            uid=[0],
        ),
        desc.BoolParam(
            name='refineIntrinsics',
            label='Refine Intrinsics',
            description=
            '''Enable/Disable camera intrinsics refinement for each localized image''',
            value=False,
            uid=[0],
        ),
        desc.FloatParam(
            name='reprojectionError',
            label='Reprojection Error',
            description=
            '''Maximum reprojection error (in pixels) allowed for resectioning. If set to 0 it lets the ACRansac select an optimal value.''',
            value=4.0,
            range=(0.1, 50.0, 0.1),
            uid=[0],
        ),
        desc.IntParam(
            name='nbImageMatch',
            label='Nb Image Match',
            description=
            '''[voctree] Number of images to retrieve in database''',
            value=4,
            range=(1, 1000, 1),
            uid=[0],
        ),
        desc.IntParam(
            name='maxResults',
            label='Max Results',
            description=
            '''[voctree] For algorithm AllResults, it stops the image matching when this number of matched images is reached. If 0 it is ignored.''',
            value=10,
            range=(1, 100, 1),
            uid=[0],
        ),
        desc.IntParam(
            name='commonviews',
            label='Commonviews',
            description=
            '''[voctree] Number of minimum images in which a point must be seen to be used in cluster tracking''',
            value=3,
            range=(2, 50, 1),
            uid=[0],
        ),
        desc.File(
            name='voctree',
            label='Voctree',
            description='''[voctree] Filename for the vocabulary tree''',
            value=os.environ.get('ALICEVISION_VOCTREE', ''),
            uid=[0],
        ),
        desc.File(
            name='voctreeWeights',
            label='Voctree Weights',
            description=
            '''[voctree] Filename for the vocabulary tree weights''',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='algorithm',
            label='Algorithm',
            description='''[voctree] Algorithm type: FirstBest, AllResults''',
            value='AllResults',
            values=['FirstBest', 'AllResults'],
            exclusive=True,
            uid=[0],
        ),
        desc.FloatParam(
            name='matchingError',
            label='Matching Error',
            description=
            '''[voctree] Maximum matching error (in pixels) allowed for image matching with geometric verification. If set to 0 it lets the ACRansac select an optimal value.''',
            value=4.0,
            range=(0.0, 50.0, 1.0),
            uid=[0],
        ),
        desc.IntParam(
            name='nbFrameBufferMatching',
            label='Nb Frame Buffer Matching',
            description=
            '''[voctree] Number of previous frame of the sequence to use for matching (0 = Disable)''',
            value=10,
            range=(0, 100, 1),
            uid=[0],
        ),
        desc.BoolParam(
            name='robustMatching',
            label='Robust Matching',
            description=
            '''[voctree] Enable/Disable the robust matching between query and database images, all putative matches will be considered.''',
            value=True,
            uid=[0],
        ),
        desc.IntParam(
            name='nNearestKeyFrames',
            label='N Nearest Key Frames',
            description=
            '''[cctag] Number of images to retrieve in the database Parameters specific for final (optional) bundle adjustment optimization of the sequence:''',
            value=5,
            range=(1, 100, 1),
            uid=[0],
        ),
        desc.StringParam(
            name='globalBundle',
            label='Global Bundle',
            description=
            '''[bundle adjustment] If --refineIntrinsics is not set, this option allows to run a final global bundle adjustment to refine the scene.''',
            value='',
            uid=[0],
        ),
        desc.BoolParam(
            name='noDistortion',
            label='No Distortion',
            description=
            '''[bundle adjustment] It does not take into account distortion during the BA, it consider the distortion coefficients all equal to 0''',
            value=False,
            uid=[0],
        ),
        desc.BoolParam(
            name='noBArefineIntrinsics',
            label='No BA Refine Intrinsics',
            description=
            '''[bundle adjustment] It does not refine intrinsics during BA''',
            value=False,
            uid=[0],
        ),
        desc.IntParam(
            name='minPointVisibility',
            label='Min Point Visibility',
            description=
            '''[bundle adjustment] Minimum number of observation that a point must have in order to be considered for bundle adjustment''',
            value=2,
            range=(2, 50, 1),
            uid=[0],
        ),
    ]

    outputs = [
        desc.File(
            name='outputAlembic',
            label='Output Alembic',
            description=
            '''Filename for the SfMData export file (where camera poses will be stored)''',
            value=desc.Node.internalFolder + 'trackedCameras.abc',
            uid=[],
        ),
        desc.File(
            name='outputJSON',
            label='Output JSON',
            description='''Filename for the localization results as .json''',
            value=desc.Node.internalFolder + 'trackedCameras.json',
            uid=[],
        ),
    ]
Esempio n. 12
0
                  range=None),
    desc.IntParam(name="rigId",
                  label="Rig",
                  description="Rig Parameters",
                  value=-1,
                  uid=[0],
                  range=None),
    desc.IntParam(name="subPoseId",
                  label="Rig Sub-Pose",
                  description="Rig Sub-Pose Parameters",
                  value=-1,
                  uid=[0],
                  range=None),
    desc.StringParam(name="metadata",
                     label="Image Metadata",
                     description="",
                     value="",
                     uid=[],
                     advanced=True),
]

Intrinsic = [
    desc.IntParam(name="intrinsicId",
                  label="Id",
                  description="Intrinsic UID",
                  value=-1,
                  uid=[0],
                  range=None),
    desc.FloatParam(name="pxInitialFocalLength",
                    label="Initial Focal Length",
                    description="Initial Guess on the Focal Length",
                    value=-1.0,
Esempio n. 13
0
class SfMTransform(desc.CommandLineNode):
    commandLine = 'aliceVision_utils_sfmTransform {allParams}'
    size = desc.DynamicNodeSize('input')

    inputs = [
        desc.File(
            name='input',
            label='Input',
            description='''SfMData file .''',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='method',
            label='Transformation Method',
            description="Transformation method:\n"
            " * transformation: Apply a given transformation\n"
            " * auto_from_cameras: Use cameras\n"
            " * auto_from_landmarks: Use landmarks\n"
            " * from_single_camera: Use a specific camera as the origin of the coordinate system\n"
            " * from_markers: Align specific markers to custom coordinates",
            value='auto_from_landmarks',
            values=[
                'transformation', 'auto_from_cameras', 'auto_from_landmarks',
                'from_single_camera', 'from_markers'
            ],
            exclusive=True,
            uid=[0],
        ),
        desc.StringParam(
            name='transformation',
            label='Transformation',
            description=
            "Required only for 'transformation' and 'from_single_camera' methods:\n"
            " * transformation: Align [X,Y,Z] to +Y-axis, rotate around Y by R deg, scale by S; syntax: X,Y,Z;R;S\n"
            " * from_single_camera: Camera UID or image filename",
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='landmarksDescriberTypes',
            label='Landmarks Describer Types',
            description=
            'Image describer types used to compute the mean of the point cloud. (only for "landmarks" method).',
            value=['sift', 'akaze'],
            values=[
                'sift', 'sift_float', 'sift_upright', 'akaze', 'akaze_liop',
                'akaze_mldb', 'cctag3', 'cctag4', 'sift_ocv', 'akaze_ocv'
            ],
            exclusive=False,
            uid=[0],
            joinChar=',',
        ),
        desc.FloatParam(
            name='scale',
            label='Additional Scale',
            description='Additional scale to apply.',
            value=1.0,
            range=(0.0, 100.0, 0.1),
            uid=[0],
        ),
        desc.ListAttribute(
            name="markers",
            elementDesc=desc.GroupAttribute(
                name="markerAlign",
                label="Marker Align",
                description="",
                joinChar=":",
                groupDesc=[
                    desc.IntParam(name="markerId",
                                  label="Marker",
                                  description="Marker Id",
                                  value=0,
                                  uid=[0],
                                  range=(0, 32, 1)),
                    desc.GroupAttribute(
                        name="markerCoord",
                        label="Coord",
                        description="",
                        joinChar=",",
                        groupDesc=[
                            desc.FloatParam(name="x",
                                            label="x",
                                            description="",
                                            value=0.0,
                                            uid=[0],
                                            range=(-2.0, 2.0, 1.0)),
                            desc.FloatParam(name="y",
                                            label="y",
                                            description="",
                                            value=0.0,
                                            uid=[0],
                                            range=(-2.0, 2.0, 1.0)),
                            desc.FloatParam(name="z",
                                            label="z",
                                            description="",
                                            value=0.0,
                                            uid=[0],
                                            range=(-2.0, 2.0, 1.0)),
                        ])
                ]),
            label="Markers",
            description="Markers alignment points",
        ),
        desc.BoolParam(name='applyScale',
                       label='Scale',
                       description='Apply scale transformation.',
                       value=True,
                       uid=[0]),
        desc.BoolParam(name='applyRotation',
                       label='Rotation',
                       description='Apply rotation transformation.',
                       value=True,
                       uid=[0]),
        desc.BoolParam(name='applyTranslation',
                       label='Translation',
                       description='Apply translation transformation.',
                       value=True,
                       uid=[0]),
        desc.ChoiceParam(
            name='verboseLevel',
            label='Verbose Level',
            description=
            '''verbosity level (fatal, error, warning, info, debug, trace).''',
            value='info',
            values=['fatal', 'error', 'warning', 'info', 'debug', 'trace'],
            exclusive=True,
            uid=[],
        ),
    ]

    outputs = [
        desc.File(
            name='output',
            label='Output',
            description='''Aligned SfMData file .''',
            value=desc.Node.internalFolder + 'transformedSfM.abc',
            uid=[],
        ),
    ]
Esempio n. 14
0
class SfMTransfer(desc.CommandLineNode):
    commandLine = 'aliceVision_utils_sfmTransfer {allParams}'
    size = desc.DynamicNodeSize('input')

    category = 'Utils'
    documentation = '''
This node allows to transfer poses and/or intrinsics form one SfM scene onto another one.
'''

    inputs = [
        desc.File(
            name='input',
            label='Input',
            description='''SfMData file .''',
            value='',
            uid=[0],
        ),
        desc.File(
            name='reference',
            label='Reference',
            description='''Path to the scene used as the reference to retrieve resolved poses and intrinsics.''',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='method',
            label='Matching Method',
            description="Matching Method:\n"
                " * from_viewid: Align cameras with same view Id\n"
                " * from_filepath: Align cameras with a filepath matching, using 'fileMatchingPattern'\n"
                " * from_metadata: Align cameras with matching metadata, using 'metadataMatchingList'\n"
                " * from_intrinsicid: Copy intrinsics parameters\n",
            value='from_viewid',
            values=['from_viewid', 'from_filepath', 'from_metadata', 'from_intrinsicid'],
            exclusive=True,
            uid=[0],
        ),
        desc.StringParam(
            name='fileMatchingPattern',
            label='File Matching Pattern',
            description='Matching regular expression for the "from_cameras_filepath" method. '
                        'You should capture specific parts of the filepath with parenthesis to define matching elements.\n'
                        'Some examples of patterns:\n'
                        ' - Match the filename without extension (default value): ".*\/(.*?)\.\w{3}"\n'
                        ' - Match the filename suffix after "_": ".*\/.*(_.*?\.\w{3})"\n'
                        ' - Match the filename prefix before "_": ".*\/(.*?)_.*\.\w{3}"\n',
            value='.*\/(.*?)\.\w{3}',
            uid=[0],
        ),
        desc.ListAttribute(
            elementDesc=desc.File(
                name="metadataMatching",
                label="Metadata",
                description="",
                value="",
                uid=[0],
            ),
            name="metadataMatchingList",
            label="Metadata Matching List",
            description='List of metadata that should match to create the correspondences. If the list is empty, the default value will be used: ["Make", "Model", "Exif:BodySerialNumber", "Exif:LensSerialNumber"].',
        ),
        desc.BoolParam(
            name='transferPoses',
            label='Poses',
            description='Transfer poses.',
            value=True,
            uid=[0]
        ),
        desc.BoolParam(
            name='transferIntrinsics',
            label='Intrinsics',
            description='Transfer cameras intrinsics.',
            value=True,
            uid=[0]
        ),
        desc.ChoiceParam(
            name='verboseLevel',
            label='Verbose Level',
            description='''verbosity level (fatal, error, warning, info, debug, trace).''',
            value='info',
            values=['fatal', 'error', 'warning', 'info', 'debug', 'trace'],
            exclusive=True,
            uid=[],
        ),
    ]

    outputs = [
        desc.File(
            name='output',
            label='Output SfMData File',
            description='SfMData file.',
            value=lambda attr: desc.Node.internalFolder + (os.path.splitext(os.path.basename(attr.node.input.value))[0] or 'sfmData') + '.abc',
            uid=[],
        ),
        desc.File(
            name='outputViewsAndPoses',
            label='Output Poses',
            description='''Path to the output sfmdata file with cameras (views and poses).''',
            value=desc.Node.internalFolder + 'cameras.sfm',
            uid=[],
        ),
    ]
Esempio n. 15
0
class CameraRigCalibration(desc.CommandLineNode):
    commandLine = 'aliceVision_rigCalibration {allParams}'

    inputs = [
        desc.File(
            name='sfmdata',
            label='SfM Data',
            description='''The sfmData file.''',
            value='',
            uid=[0],
        ),
        desc.File(
            name='mediapath',
            label='Media Path',
            description=
            '''The path to the video file, the folder of the image sequence or a text file (one image path per line) for each camera of the rig (eg. --mediapath /path/to/cam1.mov /path/to/cam2.mov).''',
            value='',
            uid=[0],
        ),
        desc.File(
            name='cameraIntrinsics',
            label='Camera Intrinsics',
            description=
            '''The intrinsics calibration file for each camera of the rig. (eg. --cameraIntrinsics /path/to/calib1.txt /path/to/calib2.txt).''',
            value='',
            uid=[0],
        ),
        desc.File(
            name='export',
            label='Export',
            description=
            '''Filename for the alembic file containing the rig poses with the 3D points. It also saves a file for each camera named 'filename.cam##.abc'.''',
            value='trackedcameras.abc',
            uid=[0],
        ),
        desc.File(
            name='descriptorPath',
            label='Descriptor Path',
            description='''Folder containing the .desc.''',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='matchDescTypes',
            label='Match Describer Types',
            description='''The describer types to use for the matching''',
            value=['sift'],
            values=[
                'sift', 'sift_float', 'sift_upright', 'dspsift', 'akaze',
                'akaze_liop', 'akaze_mldb', 'cctag3', 'cctag4', 'sift_ocv',
                'akaze_ocv'
            ],
            exclusive=False,
            uid=[0],
            joinChar=',',
        ),
        desc.ChoiceParam(
            name='preset',
            label='Preset',
            description=
            '''Preset for the feature extractor when localizing a new image (low, medium, normal, high, ultra)''',
            value='normal',
            values=['low', 'medium', 'normal', 'high', 'ultra'],
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='resectionEstimator',
            label='Resection Estimator',
            description=
            '''The type of *sac framework to use for resection (acransac,loransac)''',
            value='acransac',
            values=['acransac', 'loransac'],
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='matchingEstimator',
            label='Matching Estimator',
            description=
            '''The type of *sac framework to use for matching (acransac,loransac)''',
            value='acransac',
            values=['acransac', 'loransac'],
            exclusive=True,
            uid=[0],
        ),
        desc.StringParam(
            name='refineIntrinsics',
            label='Refine Intrinsics',
            description=
            '''Enable/Disable camera intrinsics refinement for each localized image''',
            value='',
            uid=[0],
        ),
        desc.FloatParam(
            name='reprojectionError',
            label='Reprojection Error',
            description=
            '''Maximum reprojection error (in pixels) allowed for resectioning. If set to 0 it lets the ACRansac select an optimal value.''',
            value=4.0,
            range=(0.0, 10.0, 0.1),
            uid=[0],
        ),
        desc.IntParam(
            name='maxInputFrames',
            label='Max Input Frames',
            description=
            '''Maximum number of frames to read in input. 0 means no limit.''',
            value=0,
            range=(0, 1000, 1),
            uid=[0],
        ),
        desc.File(
            name='voctree',
            label='Voctree',
            description='''[voctree] Filename for the vocabulary tree''',
            value=os.environ.get('ALICEVISION_VOCTREE', ''),
            uid=[0],
        ),
        desc.File(
            name='voctreeWeights',
            label='Voctree Weights',
            description=
            '''[voctree] Filename for the vocabulary tree weights''',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='algorithm',
            label='Algorithm',
            description='''[voctree] Algorithm type: {FirstBest,AllResults}''',
            value='AllResults',
            values=['FirstBest', 'AllResults'],
            exclusive=True,
            uid=[0],
        ),
        desc.IntParam(
            name='nbImageMatch',
            label='Nb Image Match',
            description=
            '''[voctree] Number of images to retrieve in the database''',
            value=4,
            range=(0, 50, 1),
            uid=[0],
        ),
        desc.IntParam(
            name='maxResults',
            label='Max Results',
            description=
            '''[voctree] For algorithm AllResults, it stops the image matching when this number of matched images is reached. If 0 it is ignored.''',
            value=10,
            range=(0, 100, 1),
            uid=[0],
        ),
        desc.FloatParam(
            name='matchingError',
            label='Matching Error',
            description=
            '''[voctree] Maximum matching error (in pixels) allowed for image matching with geometric verification. If set to 0 it lets the ACRansac select an optimal value.''',
            value=4.0,
            range=(0.0, 10.0, 0.1),
            uid=[0],
        ),
        desc.IntParam(
            name='nNearestKeyFrames',
            label='N Nearest Key Frames',
            description='''[cctag] Number of images to retrieve in database''',
            value=5,
            range=(0, 50, 1),
            uid=[0],
        ),
    ]

    outputs = [
        desc.File(
            name='outfile',
            label='Output File',
            description=
            '''The name of the file where to store the calibration data''',
            value=desc.Node.internalFolder + 'cameraRigCalibration.rigCal',
            uid=[],
        ),
    ]
Esempio n. 16
0
class CameraInit(desc.CommandLineNode):
    commandLine = 'aliceVision_cameraInit {allParams} --allowSingleView 1'  # don't throw an error if there is only one image

    size = desc.DynamicNodeSize('viewpoints')

    documentation = '''
This node describes your dataset. It lists the Viewpoints candidates, the guess about the type of optic, the initial focal length
and which images are sharing the same internal camera parameters, as well as potential cameras rigs.

When you import new images into Meshroom, this node is automatically configured from the analysis of the image metadata.
The software can support images without any metadata but it is recommended to have them for robustness.

### Metadata
Metadata allows images to be grouped together and provides an initialization of the focal length (in pixel unit).
The metadata needed are:
 * **Focal Length**: the focal length in mm.
 * **Make** & **Model**: this information allows to convert the focal in mm into a focal length in pixel using an embedded sensor database.
 * **Serial Number**: allows to uniquely identify a device so multiple devices with the same Make, Model can be differentiated and their internal parameters are optimized separately (in the photogrammetry case).
'''

    inputs = [
        desc.ListAttribute(
            name="viewpoints",
            elementDesc=desc.GroupAttribute(name="viewpoint",
                                            label="Viewpoint",
                                            description="",
                                            groupDesc=Viewpoint),
            label="Viewpoints",
            description="Input viewpoints",
            group="",
        ),
        desc.ListAttribute(
            name="intrinsics",
            elementDesc=desc.GroupAttribute(name="intrinsic",
                                            label="Intrinsic",
                                            description="",
                                            groupDesc=Intrinsic),
            label="Intrinsics",
            description="Camera Intrinsics",
            group="",
        ),
        desc.File(
            name='sensorDatabase',
            label='Sensor Database',
            description='''Camera sensor width database path.''',
            value=os.environ.get('ALICEVISION_SENSOR_DB', ''),
            uid=[],
        ),
        desc.FloatParam(
            name='defaultFieldOfView',
            label='Default Field Of View',
            description='Empirical value for the field of view in degree.',
            value=45.0,
            range=(0, 180.0, 1),
            uid=[],
            advanced=True,
        ),
        desc.ChoiceParam(
            name='groupCameraFallback',
            label='Group Camera Fallback',
            description=
            "If there is no serial number in image metadata, devices cannot be accurately identified.\n"
            "Therefore, internal camera parameters cannot be shared among images reliably.\n"
            "A fallback grouping strategy must be chosen:\n"
            " * global: group images from comparable devices (same make/model/focal) globally.\n"
            " * folder: group images from comparable devices only within the same folder.\n"
            " * image: never group images from comparable devices",
            values=['global', 'folder', 'image'],
            value='folder',
            exclusive=True,
            uid=[],
            advanced=True,
        ),
        desc.ChoiceParam(
            name='allowedCameraModels',
            label='Allowed Camera Models',
            description='the Camera Models that can be attributed.',
            value=[
                'pinhole', 'radial1', 'radial3', 'brown', 'fisheye4',
                'fisheye1'
            ],
            values=[
                'pinhole', 'radial1', 'radial3', 'brown', 'fisheye4',
                'fisheye1'
            ],
            exclusive=False,
            uid=[],
            joinChar=',',
            advanced=True,
        ),
        desc.BoolParam(
            name='useInternalWhiteBalance',
            label='Apply internal white balance',
            description='Apply image white balance (Only for raw images)',
            value=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='viewIdMethod',
            label='ViewId Method',
            description="Allows to choose the way the viewID is generated:\n"
            " * metadata : Generate viewId from image metadata.\n"
            " * filename : Generate viewId from file names using regex.",
            value='metadata',
            values=['metadata', 'filename'],
            exclusive=True,
            uid=[],
            advanced=True,
        ),
        desc.StringParam(
            name='viewIdRegex',
            label='ViewId Regex',
            description='Regex used to catch number used as viewId in filename.'
            'You should capture specific parts of the filename with parenthesis to define matching elements. (only number will works)\n'
            'Some examples of patterns:\n'
            ' - Match the longest number at the end of filename (default value): ".*?(\d+)"\n'
            ' - Match the first number found in filename : "(\d+).*"\n',
            value='.*?(\d+)',
            uid=[],
            advanced=True,
            enabled=lambda node: node.viewIdMethod.value == 'filename',
        ),
        desc.ChoiceParam(
            name='verboseLevel',
            label='Verbose Level',
            description=
            '''verbosity level (fatal, error, warning, info, debug, trace).''',
            value='info',
            values=['fatal', 'error', 'warning', 'info', 'debug', 'trace'],
            exclusive=True,
            uid=[],
        ),
    ]

    outputs = [
        desc.File(
            name='output',
            label='SfMData',
            description='''Output SfMData.''',
            value=desc.Node.internalFolder + 'cameraInit.sfm',
            uid=[],
        ),
    ]

    def readSfMData(self, sfmFile):
        return readSfMData(sfmFile)

    def buildIntrinsics(self, node, additionalViews=()):
        """ Build intrinsics from node current views and optional additional views

        Args:
            node: the CameraInit node instance to build intrinsics for
            additionalViews: (optional) the new views (list of path to images) to add to the node's viewpoints

        Returns:
            The updated views and intrinsics as two separate lists
        """
        assert isinstance(node.nodeDesc, CameraInit)
        if node.graph:
            # make a copy of the node outside the graph
            # to change its cache folder without modifying the original node
            node = node.graph.copyNode(node)[0]

        tmpCache = tempfile.mkdtemp()
        node.updateInternals(tmpCache)

        try:
            os.makedirs(os.path.join(tmpCache, node.internalFolder))
            self.createViewpointsFile(node, additionalViews)
            cmd = self.buildCommandLine(node.chunks[0])
            logging.debug(' - commandLine: {}'.format(cmd))
            proc = psutil.Popen(cmd, stdout=None, stderr=None, shell=True)
            stdout, stderr = proc.communicate()
            # proc.wait()
            if proc.returncode != 0:
                raise RuntimeError(
                    'CameraInit failed with error code {}.\nCommand was: "{}".\n'
                    .format(proc.returncode, cmd))

            # Reload result of aliceVision_cameraInit
            cameraInitSfM = node.output.value
            return readSfMData(cameraInitSfM)

        except Exception as e:
            logging.debug(
                "[CameraInit] Error while building intrinsics: {}".format(
                    str(e)))
            raise
        finally:
            if os.path.exists(tmpCache):
                logging.debug(
                    "[CameraInit] Remove temp files in: {}".format(tmpCache))
                shutil.rmtree(tmpCache)

    def createViewpointsFile(self, node, additionalViews=()):
        node.viewpointsFile = ""
        if node.viewpoints or additionalViews:
            newViews = []
            for path in additionalViews:  # format additional views to match json format
                newViews.append({"path": path})
            intrinsics = node.intrinsics.getPrimitiveValue(exportDefault=True)
            for intrinsic in intrinsics:
                intrinsic['principalPoint'] = [
                    intrinsic['principalPoint']['x'],
                    intrinsic['principalPoint']['y']
                ]
            views = node.viewpoints.getPrimitiveValue(exportDefault=False)

            # convert the metadata string into a map
            for view in views:
                if 'metadata' in view:
                    view['metadata'] = json.loads(view['metadata'])

            sfmData = {
                "version": [1, 0, 0],
                "views": views + newViews,
                "intrinsics": intrinsics,
                "featureFolder": "",
                "matchingFolder": "",
            }
            node.viewpointsFile = (node.nodeDesc.internalFolder +
                                   '/viewpoints.sfm').format(**node._cmdVars)
            with open(node.viewpointsFile, 'w') as f:
                json.dump(sfmData, f, indent=4)

    def buildCommandLine(self, chunk):
        cmd = desc.CommandLineNode.buildCommandLine(self, chunk)
        if chunk.node.viewpointsFile:
            cmd += ' --input "{}"'.format(chunk.node.viewpointsFile)
        return cmd

    def processChunk(self, chunk):
        self.createViewpointsFile(chunk.node)
        desc.CommandLineNode.processChunk(self, chunk)
Esempio n. 17
0
class SfMTransform(desc.CommandLineNode):
    commandLine = 'aliceVision_utils_sfmTransform {allParams}'
    size = desc.DynamicNodeSize('input')

    inputs = [
        desc.File(
            name='input',
            label='Input',
            description='''SfMData file .''',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='method',
            label='Transformation Method',
            description=
            '''Transformation method (transformation, auto_from_cameras, auto_from_landmarks).''',
            value='auto_from_landmarks',
            values=[
                'transformation', 'auto_from_cameras', 'auto_from_landmarks'
            ],
            exclusive=True,
            uid=[0],
        ),
        desc.StringParam(
            name='transformation',
            label='Transformation',
            description=
            '''Align [X,Y,Z] to +Y-axis, rotate around Y by R deg, scale by S; syntax: X,Y,Z;R;S. (required only for 'transformation' method)''',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='landmarksDescriberTypes',
            label='Landmarks Describer Types',
            description=
            'Image describer types used to compute the mean of the point cloud. (only for "landmarks" method).',
            value=['sift', 'akaze'],
            values=[
                'sift', 'sift_float', 'sift_upright', 'akaze', 'akaze_liop',
                'akaze_mldb', 'cctag3', 'cctag4', 'sift_ocv', 'akaze_ocv'
            ],
            exclusive=False,
            uid=[0],
            joinChar=',',
        ),
        desc.FloatParam(
            name='scale',
            label='Additional Scale',
            description='Additional scale to apply.',
            value=10.0,
            range=(1, 100.0, 1),
            uid=[0],
        ),
        desc.ChoiceParam(
            name='verboseLevel',
            label='Verbose Level',
            description=
            '''verbosity level (fatal, error, warning, info, debug, trace).''',
            value='info',
            values=['fatal', 'error', 'warning', 'info', 'debug', 'trace'],
            exclusive=True,
            uid=[],
        ),
    ]

    outputs = [
        desc.File(
            name='output',
            label='Output',
            description='''Aligned SfMData file .''',
            value=desc.Node.internalFolder + 'transformedSfM.abc',
            uid=[],
        ),
    ]
Esempio n. 18
0
class KeyframeSelection(desc.CommandLineNode):
    commandLine = 'aliceVision_utils_keyframeSelection {allParams}'

    inputs = [
        desc.File(
            name='mediaPaths',
            label='Media Paths',
            description='''Input video files or image sequence directories.''',
            value='',
            uid=[0],
        ),
        desc.IntParam(
            name='maxNbOutFrame',
            label='Max Nb Out Frame',
            description='''maximum number of output frames (0 = no limit)''',
            value=1000,
            range=(0, 10000, 1),
            uid=[],
        ),
        desc.File(
            name='sensorDbPath',
            label='Sensor Db Path',
            description='''Camera sensor width database path.''',
            value=os.environ.get('ALICEVISION_SENSOR_DB', ''),
            uid=[0],
        ),
        desc.File(
            name='voctreePath',
            label='Voctree Path',
            description='''Vocabulary tree path.''',
            value=os.environ.get('ALICEVISION_VOCTREE', ''),
            uid=[0],
        ),
        desc.StringParam(
            name='brands',
            label='Brands',
            description='''Camera brands.''',
            value='',
            uid=[0],
        ),
        desc.StringParam(
            name='models',
            label='Models',
            description='''Camera models.''',
            value='',
            uid=[0],
        ),
        desc.FloatParam(
            name='mmFocals',
            label='Mm Focals',
            description='''Focals in mm (will be use if not 0).''',
            value=0.0,
            range=(0.0, 500.0, 1.0),
            uid=[0],
        ),
        desc.FloatParam(
            name='pxFocals',
            label='Px Focals',
            description=
            '''Focals in px (will be use and convert in mm if not 0).''',
            value=0.0,
            range=(0.0, 500.0, 1.0),
            uid=[0],
        ),
        desc.ChoiceParam(
            name='sharpnessPreset',
            label='Sharpness Preset',
            description=
            '''Preset for sharpnessSelection : {ultra, high, normal, low, very_low, none}''',
            value='normal',
            values=['ultra', 'high', 'normal', 'low', 'very_low', 'none'],
            exclusive=True,
            uid=[0],
        ),
        desc.IntParam(
            name='sharpSubset',
            label='Sharp Subset',
            description=
            '''sharp part of the image (1 = all, 2 = size/2, ...)''',
            value=4,
            range=(1, 100, 1),
            uid=[0],
        ),
        desc.IntParam(
            name='minFrameStep',
            label='Min Frame Step',
            description='''minimum number of frames between two keyframes''',
            value=12,
            range=(1, 100, 1),
            uid=[0],
        ),
        desc.IntParam(
            name='maxFrameStep',
            label='Max Frame Step',
            description=
            '''maximum number of frames after which a keyframe can be taken''',
            value=36,
            range=(2, 1000, 1),
            uid=[0],
        ),
    ]

    outputs = [
        desc.File(
            name='outputFolder',
            label='Output Folder',
            description='''Output keyframes folder for extracted frames.''',
            value=desc.Node.internalFolder,
            uid=[],
        ),
    ]