コード例 #1
0
class SampleNodeV4(desc.Node):
    """
    Changes from V3:
        * 'paramA' has been added
    """
    inputs = [
        desc.File(
            name='in',
            label='Input',
            description='',
            value='',
            uid=[0],
        ),
        desc.ListAttribute(name='paramA',
                           label='ParamA',
                           elementDesc=desc.GroupAttribute(
                               groupDesc=SampleGroupV1,
                               name='gA',
                               label='gA',
                               description=''),
                           description='')
    ]
    outputs = [
        desc.File(name='output',
                  label='Output',
                  description='',
                  value=desc.Node.internalFolder,
                  uid=[])
    ]
コード例 #2
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)
コード例 #3
0
class SampleNodeV5(desc.Node):
    """
    Changes from V4:
        * 'paramA' elementDesc has changed from SampleGroupV1 to SampleGroupV2
    """
    inputs = [
        desc.File(name='in', label='Input', description='', value='', uid=[0]),
        desc.ListAttribute(name='paramA', label='ParamA',
                           elementDesc=desc.GroupAttribute(
                               groupDesc=SampleGroupV2, name='gA', label='gA', description=''),
                           description='')
    ]
    outputs = [
        desc.File(name='output', label='Output', description='', value=desc.Node.internalFolder, uid=[])
    ]
コード例 #4
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=[],
        ),
    ]
コード例 #5
0
SampleGroupV1 = [
    desc.IntParam(name="a", label="a", description="", value=0, uid=[0], range=None),
    desc.ListAttribute(
        name="b",
        elementDesc=desc.FloatParam(name="p", label="", description="", value=0.0, uid=[0], range=None),
        label="b",
        description="",
    )
]

SampleGroupV2 = [
    desc.IntParam(name="a", label="a", description="", value=0, uid=[0], range=None),
    desc.ListAttribute(
        name="b",
        elementDesc=desc.GroupAttribute(name="p", label="", description="", groupDesc=SampleGroupV1),
        label="b",
        description="",
    )
]


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=[])
    ]
