kitcar_ml.utils package

Subpackages

Submodules

kitcar_ml.utils.benchmark module

kitcar_ml.utils.bounding_box module

Classes:

BoundingBox(x1, y1, x2, y2, class_label[, ...])

Class representing a bounding box.

class BoundingBox(x1: float, y1: float, x2: float, y2: float, class_label: str, confidence: Optional[float] = None)[source]

Bases: object

Class representing a bounding box.

The four coordinates are the absolute coordinates in the image.

Attributes:

x1

Lower inclusive bound of the bounding box.

y1

Left inclusive bound of the bounding box.

x2

Upper inclusive bound of the bounding box.

y2

Right inclusive bound of the bounding box.

class_label

Class that the model gave the bounding box.

confidence

Confidence of the model, that this bounding box is correct.

coordinates

center_point

width

height

area

The area of the bounding box.

Methods:

shift_and_scale(shift, scale)

Shift and scale the bounding box :param shift: Vector that translates the bounding box.

create_bounding_boxes(boxes, labels[, scores])

Create multiple bounding boxes.

iou(box_a, box_b)

Calculate the IOU(Intersection over Union) of two bounding boxes.

union_area(box_a, box_b[, intersection_area])

Calculate the union area of two bounding boxes.

intersection_area(box_a, box_b)

Calculate the intersection area of two bounding boxes.

x1: float

Lower inclusive bound of the bounding box.

y1: float

Left inclusive bound of the bounding box.

x2: float

Upper inclusive bound of the bounding box.

y2: float

Right inclusive bound of the bounding box.

class_label: str

Class that the model gave the bounding box.

confidence: float = None

Confidence of the model, that this bounding box is correct.

property coordinates
property center_point: Tuple[float, float]
property width: float
property height: float
property area

The area of the bounding box.

(width + 1)x(height + 1), because the boundaries are inside the bounding box.

shift_and_scale(shift, scale)[source]

Shift and scale the bounding box :param shift: Vector that translates the bounding box. :param scale: Vector that increases or decreases the bounding box.

Returns

The scaled and shifted bounding box coordinates.

classmethod create_bounding_boxes(boxes: Iterable[Iterable[int]], labels: Iterable[str], scores: Optional[Iterable[float]] = None)[source]

Create multiple bounding boxes.

classmethod iou(box_a: BoundingBox, box_b: BoundingBox) float[source]

Calculate the IOU(Intersection over Union) of two bounding boxes.

classmethod union_area(box_a: BoundingBox, box_b: BoundingBox, intersection_area=None) float[source]

Calculate the union area of two bounding boxes.

static intersection_area(box_a: BoundingBox, box_b: BoundingBox) float[source]

Calculate the intersection area of two bounding boxes.

kitcar_ml.utils.visualization module

Functions:

draw_boxes(image, boxes, labels)

Draw labeled boxes on an image.

show_labeled_image(image[, boxes, labels, ...])

Show the image along with the specified boxes around detected objects.

draw_boxes(image, boxes, labels)[source]

Draw labeled boxes on an image.

show_labeled_image(image: Union[Image, ndarray, Tensor], boxes: Optional[Tensor] = None, labels: Optional[List[str]] = None, save_path: Optional[str] = None, show: bool = False)[source]

Show the image along with the specified boxes around detected objects.

Parameters
  • image – The image that is displayed.

  • boxes – The bounding boxes on the image.

  • labels – A list of labels for each bounding box.

  • save_path – The path to the folder where the image should be saved.

  • show – If the image should be shown interactively.

Module contents

Utils Package for KITcar-Machine-Learning.