Example #1
0
    def loads(cls: Type[_T],
              contents: Dict[str, Any]) -> _T:  # type: ignore[override]
        """Loads a LabeledPolyline2D from a dict containing the information of the label.

        Arguments:
            contents: A dict containing the information of the 2D polyline label.

        Returns:
            The loaded :class:`LabeledPolyline2D` object.

        Examples:
            >>> contents = {
            ...     "polyline2d": [{'x': 1, 'y': 2}, {'x': 2, 'y': 4}, {'x': 2, 'y': 1}],
            ...     "category": "example",
            ...     "attributes": {"key": "value"},
            ...     "instance": "12345",
            ...     "beizer_point_types": "LLL",
            ... }
            >>> LabeledPolyline2D.loads(contents)
            LabeledPolyline2D [
              Vector2D(1, 2),
              Vector2D(2, 4),
              Vector2D(2, 1)
            ](
              (beizer_point_types): 'LLL',
              (category): 'example',
              (attributes): {...},
              (instance): '12345'
            )

        """
        return common_loads(cls, contents)
    def loads(cls: Type[_T], contents: Mapping[str, float]) -> _T:
        """Loads CameraMatrix from a dict containing the information of the camera matrix.

        Arguments:
            contents: A dict containing the information of the camera matrix.

        Returns:
            A :class:`CameraMatrix` instance contains the information from the contents dict.

        Examples:
            >>> contents = {
            ...     "fx": 2,
            ...     "fy": 6,
            ...     "cx": 4,
            ...     "cy": 7,
            ...     "skew": 3
            ... }
            >>> camera_matrix = CameraMatrix.loads(contents)
            >>> camera_matrix
            CameraMatrix(
                (fx): 2,
                (fy): 6,
                (cx): 4,
                (cy): 7,
                (skew): 3
            )

        """
        return common_loads(cls, contents)
