Annotations¶
-
class
mira.core.Annotation(category, x1=None, y1=None, x2=None, y2=None, points=None, score=None, metadata=None)[source]¶ Defines a single annotation.
- Parameters
selection – The selection associated with the annotation
category (
Category) – The category of the annotationscore (
Optional[float]) – A score for the annotationmetadata (
Optional[dict]) – Metadata to store as part of the annotation
-
assign(**kwargs)[source]¶ Get a new Annotation with only the supplied keyword arguments changed.
- Return type
Annotation
-
convert(categories)[source]¶ Convert an annotation to match another annotation config.
- Return type
Annotation
-
crop(width, height)[source]¶ Crop a selection to a given image width and height.
- Parameters
width – The width of the image
height – The height of the image
-
draw(image, color, opaque=False, thickness=5)[source]¶ Draw selection onto given image.
- Parameters
image (
ndarray) – The image to draw on.color (
Union[Tuple[int,int,int],Tuple[int,int,int,int],int]) – The color to use.opaque (
bool) – Whether the box should be filled.thickness (
int) – The thickness of the box (for non-opaque cases only).
- Returns
The image with the selection drawn
-
extract(image, pad=0)[source]¶ Extract selection from image (i.e., crop the image to the selection).
-
resize(scale)[source]¶ Obtain a revised selection with a given uniform scaling. Scale should be provided as either a single float or as an array with scaling factors provided as [sx, sy]
- Return type
Annotation
-
class
mira.core.Categories(names)[source]¶ A class defining a list of annotation types for an object detection class.
- Parameters
names (
List[str]) – The list of class names
-
bboxes_from_group(annotations)[source]¶ Obtain an array of shape (N, 5) where the columns are x1, y1, x2, y2, class_index where class_index is determined from the annotation configuration.
-
classmethod
from_categories(categories)[source]¶ Convert a list of strings to categories if it is not already.
- Return type
Categories
-
property
types¶ Get the list of types.