|
| None | _check_context (context, str func_name) |
| |
| Tuple[int, int] | _check_resolution (resolution, str func_name) |
| |
| np.ndarray | _check_pixel_map (pixel_uuids, int width, int height, str func_name) |
| |
| Tuple[List[str], List[int]] | _check_labels (data_labels, class_ids, str func_name) |
| |
| str | _check_filename (value, str name, str func_name) |
| |
| List[YOLOBox] | labelBoundingBoxes (Context context, pixel_uuids, int2 resolution, Union[str, List[str]] data_labels, Union[int, List[int]] class_ids, bool use_object_data=False) |
| | Compute a bounding box for each labeled object visible in a pixel-to-primitive map.
|
| |
| None | writeLabelBoundingBoxes (Context context, pixel_uuids, int2 resolution, Union[str, List[str]] data_labels, Union[int, List[int]] class_ids, str image_file, str classes_txt_file="classes.txt", str image_path="./", bool use_object_data=False) |
| | Write YOLO bounding boxes and a class file for the labeled objects visible in a pixel-to-primitive map.
|
| |
| Dict[int, np.ndarray] | labelMasks (Context context, pixel_uuids, int2 resolution, str data_label, bool use_object_data=False) |
| | Build a binary mask for each distinct value of a data label visible in a pixel-to-primitive map.
|
| |
| None | writeLabelSegmentationMasks (Context context, pixel_uuids, int2 resolution, Union[str, List[str]] data_labels, Union[int, List[int]] class_ids, str json_filename, str image_file, Optional[List[str]] data_attribute_labels=None, bool append_file=False, bool use_object_data=False) |
| | Write COCO JSON segmentation masks for the labeled objects visible in a pixel-to-primitive map.
|
| |
| List[YOLOBox] pyhelios.annotation.labelBoundingBoxes |
( |
Context | context, |
|
|
| pixel_uuids, |
|
|
int2 | resolution, |
|
|
Union[str, List[str]] | data_labels, |
|
|
Union[int, List[int]] | class_ids, |
|
|
bool | use_object_data = False ) |
Compute a bounding box for each labeled object visible in a pixel-to-primitive map.
One box is produced per distinct pair of class index and label value. A box encloses whole every pixel in which the object is visible: it runs from the left edge of the first pixel column to the right edge of the last, and from the top edge of the first pixel row to the bottom edge of the last, so an object visible in a single pixel has a box one pixel in size.
- Parameters
-
| context | Context holding the primitives named by the map and their label data. |
| pixel_uuids | Pixel-to-primitive map (UUID + 1 per pixel, 0 for none), row-major with row 0 at the top of the image. |
| resolution | Image dimensions in pixels, as int2(width, height). |
| data_labels | Name of a primitive or object data label, or a list of them. |
| class_ids | Class index for the objects of each data label (an int for a single label, or a list in the same order as data_labels). |
| use_object_data | If True, labels are read from the data of each primitive's parent object; if False (default), from primitive data. |
- Returns
- List of :class:
YOLOBox, ordered by class index and then label value.
- Exceptions
-
| ValueError | If ``context`` is not a Context, ``resolution`` is not an int2, or the map does not have width * height elements. |
| TypeError | If the labels, class IDs or map have the wrong type. |
| NotImplementedError | If the native library predates helios-core v1.3.91. |
Definition at line 162 of file annotation.py.
| None pyhelios.annotation.writeLabelBoundingBoxes |
( |
Context | context, |
|
|
| pixel_uuids, |
|
|
int2 | resolution, |
|
|
Union[str, List[str]] | data_labels, |
|
|
Union[int, List[int]] | class_ids, |
|
|
str | image_file, |
|
|
str | classes_txt_file = "classes.txt", |
|
|
str | image_path = "./", |
|
|
bool | use_object_data = False ) |
Write YOLO bounding boxes and a class file for the labeled objects visible in a pixel-to-primitive map.
The boxes (see :func:labelBoundingBoxes) are written to a file named after the image, with its extension replaced by .txt, in the directory image_path. The class file holds one class_id data_label pair per line.
- Parameters
-
| context | Context holding the primitives named by the map and their label data. |
| pixel_uuids | Pixel-to-primitive map (UUID + 1 per pixel, 0 for none), row-major with row 0 at the top of the image. |
| resolution | Image dimensions in pixels, as int2(width, height). |
| data_labels | Name of a primitive or object data label, or a list of them. |
| class_ids | Class index for the objects of each data label. |
| image_file | Name of the image these boxes annotate. Only its stem is used, to name the output file; the image itself need not exist. |
| classes_txt_file | Name of the class file to write within image_path (default "classes.txt"). |
| image_path | Directory to write the output files to (default: current directory). |
| use_object_data | If True, labels are read from object data; if False (default), from primitive data. |
- Exceptions
-
| ValueError | On invalid arguments (see :func:`labelBoundingBoxes`). |
| HeliosRuntimeError | If ``image_path`` is not a writable directory or a file cannot be written. |
| NotImplementedError | If the native library predates helios-core v1.3.91. |
Definition at line 200 of file annotation.py.
| None pyhelios.annotation.writeLabelSegmentationMasks |
( |
Context | context, |
|
|
| pixel_uuids, |
|
|
int2 | resolution, |
|
|
Union[str, List[str]] | data_labels, |
|
|
Union[int, List[int]] | class_ids, |
|
|
str | json_filename, |
|
|
str | image_file, |
|
|
Optional[List[str]] | data_attribute_labels = None, |
|
|
bool | append_file = False, |
|
|
bool | use_object_data = False ) |
Write COCO JSON segmentation masks for the labeled objects visible in a pixel-to-primitive map.
Each connected region of pixels sharing one value of a data label becomes one annotation, so an object split in two by an occluder yields two annotations. Pixels touching only at a corner are connected. The bbox of an annotation is (x, y, width, height) in pixels, enclosing whole every pixel of the region. A region of only one or two pixels is too small to outline and is not written. Each data label becomes a COCO category.
- Parameters
-
| context | Context holding the primitives named by the map and their label data. |
| pixel_uuids | Pixel-to-primitive map (UUID + 1 per pixel, 0 for none), row-major with row 0 at the top of the image. |
| resolution | Image dimensions in pixels, as int2(width, height). |
| data_labels | Name of a primitive or object data label, or a list of them. |
| class_ids | COCO category ID for each data label. |
| json_filename | Path of the COCO JSON file to write. ".json" is appended if missing. |
| image_file | Path of the image these masks annotate, which must exist. |
| data_attribute_labels | Optional primitive or object data labels of type int, uint, float or double whose mean over the pixels of each mask is written to that annotation's "attributes". A label that exists as both is read from primitive data; labels that do not exist are ignored. |
| append_file | If True, annotations are added to an existing file at json_filename; if False (default), a new file is written. |
| use_object_data | If True, labels are read from object data; if False (default), from primitive data. |
- Exceptions
-
| ValueError | On invalid arguments (see :func:`labelBoundingBoxes`). |
| HeliosRuntimeError | If ``image_file`` does not exist or the JSON file cannot be written. |
| NotImplementedError | If the native library predates helios-core v1.3.91. |
Definition at line 281 of file annotation.py.