Example #3
0
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a LabeledBox3D from a dict containing the information of the label.

        Arguments:
            contents: A dict containing the information of the 3D bounding box label.

        Returns:
            The loaded :class:`LabeledBox3D` object.

        Examples:
            >>> contents = {
            ...     "box3d": {
            ...         "size": {"x": 1, "y": 2, "z": 3},
            ...         "translation": {"x": 1, "y": 2, "z": 3},
            ...         "rotation": {"w": 1, "x": 0, "y": 0, "z": 0},
            ...     },
            ...     "category": "test",
            ...     "attributes": {"key": "value"},
            ...     "instance": "12345",
            ... }
            >>> LabeledBox3D.loads(contents)
            LabeledBox3D(
              (size): Vector3D(1, 2, 3),
              (translation): Vector3D(1, 2, 3),
              (rotation): quaternion(1, 0, 0, 0),
              (category): 'test',
              (attributes): {...},
              (instance): '12345'
            )

        """
        return common_loads(cls, contents)
Example #4
0
    def loads(cls: Type[_T],
              contents: Dict[str, Any]) -> _T:  # type: ignore[override]
        """Loads a LabeledMultiPolyline2D from a dict containing the information of the label.

        Arguments:
            contents: A dict containing the information of the 2D polyline label.

        Returns:
            The loaded :class:`LabeledMultiPolyline2D` object.

        Examples:
            >>> contents = {
            ...     "multiPolyline2d": [[{'x': 1, 'y': 1}, {'x': 1, 'y': 2}, {'x': 2, 'y': 2}],
                                        [{'x': 2, 'y': 3}, {'x': 3, 'y': 5}]],
            ...     "category": "example",
            ...     "attributes": {"key": "value"},
            ...     "instance": "12345",
            ... }
            >>> LabeledMultiPolyline2D.loads(contents)
            LabeledMultiPolyline2D [
              Polyline2D [...]
              Polyline2D [...]
            ](
              (category): 'example',
              (attributes): {...},
              (instance): '12345'
            )

        """
        return common_loads(cls, contents)
    def loads(cls: Type[_T], contents: Mapping[str, float]) -> _T:
        """Loads DistortionCoefficients from a dict containing the information.

        Arguments:
            contents: A dict containig distortion coefficients of a camera.

        Returns:
            A :class:`DistortionCoefficients` instance containing information from
            the contents dict.

        Examples:
            >>> contents = {
            ...     "p1": 1,
            ...     "p2": 2,
            ...     "k1": 3,
            ...     "k2": 4
            ... }
            >>> distortion_coefficients = DistortionCoefficients.loads(contents)
            >>> distortion_coefficients
            DistortionCoefficients(
                (p1): 1,
                (p2): 2,
                (k1): 3,
                (k2): 4
            )

        """
        return common_loads(cls, contents)
Example #6
0
    def loads(contents: Dict[str, Any]) -> "_Type":
        """Loads a Sensor from a dict containing the sensor information.

        Arguments:
            contents: A dict containing name, description and sensor extrinsics.

        Returns:
            A :class:`Sensor` instance containing the information from the contents dict.

        Examples:
            >>> contents = {
            ...     "name": "Lidar1",
            ...     "type": "LIDAR",
            ...     "extrinsics": {
            ...         "translation": {"x": 1.1, "y": 2.2, "z": 3.3},
            ...         "rotation": {"w": 1.1, "x": 2.2, "y": 3.3, "z": 4.4},
            ...     },
            ... }
            >>> sensor = Sensor.loads(contents)
            >>> sensor
            Lidar("Lidar1")(
                (extrinsics): Transform3D(
                    (translation): Vector3D(1.1, 2.2, 3.3),
                    (rotation): quaternion(1.1, 2.2, 3.3, 4.4)
                )
            )

        """
        sensor: "Sensor._Type" = common_loads(SensorType(contents["type"]).type, contents)
        return sensor
Example #7
0
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a LabeledBox2D from a dict containing the information of the label.

        Arguments:
            contents: A dict containing the information of the 2D bounding box label.

        Returns:
            The loaded :class:`LabeledBox2D` object.

        Examples:
            >>> contents = {
            ...     "box2d": {"xmin": 1, "ymin": 2, "xmax": 5, "ymax": 8},
            ...     "category": "example",
            ...     "attributes": {"key": "value"},
            ...     "instance": "12345",
            ... }
            >>> LabeledBox2D.loads(contents)
            LabeledBox2D(1, 2, 5, 8)(
              (category): 'example',
              (attributes): {...},
              (instance): '12345'
            )

        """
        return common_loads(cls, contents)
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Load an Items from a dict containing the items information.

        Arguments:
            contents: A dict containing the information of the items.

        Returns:
            The loaded :class:`Items` object.

        Examples:
            >>> contents = {
            ...     "type": "array",
            ...     "enum": [1, 2, 3, 4, 5],
            ...     "minimum": 1,
            ...     "maximum": 5,
            ...     "items": {
            ...         "enum": [None],
            ...         "type": "null",
            ...     },
            ... }
            >>> Items.loads(contents)
            Items(
              (type): 'array',
              (enum): [...],
              (minimum): 1,
              (maximum): 5,
              (items): Items(...)
            )

        """
        return common_loads(cls, contents)
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Load an AttributeInfo from a dict containing the attribute information.

        Arguments:
            contents: A dict containing the information of the attribute.

        Returns:
            The loaded :class:`AttributeInfo` object.

        Examples:
            >>> contents = {
            ...     "name": "example",
            ...     "type": "array",
            ...     "items": {"type": "boolean"},
            ...     "description": "This is an example",
            ...     "parentCategories": ["parent_category_of_example"],
            ... }
            >>> AttributeInfo.loads(contents)
            AttributeInfo("example")(
              (type): 'array',
              (items): Items(
                (type): 'boolean',
              ),
              (parent_categories): [
                'parent_category_of_example'
              ]
            )

        """
        return common_loads(cls, contents)
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:  # type: ignore[override]
        """Loads a LabeledMultiPolygon from a list of dict containing the information of the label.

        Arguments:
            contents: A dict containing the information of the multipolygon label.

        Returns:
            The loaded :class:`LabeledMultiPolygon` object.

        Examples:
            >>> contents = {
            ...     "multiPolygon": [
            ...         [
            ...             {"x": 1.0, "y": 2.0},
            ...             {"x": 2.0, "y": 3.0},
            ...             {"x": 1.0, "y": 3.0},
            ...        ],
            ...         [{"x": 1.0, "y": 4.0}, {"x": 2.0, "y": 3.0}, {"x": 1.0, "y": 8.0}],
            ...     ],
            ...     "category": "example",
            ...     "attributes": {"key": "value"},
            ...     "instance": "12345",
            ... }
            >>> LabeledMultiPolygon.loads(contents)
            LabeledMultiPolygon [
              Polygon [...],
              Polygon [...]
            ](
              (category): 'example',
              (attributes): {...},
              (instance): '12345'
            )

        """
        return common_loads(cls, contents)
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:  # type: ignore[override]
        """Loads a LabeledRLE from a dict containing the information of the label.

        Arguments:
            contents: A dict containing the information of the rle label.

        Returns:
            The loaded :class:`LabeledRLE` object.

        Examples:
            >>> contents = {
            ...     "rle": [272, 2, 4, 4, 2, 9],
            ...     "category": "example",
            ...     "attributes": {"key": "value"},
            ...     "instance": "12345",
            ... }
            >>> LabeledRLE.loads(contents)
            LabeledRLE [
              272,
              2,
              ...
            ](
              (category): 'example',
              (attributes): {...},
              (instance): '12345'
            )

        """
        return common_loads(cls, contents)
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:  # type: ignore[override]
        """Loads a LabeledPolygon from a dict containing the information of the label.

        Arguments:
            contents: A dict containing the information of the polygon label.

        Returns:
            The loaded :class:`LabeledPolygon` object.

        Examples:
            >>> contents = {
            ...     "polygon": [
            ...         {"x": 1, "y": 2},
            ...         {"x": 2, "y": 3},
            ...         {"x": 1, "y": 3},
            ...     ],
            ...     "category": "example",
            ...     "attributes": {"key": "value"},
            ...     "instance": "12345",
            ... }
            >>> LabeledPolygon.loads(contents)
            LabeledPolygon [
              Vector2D(1, 2),
              Vector2D(2, 3),
              Vector2D(1, 3)
            ](
              (category): 'example',
              (attributes): {...},
              (instance): '12345'
            )

        """
        return common_loads(cls, contents)
