anatools.annotations.draw module¶
- box_2d(coordinates, bbox_img, width, outline)¶
Draws 2d boxes around objects given a list of coordinates.
- Parameters
coordinates (list) – The list of coordinates.
bbox_img (array) – Image in form of a numpy array.
width (int) – Desired line thickness for box outline.
outline (list) – List of bgr color values for PIL color inputs.
- Returns
Image in form of a numpy array with 2d boxes around objects.
- Return type
array
- box_3d(coordinates, bbox_img, width, fill)¶
Draws 3d boxes around objects given a list of coordinates.
- Parameters
coordinates (list) – The list of coordinates.
bbox_img (array) – Image in form of a numpy array.
width (int) – Desired line thickness for box outline.
fill (list) – List of bgr color values for PIL color inputs.
- Returns
Image in form of a numpy array with 3d boxes around objects.
- Return type
array
- check_lists(actual, expected, name_to_check)¶
Helper function that checks if one list is in another for validation on draw inputs.
- Parameters
actual (list) – The list of actual values found in either annotation or metadata file.
expected (list) – The expected list that is provided from the user.
name_to_check (str) – Name of parameter to check (either object_id or object_type).
- Returns
True if lists are matching, False otherwise.
- Return type
bool
- draw(image_path, out_dir, draw_type='box_2d', object_ids=None, object_types=None, line_thickness=1)¶
This function handles the io and draws the right type of annotation on the image.
- Parameters
image_path (str) – Path to of specific image file to draw the boxes for.
out_dir (str) – File path to directory where the image should be saved to.
draw_type (str) – Draw either a 2d bounding box, 3d bounding box, or segmentation on objects within an image. Must pass in either ‘box_2d’, ‘box_3d’, or ‘segmentation’ for values.
object_ids (list[int]) – List of object id’s to annotate. If not provided, all objects will get annotated. Choose either id or type filter.
object_types (list[str]) – Filter for the object types to annotate. If not provided, all object types will get annotated. Choose either id or type filter.
line_thickness (int) – Desired line thickness for box outline.
- segmentation(coordinates, draw_img, width, color)¶
Draws an outline around objects given a list of coordinates.
- Parameters
coordinates (list) – The list of coordinates.
draw_img (array) – Image in form of a numpy array.
width (int) – Desired line thickness for box outline.
fill (list) – List of bgr color values for cv2 color inputs.
- Returns
Image in form of a numpy array with objects outlined.
- Return type
array