コード例 #6
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)
コード例 #7
0
 desc.StringParam(
     name="serialNumber",
     label="Serial Number",
     description="Device Serial Number (Camera UID and Lens UID combined)",
     value="",
     uid=[]),
 desc.GroupAttribute(
     name="principalPoint",
     label="Principal Point",
     description=
     "Position of the Optical Center in the Image (i.e. the sensor surface).",
     groupDesc=[
         desc.FloatParam(name="x",
                         label="x",
                         description="",
                         value=0,
                         uid=[],
                         range=(0, 10000, 1)),
         desc.FloatParam(name="y",
                         label="y",
                         description="",
                         value=0,
                         uid=[],
                         range=(0, 10000, 1)),
     ]),
 desc.ChoiceParam(
     name="initializationMode",
     label="Initialization Mode",
     description="Defines how this Intrinsic was initialized:\n"
     " * calibrated: calibrated externally.\n"
     " * estimated: estimated from metadata and/or sensor width. \n"
コード例 #8
0
ファイル: Meshing.py プロジェクト: ys-forks/meshroom
class Meshing(desc.CommandLineNode):
    commandLine = 'aliceVision_meshing {allParams}'

    cpu = desc.Level.INTENSIVE
    ram = desc.Level.INTENSIVE

    category = 'Dense Reconstruction'
    documentation = '''
This node creates a dense geometric surface representation of the scene.

First, it fuses all the depth maps into a global dense point cloud with an adaptive resolution.
It then performs a 3D Delaunay tetrahedralization and a voting procedure is done to compute weights on cells and weights on facets connecting the cells.
A Graph Cut Max-Flow is applied to optimally cut the volume. This cut represents the extracted mesh surface.

## Online
[https://alicevision.org/#photogrammetry/meshing](https://alicevision.org/#photogrammetry/meshing)
'''

    inputs = [
        desc.File(
            name='input',
            label='SfmData',
            description='SfMData file.',
            value='',
            uid=[0],
        ),
        desc.File(
            name="depthMapsFolder",
            label='Depth Maps Folder',
            description='Input depth maps folder.',
            value='',
            uid=[0],
        ),
        desc.BoolParam(
            name='useBoundingBox',
            label='Custom Bounding Box',
            description=
            'Edit the meshing bounding box. If enabled, it takes priority over the Estimate From SfM option. Parameters can be adjusted in advanced settings.',
            value=False,
            uid=[0],
            group=''),
        desc.GroupAttribute(
            name="boundingBox",
            label="Bounding Box Settings",
            description="Translation, rotation and scale of the bounding box.",
            groupDesc=[
                desc.GroupAttribute(
                    name="bboxTranslation",
                    label="Translation",
                    description="Position 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="bboxRotation",
                    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.GroupAttribute(
                    name="bboxScale",
                    label="Scale",
                    description="Scale of the bounding box.",
                    groupDesc=[
                        desc.FloatParam(name="x",
                                        label="x",
                                        description="X Scale",
                                        value=1.0,
                                        uid=[0],
                                        range=(0.0, 20.0, 0.01)),
                        desc.FloatParam(name="y",
                                        label="y",
                                        description="Y Scale",
                                        value=1.0,
                                        uid=[0],
                                        range=(0.0, 20.0, 0.01)),
                        desc.FloatParam(name="z",
                                        label="z",
                                        description="Z Scale",
                                        value=1.0,
                                        uid=[0],
                                        range=(0.0, 20.0, 0.01))
                    ],
                    joinChar=",")
            ],
            joinChar=",",
            enabled=lambda node: node.useBoundingBox.value,
        ),
        desc.BoolParam(
            name='estimateSpaceFromSfM',
            label='Estimate Space From SfM',
            description='Estimate the 3d space from the SfM',
            value=True,
            uid=[0],
            advanced=True,
        ),
        desc.IntParam(
            name='estimateSpaceMinObservations',
            label='Min Observations For SfM Space Estimation',
            description=
            'Minimum number of observations for SfM space estimation.',
            value=3,
            range=(0, 100, 1),
            uid=[0],
            advanced=True,
            enabled=lambda node: node.estimateSpaceFromSfM.value,
        ),
        desc.FloatParam(
            name='estimateSpaceMinObservationAngle',
            label='Min Observations Angle For SfM Space Estimation',
            description=
            'Minimum angle between two observations for SfM space estimation.',
            value=10,
            range=(0, 120, 1),
            uid=[0],
            enabled=lambda node: node.estimateSpaceFromSfM.value,
        ),
        desc.IntParam(
            name='maxInputPoints',
            label='Max Input Points',
            description='Max input points loaded from depth map images.',
            value=50000000,
            range=(500000, 500000000, 1000),
            uid=[0],
        ),
        desc.IntParam(
            name='maxPoints',
            label='Max Points',
            description='Max points at the end of the depth maps fusion.',
            value=5000000,
            range=(100000, 10000000, 1000),
            uid=[0],
        ),
        desc.IntParam(
            name='maxPointsPerVoxel',
            label='Max Points Per Voxel',
            description='Max points per voxel',
            value=1000000,
            range=(500000, 30000000, 1000),
            uid=[0],
            advanced=True,
        ),
        desc.IntParam(
            name='minStep',
            label='Min Step',
            description=
            'The step used to load depth values from depth maps is computed from maxInputPts. '
            'Here we define the minimal value for this step, so on small datasets we will not spend '
            'too much time at the beginning loading all depth values.',
            value=2,
            range=(1, 20, 1),
            uid=[0],
            advanced=True,
        ),
        desc.ChoiceParam(
            name='partitioning',
            label='Partitioning',
            description='',
            value='singleBlock',
            values=('singleBlock', 'auto'),
            exclusive=True,
            uid=[0],
            advanced=True,
        ),
        desc.ChoiceParam(
            name='repartition',
            label='Repartition',
            description='',
            value='multiResolution',
            values=('multiResolution', 'regularGrid'),
            exclusive=True,
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='angleFactor',
            label='angleFactor',
            description='angleFactor',
            value=15.0,
            range=(0.0, 200.0, 1.0),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='simFactor',
            label='simFactor',
            description='simFactor',
            value=15.0,
            range=(0.0, 200.0, 1.0),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='pixSizeMarginInitCoef',
            label='pixSizeMarginInitCoef',
            description='pixSizeMarginInitCoef',
            value=2.0,
            range=(0.0, 10.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='pixSizeMarginFinalCoef',
            label='pixSizeMarginFinalCoef',
            description='pixSizeMarginFinalCoef',
            value=4.0,
            range=(0.0, 10.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='voteMarginFactor',
            label='voteMarginFactor',
            description='voteMarginFactor',
            value=4.0,
            range=(0.1, 10.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='contributeMarginFactor',
            label='contributeMarginFactor',
            description='contributeMarginFactor',
            value=2.0,
            range=(0.0, 10.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='simGaussianSizeInit',
            label='simGaussianSizeInit',
            description='simGaussianSizeInit',
            value=10.0,
            range=(0.0, 50.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='simGaussianSize',
            label='simGaussianSize',
            description='simGaussianSize',
            value=10.0,
            range=(0.0, 50.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='minAngleThreshold',
            label='minAngleThreshold',
            description='minAngleThreshold',
            value=1.0,
            range=(0.0, 10.0, 0.01),
            uid=[0],
            advanced=True,
        ),
        desc.BoolParam(
            name='refineFuse',
            label='Refine Fuse',
            description=
            'Refine depth map fusion with the new pixels size defined by angle and similarity scores.',
            value=True,
            uid=[0],
            advanced=True,
        ),
        desc.IntParam(
            name='helperPointsGridSize',
            label='Helper Points Grid Size',
            description='Grid Size for the helper points.',
            value=10,
            range=(0, 50, 1),
            uid=[0],
            advanced=True,
        ),
        desc.BoolParam(
            name='densify',
            label='Densify',
            description='Densify scene with helper points around vertices.',
            value=False,
            uid=[],
            advanced=True,
            group='',
        ),
        desc.IntParam(
            name='densifyNbFront',
            label='Densify: Front',
            description='Densify vertices: front.',
            value=1,
            range=(0, 5, 1),
            uid=[0],
            advanced=True,
            enabled=lambda node: node.densify.value,
        ),
        desc.IntParam(
            name='densifyNbBack',
            label='Densify: Back',
            description='Densify vertices: back.',
            value=1,
            range=(0, 5, 1),
            uid=[0],
            advanced=True,
            enabled=lambda node: node.densify.value,
        ),
        desc.FloatParam(
            name='densifyScale',
            label='Densify Scale',
            description='Scale between points used to densify the scene.',
            value=20.0,
            range=(0.0, 10.0, 0.1),
            uid=[0],
            advanced=True,
            enabled=lambda node: node.densify.value,
        ),
        desc.FloatParam(
            name='nPixelSizeBehind',
            label='Nb Pixel Size Behind',
            description=
            'Number of pixel size units to vote behind the vertex as FULL status.',
            value=4.0,
            range=(0.0, 10.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='fullWeight',
            label='Full Weight',
            description='Weighting for full status.',
            value=1.0,
            range=(0.0, 10.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.BoolParam(
            name='voteFilteringForWeaklySupportedSurfaces',
            label='Weakly Supported Surface Support',
            description=
            'Improve support of weakly supported surfaces with a tetrahedra fullness score filtering.',
            value=True,
            uid=[0],
        ),
        desc.BoolParam(
            name='addLandmarksToTheDensePointCloud',
            label='Add Landmarks To The Dense Point Cloud',
            description='Add SfM Landmarks to the dense point cloud.',
            value=False,
            uid=[0],
            advanced=True,
        ),
        desc.IntParam(
            name='invertTetrahedronBasedOnNeighborsNbIterations',
            label='Tretrahedron Neighbors Coherency Nb Iterations',
            description=
            'Invert cells status around surface to improve smoothness. Zero to disable.',
            value=10,
            range=(0, 30, 1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='minSolidAngleRatio',
            label='minSolidAngleRatio',
            description=
            'Change cells status on surface around vertices to improve smoothness using solid angle ratio between full/empty parts. Zero to disable.',
            value=0.2,
            range=(0.0, 0.5, 0.01),
            uid=[0],
            advanced=True,
        ),
        desc.IntParam(
            name='nbSolidAngleFilteringIterations',
            label='Nb Solid Angle Filtering Iterations',
            description=
            'Filter cells status on surface around vertices to improve smoothness using solid angle ratio between full/empty parts. Zero to disable.',
            value=2,
            range=(0, 30, 1),
            uid=[0],
            advanced=True,
        ),
        desc.BoolParam(
            name='colorizeOutput',
            label='Colorize Output',
            description=
            'Whether to colorize output dense point cloud and mesh.',
            value=False,
            uid=[0],
        ),
        desc.BoolParam(
            name='addMaskHelperPoints',
            label='Add Mask Helper Points',
            description=
            'Add Helper points on the outline of the depth maps masks.',
            value=False,
            uid=[],
            advanced=True,
            group='',
        ),
        desc.FloatParam(
            name='maskHelperPointsWeight',
            label='Mask Helper Points Weight',
            description=
            'Weight value for mask helper points. Zero means no helper point.',
            value=1.0,
            range=(0.0, 20.0, 1.0),
            uid=[0],
            advanced=True,
            enabled=lambda node: node.addMaskHelperPoints.value,
        ),
        desc.IntParam(
            name='maskBorderSize',
            label='Mask Border Size',
            description='How many pixels on mask borders?',
            value=4,
            range=(0, 20, 1),
            uid=[0],
            advanced=True,
            enabled=lambda node: node.addMaskHelperPoints.value,
        ),
        desc.IntParam(
            name='maxNbConnectedHelperPoints',
            label='Helper Points: Max Segment Size',
            description=
            'Maximum size of a segment of connected helper points before we remove it. Small segments of helper points can be on the real surface and should not be removed to avoid the creation of holes. 0 means that we remove all helper points. -1 means that we do not filter helper points at all.',
            value=50,
            range=(-1, 100, 1),
            uid=[0],
            advanced=True,
        ),
        desc.BoolParam(
            name='saveRawDensePointCloud',
            label='Save Raw Dense Point Cloud',
            description='Save dense point cloud before cut and filtering.',
            value=False,
            uid=[],
            advanced=True,
        ),
        desc.BoolParam(
            name='exportDebugTetrahedralization',
            label='Export DEBUG Tetrahedralization',
            description=
            'Export debug cells score as tetrahedral mesh.\nWARNING: Could create HUGE meshes, only use on very small datasets.',
            value=False,
            uid=[],
            advanced=True,
        ),
        desc.IntParam(
            name='seed',
            label='Seed',
            description=
            'Seed used for random operations. Zero means use of random device instead of a fixed seed.',
            value=0,
            range=(0, 10000, 1),
            uid=[0],
            advanced=True,
        ),
        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="outputMesh",
            label="Mesh",
            description="Output mesh (OBJ file format).",
            value="{cache}/{nodeType}/{uid0}/mesh.obj",
            uid=[],
        ),
        desc.File(
            name="output",
            label="Dense SfMData",
            description=
            "Output dense point cloud with visibilities (SfMData file format).",
            value="{cache}/{nodeType}/{uid0}/densePointCloud.abc",
            uid=[],
        ),
    ]
コード例 #9
0
ファイル: SfMTransform.py プロジェクト: cs210/Worldsight
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=[],
        ),
    ]
コード例 #10
0
               range=(0, 10000, 1)),
 desc.StringParam(
     name="serialNumber",
     label="Serial Number",
     description="Device Serial Number (camera and lens combined)",
     value="",
     uid=[]),
 desc.GroupAttribute(name="principalPoint",
                     label="Principal Point",
                     description="",
                     groupDesc=[
                         desc.FloatParam(name="x",
                                         label="x",
                                         description="",
                                         value=0,
                                         uid=[],
                                         range=(0, 10000, 1)),
                         desc.FloatParam(name="y",
                                         label="y",
                                         description="",
                                         value=0,
                                         uid=[],
                                         range=(0, 10000, 1)),
                     ]),
 desc.ChoiceParam(
     name="initializationMode",
     label="Initialization Mode",
     description="Defines how this Intrinsic was initialized:\n"
     " * calibrated: calibrated externally.\n"
     " * estimated: estimated from metadata and/or sensor width. \n"
     " * unknown: unknown camera parameters (can still have default value guess)\n"
コード例 #11
0
ファイル: Texturing.py プロジェクト: ys-forks/meshroom
class Texturing(desc.CommandLineNode):
    commandLine = 'aliceVision_texturing {allParams}'
    cpu = desc.Level.INTENSIVE
    ram = desc.Level.INTENSIVE

    category = 'Dense Reconstruction'
    documentation = '''
This node computes the texturing on the mesh.

If the mesh has no associated UV, it automatically computes UV maps.

For each triangle, it uses the visibility information associated to each vertex to retrieve the texture candidates.
It select the best cameras based on the resolution covering the triangle. Finally it averages the pixel values using multiple bands in the frequency domain.
Many cameras are contributing to the low frequencies and only the best ones contributes to the high frequencies.

## Online
[https://alicevision.org/#photogrammetry/texturing](https://alicevision.org/#photogrammetry/texturing)
'''

    inputs = [
        desc.File(
            name='input',
            label='Dense SfMData',
            description='SfMData file.',
            value='',
            uid=[0],
        ),
        desc.File(
            name='imagesFolder',
            label='Images Folder',
            description=
            'Use images from a specific folder instead of those specify in the SfMData file.\nFilename should be the image uid.',
            value='',
            uid=[0],
        ),
        desc.File(
            name='inputMesh',
            label='Mesh',
            description=
            'Optional input mesh to texture. By default, it will texture the result of the reconstruction.',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='textureSide',
            label='Texture Side',
            description='''Output texture size''',
            value=8192,
            values=(1024, 2048, 4096, 8192, 16384),
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='downscale',
            label='Texture Downscale',
            description='''Texture downscale factor''',
            value=2,
            values=(1, 2, 4, 8),
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='outputTextureFileType',
            label='Texture File Type',
            description='Texture File Type',
            value='png',
            values=('jpg', 'png', 'tiff', 'exr'),
            exclusive=True,
            uid=[0],
        ),
        desc.ChoiceParam(
            name='unwrapMethod',
            label='Unwrap Method',
            description=
            'Method to unwrap input mesh if it does not have UV coordinates.\n'
            ' * Basic (> 600k faces) fast and simple. Can generate multiple atlases.\n'
            ' * LSCM (<= 600k faces): optimize space. Generates one atlas.\n'
            ' * ABF (<= 300k faces): optimize space and stretch. Generates one atlas.',
            value="Basic",
            values=("Basic", "LSCM", "ABF"),
            exclusive=True,
            uid=[0],
        ),
        desc.BoolParam(
            name='useUDIM',
            label='Use UDIM',
            description='Use UDIM UV mapping.',
            value=True,
            uid=[0],
        ),
        desc.BoolParam(
            name='fillHoles',
            label='Fill Holes',
            description='Fill Texture holes with plausible values',
            value=False,
            uid=[0],
        ),
        desc.IntParam(
            name='padding',
            label='Padding',
            description='''Texture edge padding size in pixel''',
            value=5,
            range=(0, 20, 1),
            uid=[0],
            advanced=True,
        ),
        desc.IntParam(
            name='multiBandDownscale',
            label='Multi Band Downscale',
            description='''Width of frequency bands for multiband blending''',
            value=4,
            range=(0, 8, 2),
            uid=[0],
            advanced=True,
        ),
        desc.GroupAttribute(
            name="multiBandNbContrib",
            label="MultiBand contributions",
            groupDesc=[
                desc.IntParam(name="high",
                              label="High Freq",
                              description="High Frequency Band",
                              value=1,
                              uid=[0],
                              range=None),
                desc.IntParam(name="midHigh",
                              label="Mid-High Freq",
                              description="Mid-High Frequency Band",
                              value=5,
                              uid=[0],
                              range=None),
                desc.IntParam(name="midLow",
                              label="Mid-Low Freq",
                              description="Mid-Low Frequency Band",
                              value=10,
                              uid=[0],
                              range=None),
                desc.IntParam(name="low",
                              label="Low Freq",
                              description="Low Frequency Band",
                              value=0,
                              uid=[0],
                              range=None),
            ],
            description=
            '''Number of contributions per frequency band for multiband blending (each frequency band also contributes to lower bands)''',
            advanced=True,
        ),
        desc.BoolParam(
            name='useScore',
            label='Use Score',
            description=
            'Use triangles scores (ie. reprojection area) for multiband blending.',
            value=True,
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='bestScoreThreshold',
            label='Best Score Threshold',
            description=
            '''(0.0 to disable filtering based on threshold to relative best score)''',
            value=0.1,
            range=(0.0, 1.0, 0.01),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='angleHardThreshold',
            label='Angle Hard Threshold',
            description='''(0.0 to disable angle hard threshold filtering)''',
            value=90.0,
            range=(0.0, 180.0, 0.01),
            uid=[0],
            advanced=True,
        ),
        desc.ChoiceParam(
            name='processColorspace',
            label='Process Colorspace',
            description=
            "Colorspace for the texturing internal computation (does not impact the output file colorspace).",
            value='sRGB',
            values=('sRGB', 'LAB', 'XYZ'),
            exclusive=True,
            uid=[0],
            advanced=True,
        ),
        desc.BoolParam(
            name='correctEV',
            label='Correct Exposure',
            description='Uniformize images exposure values.',
            value=False,
            uid=[0],
        ),
        desc.BoolParam(
            name='forceVisibleByAllVertices',
            label='Force Visible By All Vertices',
            description=
            '''Triangle visibility is based on the union of vertices visiblity.''',
            value=False,
            uid=[0],
            advanced=True,
        ),
        desc.BoolParam(
            name='flipNormals',
            label='Flip Normals',
            description=
            '''Option to flip face normals. It can be needed as it depends on the vertices order in triangles and the convention change from one software to another.''',
            value=False,
            uid=[0],
            advanced=True,
        ),
        desc.ChoiceParam(
            name='visibilityRemappingMethod',
            label='Visibility Remapping Method',
            description=
            '''Method to remap visibilities from the reconstruction to the input mesh (Pull, Push, PullPush).''',
            value='PullPush',
            values=['Pull', 'Push', 'PullPush'],
            exclusive=True,
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='subdivisionTargetRatio',
            label='Subdivision Target Ratio',
            description=
            '''Percentage of the density of the reconstruction as the target for the subdivision (0: disable subdivision, 0.5: half density of the reconstruction, 1: full density of the reconstruction).''',
            value=0.8,
            range=(0.0, 1.0, 0.001),
            uid=[0],
            advanced=True,
        ),
        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='Folder',
            description=
            'Folder for output mesh: OBJ, material and texture files.',
            value=desc.Node.internalFolder,
            uid=[],
        ),
        desc.File(
            name='outputMesh',
            label='Mesh',
            description='Output Mesh file.',
            value=desc.Node.internalFolder + 'texturedMesh.obj',
            uid=[],
            group='',
        ),
        desc.File(
            name='outputMaterial',
            label='Material',
            description='Output Material file.',
            value=desc.Node.internalFolder + 'texturedMesh.mtl',
            uid=[],
            group='',
        ),
        desc.File(
            name='outputTextures',
            label='Textures',
            description='Output Texture files.',
            value=desc.Node.internalFolder +
            'texture_*.{outputTextureFileTypeValue}',
            uid=[],
            group='',
        ),
    ]
コード例 #12
0
ファイル: Meshing.py プロジェクト: zyl1336110861/meshroom
class Meshing(desc.CommandLineNode):
    commandLine = 'aliceVision_meshing {allParams}'

    cpu = desc.Level.INTENSIVE
    ram = desc.Level.INTENSIVE

    documentation = '''
This node creates a dense geometric surface representation of the scene.

First, it fuses all the depth maps into a global dense point cloud with an adaptive resolution.
It then performs a 3D Delaunay tetrahedralization and a voting procedure is done to compute weights on cells and weights on facets connecting the cells.
A Graph Cut Max-Flow is applied to optimally cut the volume. This cut represents the extracted mesh surface.

## Online
[https://alicevision.org/#photogrammetry/meshing](https://alicevision.org/#photogrammetry/meshing)
'''

    inputs = [
        desc.File(
            name='input',
            label='Input',
            description='SfMData file.',
            value='',
            uid=[0],
        ),
        desc.File(
            name="depthMapsFolder",
            label='Depth Maps Folder',
            description='Input depth maps folder.',
            value='',
            uid=[0],
        ),
        desc.BoolParam(
            name='useBoundingBox',
            label='Custom Bounding Box',
            description='Edit the meshing bounding box. If enabled, it takes priority over the Estimate From SfM option. Parameters can be adjusted in advanced settings.',
            value=False,
            uid=[0],
            group=''
        ),
        desc.GroupAttribute(
            name="boundingBox",
            label="Bounding Box Settings",
            description="Translation, rotation and scale of the bounding box.",
            groupDesc=[
                desc.GroupAttribute(
                    name="bboxTranslation",
                    label="Translation",
                    description="Position 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="bboxRotation",
                    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.GroupAttribute(
                    name="bboxScale",
                    label="Scale",
                    description="Scale of the bounding box.",
                    groupDesc=[
                        desc.FloatParam(
                            name="x", label="x", description="X Scale",
                            value=1.0,
                            uid=[0],
                            range=(0.0, 20.0, 0.01)
                        ),
                        desc.FloatParam(
                            name="y", label="y", description="Y Scale",
                            value=1.0,
                            uid=[0],
                            range=(0.0, 20.0, 0.01)
                        ),
                        desc.FloatParam(
                            name="z", label="z", description="Z Scale",
                            value=1.0,
                            uid=[0],
                            range=(0.0, 20.0, 0.01)
                        )
                    ],
                    joinChar=","
                )
            ],
            joinChar=",",
            enabled=lambda node: node.useBoundingBox.value,
        ),
        desc.BoolParam(
            name='estimateSpaceFromSfM',
            label='Estimate Space From SfM',
            description='Estimate the 3d space from the SfM',
            value=True,
            uid=[0],
            advanced=True,
        ),
        desc.IntParam(
            name='estimateSpaceMinObservations',
            label='Min Observations For SfM Space Estimation',
            description='Minimum number of observations for SfM space estimation.',
            value=3,
            range=(0, 100, 1),
            uid=[0],
            advanced=True,
            enabled=lambda node: node.estimateSpaceFromSfM.value,
        ),
        desc.FloatParam(
            name='estimateSpaceMinObservationAngle',
            label='Min Observations Angle For SfM Space Estimation',
            description='Minimum angle between two observations for SfM space estimation.',
            value=10,
            range=(0, 120, 1),
            uid=[0],
            enabled=lambda node: node.estimateSpaceFromSfM.value,
        ),
        desc.IntParam(
            name='maxInputPoints',
            label='Max Input Points',
            description='Max input points loaded from depth map images.',
            value=50000000,
            range=(500000, 500000000, 1000),
            uid=[0],
        ),
        desc.IntParam(
            name='maxPoints',
            label='Max Points',
            description='Max points at the end of the depth maps fusion.',
            value=5000000,
            range=(100000, 10000000, 1000),
            uid=[0],
        ),
        desc.IntParam(
            name='maxPointsPerVoxel',
            label='Max Points Per Voxel',
            description='Max points per voxel',
            value=1000000,
            range=(500000, 30000000, 1000),
            uid=[0],
            advanced=True,
        ),
        desc.IntParam(
            name='minStep',
            label='Min Step',
            description='The step used to load depth values from depth maps is computed from maxInputPts. '
            'Here we define the minimal value for this step, so on small datasets we will not spend '
            'too much time at the beginning loading all depth values.',
            value=2,
            range=(1, 20, 1),
            uid=[0],
            advanced=True,
        ),
        desc.ChoiceParam(
            name='partitioning',
            label='Partitioning',
            description='',
            value='singleBlock',
            values=('singleBlock', 'auto'),
            exclusive=True,
            uid=[0],
            advanced=True,
        ),
        desc.ChoiceParam(
            name='repartition',
            label='Repartition',
            description='',
            value='multiResolution',
            values=('multiResolution', 'regularGrid'),
            exclusive=True,
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='angleFactor',
            label='angleFactor',
            description='angleFactor',
            value=15.0,
            range=(0.0, 200.0, 1.0),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='simFactor',
            label='simFactor',
            description='simFactor',
            value=15.0,
            range=(0.0, 200.0, 1.0),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='pixSizeMarginInitCoef',
            label='pixSizeMarginInitCoef',
            description='pixSizeMarginInitCoef',
            value=2.0,
            range=(0.0, 10.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='pixSizeMarginFinalCoef',
            label='pixSizeMarginFinalCoef',
            description='pixSizeMarginFinalCoef',
            value=4.0,
            range=(0.0, 10.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='voteMarginFactor',
            label='voteMarginFactor',
            description='voteMarginFactor',
            value=4.0,
            range=(0.1, 10.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='contributeMarginFactor',
            label='contributeMarginFactor',
            description='contributeMarginFactor',
            value=2.0,
            range=(0.0, 10.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='simGaussianSizeInit',
            label='simGaussianSizeInit',
            description='simGaussianSizeInit',
            value=10.0,
            range=(0.0, 50.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='simGaussianSize',
            label='simGaussianSize',
            description='simGaussianSize',
            value=10.0,
            range=(0.0, 50.0, 0.1),
            uid=[0],
            advanced=True,
        ),
        desc.FloatParam(
            name='minAngleThreshold',
            label='minAngleThreshold',
            description='minAngleThreshold',
            value=1.0,
            range=(0.0, 10.0, 0.01),
            uid=[0],
            advanced=True,
        ),
        desc.BoolParam(
            name='refineFuse',
            label='Refine Fuse',
            description='Refine depth map fusion with the new pixels size defined by angle and similarity scores.',
            value=True,
            uid=[0],
            advanced=True,
        ),
        desc.BoolParam(
            name='addLandmarksToTheDensePointCloud',
            label='Add Landmarks To The Dense Point Cloud',
            description='Add SfM Landmarks to the dense point cloud.',
            value=False,
            uid=[0],
            advanced=True,
        ),
        desc.BoolParam(
            name='colorizeOutput',
            label='Colorize Output',
            description='Whether to colorize output dense point cloud and mesh.',
            value=False,
            uid=[0],
        ),
        desc.BoolParam(
            name='saveRawDensePointCloud',
            label='Save Raw Dense Point Cloud',
            description='Save dense point cloud before cut and filtering.',
            value=False,
            uid=[],
            advanced=True,
        ),
        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="outputMesh",
            label="Output Mesh",
            description="Output mesh (OBJ file format).",
            value="{cache}/{nodeType}/{uid0}/mesh.obj",
            uid=[],
        ),
        desc.File(
            name="output",
            label="Output Dense Point Cloud",
            description="Output dense point cloud with visibilities (SfMData file format).",
            value="{cache}/{nodeType}/{uid0}/densePointCloud.abc",
            uid=[],
        ),
    ]
コード例 #13
0
class CameraCalibration(desc.CommandLineNode):
    commandLine = 'aliceVision_cameraCalibration {allParams}'

    category = 'Utils'

    inputs = [
        desc.File(
            name='input',
            label='Input',
            description='''Input images in one of the following form:
 - folder containing images
 - image sequence like "/path/to/[email protected]"
 - video file''',
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='pattern',
            label='Pattern',
            description=
            '''Type of pattern (CHESSBOARD, CIRCLES, ASYMMETRIC_CIRCLES, ASYMMETRIC_CCTAG).''',
            value='CHESSBOARD',
            values=[
                'CHESSBOARD', 'CIRCLES', 'ASYMMETRIC_CIRCLES',
                'ASYMMETRIC_CCTAG'
            ],
            exclusive=True,
            uid=[0],
        ),
        desc.GroupAttribute(
            name="size",
            label="Size",
            description=
            "Number of inner corners per one of board dimension like W H.",
            groupDesc=[
                desc.IntParam(
                    name='width',
                    label='Width',
                    description='',
                    value=7,
                    range=(0, 10000, 1),
                    uid=[0],
                ),
                desc.IntParam(
                    name='height',
                    label='Height',
                    description='',
                    value=5,
                    range=(0, 10000, 1),
                    uid=[0],
                ),
            ]),
        desc.FloatParam(
            name='squareSize',
            label='Square Size',
            description='''Size of the grid's square cells (mm).''',
            value=1.0,
            range=(0.0, 100.0, 1.0),
            uid=[0],
        ),
        desc.IntParam(
            name='nbDistortionCoef',
            label='Nb Distortion Coef',
            description='''Number of distortion coefficient.''',
            value=3,
            range=(0, 5, 1),
            uid=[0],
        ),
        desc.IntParam(
            name='maxFrames',
            label='Max Frames',
            description=
            '''Maximal number of frames to extract from the video file.''',
            value=0,
            range=(0, 5, 1),
            uid=[0],
        ),
        desc.IntParam(
            name='maxCalibFrames',
            label='Max Calib Frames',
            description=
            '''Maximal number of frames to use to calibrate from the selected frames.''',
            value=100,
            range=(0, 1000, 1),
            uid=[0],
        ),
        desc.IntParam(
            name='calibGridSize',
            label='Calib Grid Size',
            description='''Define the number of cells per edge.''',
            value=10,
            range=(0, 50, 1),
            uid=[0],
        ),
        desc.IntParam(
            name='minInputFrames',
            label='Min Input Frames',
            description=
            '''Minimal number of frames to limit the refinement loop.''',
            value=10,
            range=(0, 100, 1),
            uid=[0],
        ),
        desc.FloatParam(
            name='maxTotalAvgErr',
            label='Max Total Avg Err',
            description='''Max Total Average Error.''',
            value=0.10000000000000001,
            range=(0.0, 1.0, 0.01),
            uid=[0],
        ),
        desc.File(
            name='debugRejectedImgFolder',
            label='Debug Rejected Img Folder',
            description=
            '''Folder to export delete images during the refinement loop.''',
            value='',
            uid=[0],
        ),
        desc.File(
            name='debugSelectedImgFolder',
            label='Debug Selected Img Folder',
            description='''Folder to export debug images.''',
            value='',
            uid=[0],
        ),
    ]

    outputs = [
        desc.File(
            name='output',
            label='Output',
            description=
            '''Output filename for intrinsic [and extrinsic] parameters.''',
            value=desc.Node.internalFolder + '/cameraCalibration.cal',
            uid=[],
        ),
    ]
コード例 #14
0
ファイル: CameraInit.py プロジェクト: zkov96/meshroom
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')

    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=[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='''Output SfMData.''',
            value=desc.Node.internalFolder + 'cameraInit.sfm',
            uid=[],
        ),
    ]

    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)
        assert node.graph is None

        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])
            cmd += " --allowIncompleteOutput 1" # don't throw an error if the image intrinsic is undefined
            # logging.debug(' - commandLine:', cmd)
            subprocess = psutil.Popen(cmd, stdout=None, stderr=None, shell=True)
            stdout, stderr = subprocess.communicate()
            subprocess.wait()
            if subprocess.returncode != 0:
                raise RuntimeError('CameraInit failed with error code {}. Command was: "{}"'.format(
                    subprocess.returncode, cmd)
                )

            # Reload result of aliceVision_cameraInit
            cameraInitSfM = node.output.value
            import io  # use io.open for Python2/3 compatibility (allow to specify encoding + errors handling)
            # skip decoding errors to avoid potential exceptions due to non utf-8 characters in images metadata
            with io.open(cameraInitSfM, 'r', encoding='utf-8', errors='ignore') as f:
                data = json.load(f)

            intrinsicsKeys = [i.name for i in Intrinsic]
            intrinsics = [{k: v for k, v in item.items() if k in intrinsicsKeys} for item in data.get("intrinsics", [])]
            for intrinsic in intrinsics:
                pp = intrinsic['principalPoint']
                intrinsic['principalPoint'] = {}
                intrinsic['principalPoint']['x'] = pp[0]
                intrinsic['principalPoint']['y'] = pp[1]
                # convert empty string distortionParams (i.e: Pinhole model) to empty list
                if intrinsic['distortionParams'] == '':
                    intrinsic['distortionParams'] = list()
            # print('intrinsics:', intrinsics)
            viewsKeys = [v.name for v in Viewpoint]
            views = [{k: v for k, v in item.items() if k in viewsKeys} for item in data.get("views", [])]
            for view in views:
                view['metadata'] = json.dumps(view['metadata'])  # convert metadata to string
            # print('views:', views)
            return views, intrinsics

        except Exception:
            raise
        finally:
            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)
コード例 #15
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=[],
        ),
    ]
コード例 #16
0
ファイル: PanoramaInit.py プロジェクト: ys-forks/meshroom
class PanoramaInit(desc.CommandLineNode):
    commandLine = 'aliceVision_panoramaInit {allParams}'
    size = desc.DynamicNodeSize('input')

    category = 'Panorama HDR'
    documentation = '''
This node allows to setup the Panorama:

1/ Enables the initialization the cameras from known position in an XML file (provided by
["Roundshot VR Drive"](https://www.roundshot.com/xml_1/internet/fr/application/d394/d395/f396.cfm) ).

2/ Enables to setup Full Fisheye Optics (to use an Equirectangular camera model).

3/ To automatically detects the Fisheye Circle (radius + center) in input images or manually adjust it.

'''

    inputs = [
        desc.File(
            name='input',
            label='Input',
            description="SfM Data File",
            value='',
            uid=[0],
        ),
        desc.ChoiceParam(
            name='initializeCameras',
            label='Initialize Cameras',
            description='Initialize cameras.',
            value='No',
            values=['No', 'File', 'Horizontal', 'Horizontal+Zenith', 'Zenith+Horizontal', 'Spherical'],
            exclusive=True,
            uid=[0],
        ),
        desc.File(
            name='config',
            label='Xml Config',
            description="XML Data File",
            value='',
            uid=[0],
            enabled=lambda node: node.initializeCameras.value == 'File',
        ),
        desc.BoolParam(
            name='yawCW',
            label='Yaw CW',
            description="Yaw ClockWise or CounterClockWise",
            value=1,
            uid=[0],
            enabled=lambda node: ('Horizontal' in node.initializeCameras.value) or (node.initializeCameras.value == "Spherical"),
        ),
        desc.ListAttribute(
            elementDesc=desc.IntParam(
                name='nbViews',
                label='',
                description='',
                value=-1,
                range=[-1, 20],
                uid=[0],
            ),
            name='nbViewsPerLine',
            label='Spherical: Nb Views Per Line',
            description='Number of views per line in Spherical acquisition. Assumes angles from [-90,+90deg] for pitch and [-180,+180deg] for yaw. Use -1 to estimate the number of images automatically.',
            joinChar=',',
            enabled=lambda node: node.initializeCameras.value == 'Spherical',
        ),
        desc.ListAttribute(
            elementDesc=desc.File(
                name='dependency',
                label='',
                description="",
                value='',
                uid=[],
            ),
            name='dependency',
            label='Dependency',
            description="Folder(s) in which computed features are stored. (WORKAROUND for valid Tractor graph submission)",
            group='forDependencyOnly', # not a command line argument
        ),
        desc.BoolParam(
            name='useFisheye',
            label='Full Fisheye',
            description='To declare a full fisheye panorama setup',
            value=False,
            uid=[0],
        ),
        desc.BoolParam(
            name='estimateFisheyeCircle',
            label='Estimate Fisheye Circle',
            description='Automatically estimate the Fisheye Circle center and radius instead of using user values.',
            value=True,
            uid=[0],
            enabled=lambda node: node.useFisheye.value,
        ),
        desc.GroupAttribute(
            name="fisheyeCenterOffset",
            label="Fisheye Center",
            description="Center of the Fisheye circle (XY offset to the center in pixels).",
            groupDesc=[
                desc.FloatParam(
                    name="fisheyeCenterOffset_x", label="x", description="X Offset in pixels",
                    value=0.0,
                    uid=[0],
                    range=(-1000.0, 10000.0, 1.0)),
                desc.FloatParam(
                    name="fisheyeCenterOffset_y", label="y", description="Y Offset in pixels",
                    value=0.0,
                    uid=[0],
                    range=(-1000.0, 10000.0, 1.0)),
                ],
            group=None, # skip group from command line
            enabled=lambda node: node.useFisheye.value and not node.estimateFisheyeCircle.value,
        ),
        desc.FloatParam(
            name='fisheyeRadius',
            label='Radius',
            description='Fisheye visibillity circle radius (% of image shortest side).',
            value=96.0,
            range=(0.0, 150.0, 0.01),
            uid=[0],
            enabled=lambda node: node.useFisheye.value and not node.estimateFisheyeCircle.value,
        ),
        desc.ChoiceParam(
            name='inputAngle',
            label='input Angle offset',
            description='Add a rotation to the input XML given poses (CCW).',
            value='None',
            values=['None', 'rotate90', 'rotate180', 'rotate270'],
            exclusive=True,
            uid=[0]
        ),
        desc.BoolParam(
            name='debugFisheyeCircleEstimation',
            label='Debug Fisheye Circle Detection',
            description='Debug fisheye circle detection.',
            value=False,
            uid=[0],
            enabled=lambda node: node.useFisheye.value,
            advanced=True,
        ),
        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 File',
            description='Path to the output sfmdata file',
            value=desc.Node.internalFolder + 'sfmData.sfm',
            uid=[],
        )
    ]
コード例 #17
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')

    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=[0],
        ),
        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=[0],
            advanced=True),
        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='''Output SfMData.''',
            value=desc.Node.internalFolder + 'cameraInit.sfm',
            uid=[],
        ),
    ]

    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:', 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:
            raise
        finally:
            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)