Example #13
0
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a KeypointsInfo from a dict containing the information of the keypoints.

        Arguments:
            contents: A dict containing all the information of the set of keypoints.

        Returns:
            The loaded :class:`KeypointsInfo` object.

        Examples:
            >>> contents = {
            ...     "number": 2,
            ...     "names": ["L", "R"],
            ...     "skeleton": [(0,1)],
            ...     "visible": "TERNARY",
            ...     "parentCategories": ["example"],
            ...     "description": "example",
            ... }
            >>> KeypointsInfo.loads(contents)
            KeypointsInfo(
              (number): 2,
              (names): [...],
              (skeleton): [...],
              (visible): 'TERNARY',
              (parent_categories): [...]
            )

        """
        return common_loads(cls, contents)
Example #14
0
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a :class:`Draft` instance from the given contents.

        Arguments:
            contents: A dict containing all the information of the draft::

                    {
                        "number": <int>
                        "title": <str>
                        "branchName": <str>
                        "status": "OPEN", "CLOSED" or "COMMITTED"
                        "parentCommitId": <str>
                        "author": {
                            "name": <str>
                            "date": <int>
                        }
                        "updatedAt": <int>
                        "description": <str>
                    }

        Returns:
            A :class:`Draft` instance containing all the information in the given contents.

        """
        return common_loads(cls, contents)
Example #15
0
    def loads(cls: Type[_B3], contents: Mapping[str, Mapping[str,
                                                             float]]) -> _B3:
        """Load a :class:`Box3D` from a dict containing the coordinates of the 3D box.

        Arguments:
            contents: A dict containing the coordinates of a 3D box.

        Returns:
            The loaded :class:`Box3D` object.

        Examples:
            >>> contents = {
            ...     "size": {"x": 1.0, "y": 2.0, "z": 3.0},
            ...     "translation": {"x": 1.0, "y": 2.0, "z": 3.0},
            ...     "rotation": {"w": 0.0, "x": 1.0, "y": 0.0, "z": 0.0},
            ... }
            >>> Box3D.loads(contents)
            Box3D(
              (size): Vector3D(1.0, 2.0, 3.0)
              (translation): Vector3D(1.0, 2.0, 3.0),
              (rotation): quaternion(0, 1, 0, 0),
            )

        """
        return common_loads(cls, contents)
Example #16
0
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads data from a dict containing the labels information.

        Arguments:
            contents: A dict containing the labels information.

        Returns:
            A :class:`Label` instance containing labels information from the given dict.

        Examples:
            >>> contents = {
            ...     "CLASSIFICATION": {
            ...         "category": "example_category",
            ...         "attributes": {"example_attribute1": "a"}
            ...     }
            ... }
            >>> Label.loads(contents)
            Label(
              (classification): Classification(
                (category): 'example_category',
                (attributes): {...}
              )
            )

        """
        return common_loads(cls, contents)
Example #17
0
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a subcatalog from a dict containing the information of the subcatalog.

        Arguments:
            contents: A dict containing the information of the subcatalog.

        Returns:
            The loaded :class:`SubcatalogBase` object.

        """
        return common_loads(cls, contents)
