datumaro.plugins.data_formats.datumaro_binary.mapper#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.AnnotationListMapper[source]#
Bases:
Mapper
- backward_map = {AnnotationType.label: <bound method LabelMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.LabelMapper'>>, AnnotationType.mask: <bound method MaskMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.MaskMapper'>>, AnnotationType.points: <bound method PointsMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.PointsMapper'>>, AnnotationType.polygon: <bound method PolygonMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.PolygonMapper'>>, AnnotationType.polyline: <bound method PolyLineMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.PolyLineMapper'>>, AnnotationType.bbox: <bound method BboxMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.BboxMapper'>>, AnnotationType.caption: <bound method CaptionMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.CaptionMapper'>>, AnnotationType.cuboid_3d: <bound method Cuboid3dMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.Cuboid3dMapper'>>, AnnotationType.ellipse: <bound method EllipseMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.EllipseMapper'>>, AnnotationType.cuboid_2d: <bound method Cuboid2DMapper.backward of <class 'datumaro.plugins.data_formats.datumaro_binary.mapper.annotation.Cuboid2DMapper'>>}#
- classmethod forward(anns: List[Annotation]) bytes [source]#
Convert an object to bytes.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.LabelMapper[source]#
Bases:
AnnotationMapper
- ann_type = 1#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.MaskMapper[source]#
Bases:
AnnotationMapper
- ann_type = 2#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.RleMaskMapper[source]#
Bases:
MaskMapper
Just clone MaskMapper.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.PointsMapper[source]#
Bases:
_ShapeMapper
- ann_type = 3#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.PolygonMapper[source]#
Bases:
_ShapeMapper
- ann_type = 4#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.PolyLineMapper[source]#
Bases:
_ShapeMapper
- ann_type = 5#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.BboxMapper[source]#
Bases:
_ShapeMapper
- ann_type = 6#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.CaptionMapper[source]#
Bases:
AnnotationMapper
- ann_type = 7#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Cuboid3dMapper[source]#
Bases:
AnnotationMapper
- ann_type = 8#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.EllipseMapper[source]#
Bases:
_ShapeMapper
- ann_type = 11#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Cuboid2DMapper[source]#
Bases:
AnnotationMapper
- ann_type = 16#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.IntListMapper[source]#
Bases:
ListMapper
- class datumaro.plugins.data_formats.datumaro_binary.mapper.FloatListMapper[source]#
Bases:
ListMapper
- class datumaro.plugins.data_formats.datumaro_binary.mapper.DatasetItemMapper[source]#
Bases:
Mapper
- static forward(obj: DatasetItem) bytes [source]#
Convert an object to bytes.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.MediaMapper[source]#
Bases:
Mapper
- classmethod forward(obj: MediaElement | None) bytes [source]#
Convert an object to bytes.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Annotation(*, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#
Bases:
object
A base annotation class.
Derived classes must define the ‘_type’ class variable with a value from the AnnotationType enum.
Method generated by attrs for class Annotation.
- property type: AnnotationType#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.AnnotationMapper[source]#
Bases:
Mapper
- ann_type = 0#
- classmethod forward(ann: Annotation) bytes [source]#
Convert an object to bytes.
- classmethod backward(_bytes: bytes, offset: int = 0) Tuple[Annotation, int] [source]#
Build an object from bytes.
- static parse_ann_type(_bytes: bytes, offset: int = 0) AnnotationType [source]#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.AnnotationType(value)[source]#
Bases:
IntEnum
An enumeration.
- unknown = 0#
- label = 1#
- mask = 2#
- points = 3#
- polygon = 4#
- polyline = 5#
- bbox = 6#
- cuboid_3d = 8#
- super_resolution_annotation = 9#
- depth_annotation = 10#
- ellipse = 11#
- hash_key = 12#
- feature_vector = 13#
- tabular = 14#
- rotated_bbox = 15#
- cuboid_2d = 16#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Bbox(x, y, w, h, *args, **kwargs)[source]#
Bases:
Shape
Bbox annotation class. This class represents a bounding box defined by its top-left corner (x, y) and its width and height (w, h).
- _type#
The type of annotation, set to AnnotationType.bbox.
- Type:
- x()#
Property to get the x-coordinate of the bounding box.
- y()#
Property to get the y-coordinate of the bounding box.
- w()#
Property to get the width of the bounding box.
- h()#
Property to get the height of the bounding box.
Initialize the Bbox with its top-left corner (x, y) and its width and height (w, h).
- Parameters:
- property x#
Get the x-coordinate of the top-left corner of the bounding box.
- Returns:
The x-coordinate of the bounding box.
- Return type:
- property y#
Get the y-coordinate of the top-left corner of the bounding box.
- Returns:
The y-coordinate of the bounding box.
- Return type:
- property w#
Get the width of the bounding box.
- Returns:
The width of the bounding box.
- Return type:
- property h#
Get the height of the bounding box.
- Returns:
The height of the bounding box.
- Return type:
- get_area()[source]#
Calculate the area of the bounding box.
- Returns:
The area of the bounding box.
- Return type:
- get_bbox()[source]#
Get the bounding box coordinates and dimensions.
- Returns:
The bounding box as [x, y, w, h].
- Return type:
List[float]
- as_polygon() List[float] [source]#
Convert the bounding box into a polygon representation.
- Returns:
The bounding box as a polygon.
- Return type:
List[float]
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Caption(caption, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#
Bases:
Annotation
Represents arbitrary text annotations.
Method generated by attrs for class Caption.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Cuboid2D(_points: Iterable[Tuple[float, float]], *args, **kwargs)[source]#
Bases:
Annotation
Cuboid2D annotation class. This class represents a 3D bounding box defined by its point coordinates in the following way: [(x1, y1), (x2, y2), (x3, y3), (x4, y4), (x5, y5), (x6, y6), (x7, y7), (x8, y8)].
2—3
/| /|
- _type#
The type of annotation, set to AnnotationType.cuboid_2d.
- Type:
- wrap()#
Creates a new Cuboid2D instance with updated attributes.
Method generated by attrs for class Annotation.
- points#
- classmethod from_3d(dim: ndarray, location: ndarray, rotation_y: float, P: ndarray, Tr_velo_to_cam: ndarray) Cuboid2D [source]#
Creates an instance of Cuboid2D class from 3D bounding box parameters.
- Parameters:
dim (np.ndarray) – 3 scalars describing length, width and height of a 3D bounding box
location (np.ndarray) – (x, y, z) coordinates of the middle of the top face.
rotation_y (np.ndarray) – rotation along the Y-axis (from -pi to pi)
P (np.ndarray) – Camera-to-Image transformation matrix (3x4)
Tr_velo_to_cam (np.ndarray) – LiDAR-to-Camera transformation matrix (3x4)
- Returns:
Projection points for the given bounding box
- Return type:
- to_3d(P_inv: ndarray) tuple[ndarray, ndarray, float] [source]#
Reconstructs 3D object Velodyne coordinates (dimensions, location and rotation along the Y-axis) from the given Cuboid2D instance.
- Parameters:
P_inv (np.ndarray) – Pseudo-inverse of Camera-to-Image projection matrix
- Returns:
dimensions, location and rotation along the Y-axis
- Return type:
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Cuboid3d(position, rotation=None, scale=None, **kwargs)[source]#
Bases:
Annotation
Cuboid3d annotation class. This class represents a 3D cuboid annotation with position, rotation, and scale.
- _type#
The type of annotation, set to AnnotationType.cuboid_3d.
- Type:
- _points#
List of float values representing the position, rotation, and scale of the cuboid.
- Type:
List[float]
- position()#
Property to get and set the position of the cuboid.
- rotation()#
Property to get and set the rotation of the cuboid.
- scale()#
Property to get and set the scale of the cuboid.
Initialize the Cuboid3d with position, rotation, and scale.
- Parameters:
- property position#
Get the position of the cuboid.
- Returns:
The position [x, y, z] of the cuboid.
- Return type:
List[float]
- class datumaro.plugins.data_formats.datumaro_binary.mapper.DatasetItem(id: str, *, subset: str | None = None, media: str | MediaElement | None = None, annotations: List[Annotation] | None = None, attributes: Dict[str, Any] | None = None)[source]#
Bases:
object
- media: MediaElement | None#
- annotations: Annotations#
- exception datumaro.plugins.data_formats.datumaro_binary.mapper.DatumaroError[source]#
Bases:
Exception
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Ellipse(x1: float, y1: float, x2: float, y2: float, *args, **kwargs)[source]#
Bases:
Shape
Ellipse represents an ellipse that is encapsulated by a rectangle.
x1 and y1 represent the top-left coordinate of the encapsulating rectangle
x2 and y2 representing the bottom-right coordinate of the encapsulating rectangle
- Parameters:
Method generated by attrs for class Shape.
- property x1#
- property y1#
- property x2#
- property y2#
- property w#
- property h#
- property c_x#
- property c_y#
- get_points(num_points: int = 720) List[Tuple[float, float]] [source]#
Return points as a list of tuples, e.g. [(x0, y0), (x1, y1), …].
- Parameters:
num_points (int) – The number of boundary points of the ellipse. By default, one point is created for every 1 degree of interior angle (num_points=360).
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Image(size: Tuple[int, int] | None = None, ext: str | None = None, *args, **kwargs)[source]#
Bases:
MediaElement
[ndarray
]
- class datumaro.plugins.data_formats.datumaro_binary.mapper.ImageMapper[source]#
Bases:
MediaElementMapper
- MAGIC_SIZE_FOR_NONE = (-1583, -1597)#
- MEDIA_TYPE = 2#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Label(label, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1)[source]#
Bases:
Annotation
Method generated by attrs for class Label.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Mask(image: ndarray | Callable[[], ndarray], *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1, label=None, z_order: int = 0)[source]#
Bases:
Annotation
Represents a 2d single-instance binary segmentation mask.
Method generated by attrs for class Mask.
- as_class_mask(label_id: int | None = None, ignore_index: int = 0, dtype: dtype | None = None) ndarray [source]#
Produces a class index mask based on the binary mask.
- Parameters:
label_id – Scalar value to represent the class index of the mask. If not specified, self.label will be used. Defaults to None.
ignore_index – Scalar value to fill in the zeros in the binary mask. Defaults to 0.
dtype – Data type for the resulting mask. If not specified, it will be inferred from the provided label_id to hold its value. For example, if label_id=255, the inferred dtype will be np.uint8. Defaults to None.
- Returns:
Class index mask generated from the binary mask.
- Return type:
IndexMaskImage
- as_instance_mask(instance_id: int, ignore_index: int = 0, dtype: dtype | None = None) ndarray [source]#
Produces an instance index mask based on the binary mask.
- Parameters:
instance_id – Scalar value to represent the instance id.
ignore_index – Scalar value to fill in the zeros in the binary mask. Defaults to 0.
dtype – Data type for the resulting mask. If not specified, it will be inferred from the provided label_id to hold its value. For example, if label_id=255, the inferred dtype will be np.uint8. Defaults to None.
- Returns:
Instance index mask generated from the binary mask.
- Return type:
IndexMaskImage
- class datumaro.plugins.data_formats.datumaro_binary.mapper.MediaElement(crypter: ~datumaro.components.crypter.Crypter = <datumaro.components.crypter.NullCrypter object>, *args, **kwargs)[source]#
Bases:
Generic
[AnyData
]
- class datumaro.plugins.data_formats.datumaro_binary.mapper.MediaElementMapper[source]#
Bases:
Mapper
- MAGIC_PATH = '/NOT/A/REAL/PATH'#
- MEDIA_TYPE = 1#
- classmethod forward(obj: MediaElement) bytes [source]#
Convert an object to bytes.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.MediaType(value)[source]#
Bases:
IntEnum
An enumeration.
- NONE = 0#
- MEDIA_ELEMENT = 1#
- IMAGE = 2#
- BYTE_IMAGE = 3#
- VIDEO_FRAME = 4#
- VIDEO = 5#
- POINT_CLOUD = 6#
- MULTIFRAME_IMAGE = 7#
- ROI_IMAGE = 8#
- MOSAIC_IMAGE = 9#
- TABLE_ROW = 10#
- property media: Type[MediaElement] | None#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.PointCloud(extra_images: List[Image] | Callable[[], List[Image]] | None = None, *args, **kwargs)[source]#
Bases:
MediaElement
[bytes
]
- class datumaro.plugins.data_formats.datumaro_binary.mapper.PointCloudMapper[source]#
Bases:
MediaElementMapper
- MEDIA_TYPE = 6#
- classmethod forward(obj: PointCloud) bytes [source]#
Convert an object to bytes.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Points(points, visibility: List[IntEnum] | None = None, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1, label=None, z_order: int = 0)[source]#
Bases:
Shape
Represents an ordered set of points.
- _type#
The type of annotation, set to AnnotationType.points.
- Type:
- Nested Class:
- Visibility (IntEnum): Enum representing the visibility state of points. It has three states:
absent: Point is absent (0).
hidden: Point is hidden (1).
visible: Point is visible (2).
Method generated by attrs for class Points.
- class Visibility(value)[source]#
Bases:
IntEnum
Enum representing the visibility state of points.
Point is hidden (1).
- Type:
- absent = 0#
- hidden = 1#
- visible = 2#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.PolyLine(points, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1, label=None, z_order: int = 0)[source]#
Bases:
Shape
PolyLine annotation class. This class represents a polyline shape, which is a series of connected line segments.
- _type#
The type of annotation, set to AnnotationType.polyline.
- Type:
Method generated by attrs for class PolyLine.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Polygon(points, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1, label=None, z_order: int = 0)[source]#
Bases:
Shape
Polygon annotation class. This class represents a polygon shape defined by a series of points.
- _type#
The type of annotation, set to AnnotationType.polygon.
- Type:
- _get_shoelace_area()[source]#
Helper method to calculate the area of the polygon using the shoelace formula.
Method generated by attrs for class Polygon.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.RleMask(rle, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1, label=None, z_order: int = 0)[source]#
Bases:
Mask
An RLE-encoded instance segmentation mask.
Method generated by attrs for class RleMask.
- property rle#
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Shape(points, *, id: int = 0, attributes: Dict[str, Any] = _Nothing.NOTHING, group: int = 0, object_id: int = -1, label=None, z_order: int = 0)[source]#
Bases:
Annotation
Base class for shape annotations. This class defines the common attributes and methods for different types of shape annotations.
Method generated by attrs for class Shape.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.Video(path: str, step: int = 1, start_frame: int = 0, end_frame: int | None = None, *args, **kwargs)[source]#
Bases:
MediaElement
,Iterable
[VideoFrame
]- get_frame_data(idx: int) VideoFrame [source]#
- property length: int | None#
Returns frame count of the closed interval [start_frame, end_frame], if video provides such information.
Note that not all videos provide length / duration metainfo, so the result may be undefined.
Also note, that information may be inaccurate because of variable FPS in video or incorrect metainfo. The count is only guaranteed to be valid after video is completely read once.
The count is affected by the frame filtering options of the object, i.e. start frame, end frame and frame step.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.VideoFrame(video: Video, index: int)[source]#
Bases:
ImageFromNumpy
- class datumaro.plugins.data_formats.datumaro_binary.mapper.VideoFrameMapper[source]#
Bases:
MediaElementMapper
- MEDIA_TYPE = 4#
- classmethod forward(obj: VideoFrame) bytes [source]#
Convert an object to bytes.
- class datumaro.plugins.data_formats.datumaro_binary.mapper.VideoMapper[source]#
Bases:
MediaElementMapper
- MAGIC_END_FRAME_FOR_NONE = 4294967295#
- MEDIA_TYPE = 5#
Modules
|
|
|
|