Skip to main content

NotebookHelpers

These are miscellaneous helper methods to render responses from ApertureDB in a jupyter environment.

This module provides helper classes (such as BoundingBox, TemporalBoundingBox) and functions (such as display, draw_bboxes, display_video_mp4, display_annotated_video) to help render visual results from ApertureDB queries directly within a Jupyter Notebook. It makes it easier to visualize bounding boxes, images, and videos without writing boilerplate code.

BoundingBox​

BoundingBox(r: Rectangle = None, label: str = None)

A class which combines a box and a label.

TemporalBoundingBox​

TemporalBoundingBox(bb: BoundingBox = None, start_frame: int = 0, end_frame=0)

A class that represents a box, but also associated time in the range of frame start and end

display​

display(images_array, save=False)

Show images with matplotlib

Note

This method was used by ApertureDB to display images, but it is not recommended anymore. It will not draw annotation.

Instead, when using with JSON queries, make a instance of the Images class and call the display method.

from aperturedb.Images import Images
result, response, blobs = execute_query(client, [{"FindImage":{"uniqueids": True}}], [])
wrapper = Images(client, response=response[0]["FindImage"]["entities"])
wrapper.display()

display_video_mp4​

display_video_mp4(blob)

Display a video using IPython.display

Parameters:

NameTypeDescriptionDefault
blobbytearray

A blob that is the Video.

required

annotate_video​

annotate_video(blob, bboxes: List[TemporalBoundingBox] = [])

Place annotations on a video framewise

Parameters:

NameTypeDescriptionDefault
blobbytearray

Video blob returned from the database

required
bboxesList[TemporalBoundingBox]

List of boxes to be drawn. Defaults to [].

[]

display_annotated_video​

display_annotated_video(blob, bboxes: List[TemporalBoundingBox] = [])

Returns a HTML representation with a column filled with video entities.