Example #18
0
    def loads(cls: Type[_T], contents: List[Dict[str, Any]]) -> _T:
        """Loads a :class:`Sensors` instance from the given contents.

        Arguments:
            contents: A list of dict containing the sensors information in a fusion segment,
                whose format should be like::

                    [
                        {
                            "name": <str>
                            "type": <str>
                            "extrinsics": {
                                "translation": {
                                    "x": <float>
                                    "y": <float>
                                    "z": <float>
                                },
                                "rotation": {
                                    "w": <float>
                                    "x": <float>
                                    "y": <float>
                                    "z": <float>
                                },
                            },
                            "intrinsics": {           --- only for cameras
                                "cameraMatrix": {
                                    "fx": <float>
                                    "fy": <float>
                                    "cx": <float>
                                    "cy": <float>
                                    "skew": <float>
                                }
                                "distortionCoefficients": {
                                    "k1": <float>
                                    "k2": <float>
                                    "p1": <float>
                                    "p2": <float>
                                    ...
                                }
                            },
                            "desctiption": <str>
                        },
                        ...
                    ]

        Returns:
            The loaded :class:`Sensors` instance.

        """
        return common_loads(cls, contents)
Example #19
0
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a :class:`DiffBase` instance from the given contents.

        Arguments:
            contents: A dict containing all the information of the diff::

                    {
                        "action": <str>
                    }

        Returns:
            A :class:`DiffBase` instance containing all the information in the given contents.

        """
        return common_loads(cls, contents)
Example #20
0
    def loads(cls: Type[_T], contents: Dict[str, str]) -> _T:
        """Loads a CategoryInfo from a dict containing the category.

        Arguments:
            contents: A dict containing the information of the category.

        Returns:
            The loaded :class:`CategoryInfo` object.

        Examples:
            >>> contents = {"name": "example", "description": "This is an exmaple"}
            >>> CategoryInfo.loads(contents)
            CategoryInfo("example")

        """
        return common_loads(cls, contents)
Example #21
0
    def loads(cls: Type[_B2], contents: Mapping[str, float]) -> _B2:
        """Load a :class:`Box2D` from a dict containing coordinates of the 2D box.

        Arguments:
            contents: A dict containing coordinates of a 2D box.

        Returns:
            The loaded :class:`Box2D` object.

        Examples:
            >>> contents = {"xmin": 1.0, "ymin": 2.0, "xmax": 3.0, "ymax": 4.0}
            >>> Box2D.loads(contents)
            Box2D(1.0, 2.0, 3.0, 4.0)

        """
        return common_loads(cls, contents)
Example #22
0
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a :class:`User` instance from the given contents.

        Arguments:
            contents: A dict containing all the information of the commit::

                    {
                        "name": <str>
                        "date": <int>
                    }

        Returns:
            A :class:`User` instance containing all the information in the given contents.

        """
        return common_loads(cls, contents)
Example #23
0
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a Camera from a dict containing the camera information.

        Arguments:
            contents: A dict containing name, description, extrinsics and intrinsics.

        Returns:
            A :class:`Camera` instance containing information from contents dict.

        Examples:
            >>> contents = {
            ...     "name": "Camera1",
            ...     "type": "CAMERA",
            ...     "extrinsics": {
            ...           "translation": {"x": 1, "y": 2, "z": 3},
            ...           "rotation": {"w": 1.0, "x": 2.0, "y": 3.0, "z": 4.0},
            ...     },
            ...     "intrinsics": {
            ...         "cameraMatrix": {"fx": 1, "fy": 1, "cx": 1, "cy": 1, "skew": 0},
            ...         "distortionCoefficients": {"p1": 1, "p2": 1, "k1": 1, "k2": 1},
            ...     },
            ... }
            >>> Camera.loads(contents)
            Camera("Camera1")(
                    (extrinsics): Transform3D(
                        (translation): Vector3D(1, 2, 3),
                        (rotation): quaternion(1, 2, 3, 4)
                    ),
                    (intrinsics): CameraIntrinsics(
                        (camera_matrix): CameraMatrix(
                            (fx): 1,
                            (fy): 1,
                            (cx): 1,
                            (cy): 1,
                            (skew): 0
                        ),
                        (distortion_coefficients): DistortionCoefficients(
                            (p1): 1,
                            (p2): 1,
                            (k1): 1,
                            (k2): 1
                        )
                    )
                )

        """
        return common_loads(cls, contents)
Example #24
0
    def loads(cls: Type[_P], contents: Sequence[Mapping[str, float]]) -> _P:
        """Load a :class:`Polyline2D` from a list of dict.

        Arguments:
            contents: A list of dict containing
                the coordinates of the vertexes of the polyline.

        Returns:
            The loaded :class:`Polyline2D` object.

        Examples:
            >>> polyline = Polyline2D([[1, 1], [1, 2], [2, 2]])
            >>> polyline.dumps()
            [{'x': 1, 'y': 1}, {'x': 1, 'y': 2}, {'x': 2, 'y': 2}]

        """
        return common_loads(cls, contents)
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a LabeledSentence from a dict containing the information of the label.

        Arguments:
            contents: A dict containing the information of the sentence label.

        Returns:
            The loaded :class:`LabeledSentence` object.

        Examples:
            >>> contents = {
            ...     "sentence": [{"text": "qi1shi2", "begin": 1, "end": 2}],
            ...     "spell": [{"text": "qi1", "begin": 1, "end": 2}],
            ...     "phone": [{"text": "q", "begin": 1, "end": 2}],
            ...     "attributes": {"key": "value"},
            ... }
            >>> LabeledSentence.loads(contents)
            LabeledSentence(
              (sentence): [
                Word(
                  (text): 'qi1shi2',
                  (begin): 1,
                  (end): 2
                )
              ],
              (spell): [
                Word(
                  (text): 'qi1',
                  (begin): 1,
                  (end): 2
                )
              ],
              (phone): [
                Word(
                  (text): 'q',
                  (begin): 1,
                  (end): 2
                )
              ],
              (attributes): {
                'key': 'value'
              }
            )

        """
        return common_loads(cls, contents)
    def loads(cls: Type[_T], contents: Mapping[str, Mapping[str,
                                                            float]]) -> _T:
        """Loads CameraIntrinsics from a dict containing the information.

        Arguments:
            contents: A dict containig camera matrix and distortion coefficients.

        Returns:
            A :class:`CameraIntrinsics` instance containing information from
            the contents dict.

        Examples:
            >>> contents = {
            ...     "cameraMatrix": {
            ...         "fx": 1,
            ...         "fy": 2,
            ...         "cx": 3,
            ...         "cy": 4,
            ...     },
            ...     "distortionCoefficients": {
            ...         "p1": 1,
            ...         "p2": 2,
            ...         "k1": 3,
            ...         "k2": 4
            ...     },
            ... }
            >>> camera_intrinsics = CameraIntrinsics.loads(contents)
            >>> camera_intrinsics
            CameraIntrinsics(
                (camera_matrix): CameraMatrix(
                    (fx): 1,
                    (fy): 2,
                    (cx): 3,
                    (cy): 4,
                    (skew): 0
                ),
                (distortion_coefficients): DistortionCoefficients(
                    (p1): 1,
                    (p2): 2,
                    (k1): 3,
                    (k2): 4
                )
            )

        """
        return common_loads(cls, contents)
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a :class:`StorageConfig` instance from the given contents.

        Arguments:
            contents: The given dict containing the storage config::

                {
                    "name":                 <str>,
                    "filePath":             <str>,
                    "type":                 <str>,
                    "isGravitiStorage":     <boolean>
                }

        Returns:
            The loaded :class:`StorageConfig` instance.

        """
        return common_loads(cls, contents)
Example #28
0
    def loads(cls: Type[_P], contents: List[Dict[str, float]]) -> _P:
        """Load a :class:`Keypoints2D` from a list of dict.

        Arguments:
            contents: A list of dictionaries containing 2D keypoint.

        Returns:
            The loaded :class:`Keypoints2D` object.

        Examples:
            >>> contents = [{"x": 1.0, "y": 1.0, "v": 1}, {"x": 2.0, "y": 2.0, "v": 2}]
            >>> Keypoints2D.loads(contents)
            Keypoints2D [
              Keypoint2D(1.0, 1.0, 1),
              Keypoint2D(2.0, 2.0, 2)
            ]

        """
        return common_loads(cls, contents)
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a :class:`Notes` instance from the given contents.

        Arguments:
            contents: The given dict containing the dataset notes::

                    {
                        "isContinuous":            <boolean>
                        "binPointCloudFields": [   <array> or null
                                <field_name>,      <str>
                                ...
                        ]
                    }

        Returns:
            The loaded :class:`Notes` instance.

        """
        return common_loads(cls, contents)
Example #30
0
    def loads(cls: Type[_T], contents: Dict[str, Any]) -> _T:
        """Loads a Classification label from a dict containing the label information.

        Arguments:
            contents: A dict containing the information of the classification label.

        Returns:
            The loaded :class:`Classification` object.

        Examples:
            >>> contents = {"category": "example", "attributes": {"key": "value"}}
            >>> Classification.loads(contents)
            Classification(
              (category): 'example',
              (attributes): {...}
            )

        """
        return common_loads(cls, contents)