Images
Image Objects
np_arr_img_to_bytes
def np_arr_img_to_bytes(arr, format: str = 'JPEG') -> bytes
Convert a NumPy array to bytes
Arguments:
arr
- The NumPy array to convertformat
- The format of the image. Defaults to "JPEG".
Returns:
bytes
- The image as bytes
image_to_bytes
def image_to_bytes(image: Image, format: str = "JPEG") -> bytes
Convert an image to bytes
Arguments:
image
PIL.Image - The image to convertformat
str, optional - The format of the image. Defaults to "JPEG".
Returns:
bytes
- The image as bytes
rotate
def rotate(points, angle, c_x=0, c_y=0)
Rotate a set of points around a center
Arguments:
points
- The points to rotate; iterable of (x, y) pairsangle
- The angle of counterclockwise rotation in degreesc_x
- The x coordinate of the center of rotationc_y
- The y coordinate of the center of rotation
Returns:
points
- The rotated points as a NumPy array of shape (n,2) and type int
resolve
def resolve(points: np.array, image_meta, operations) -> np.array
Resolve the coordinates of a bounding box to the original image size
Given an array of (x,y) points with respect to the coordinates of an image, returns the corresponding coordinates with respect to a the resized or rotated image that resulted from a series of operations.
Arguments:
points
NumPy array - The coordinates of the bounding box; shape (...,2)image
dict - The image propertiesoperations
list - The operations applied to the image
Returns:
resolved_points
NumPy array - The resolved coordinates, same shape as points
Images Objects
class Images(Entities)
The python wrapper of images in ApertureDB.
This class serves 2 purposes:
This class is a layer on top of the native query.
It facilitate interactions with images in the database in a pythonic way. Abstracts the complexity of the query language and the communication with the database.
It includes utility methods to visualize image and annotations
Inter convert the representation into NumPy matrices and find similar images, related bounding boxes, etc.
Arguments:
client
- The database connector, perhaps as returned byCommonLibrary.create_connector
total_results
def total_results() -> int
Returns the total number of images that matched the query
Returns:
int
- Count of images that match the query.
get_image_by_index
def get_image_by_index(index: int)
Get a single image by its index in the array of retrieved ids
Arguments:
index
int - Position in the image ids retrieved.
get_np_image_by_index
def get_np_image_by_index(index: int)
Retrieves the NumPy representation of image from database
Arguments:
index
int - Position in the image ids retrieved.
get_bboxes_by_index
def get_bboxes_by_index(index: int)
Get related bounding box for the image
Arguments:
index
int - Position in the image ids retrieved.
Returns:
_type_
- description
search
def search(constraints=None,
operations=None,
format=None,
limit=None,
sort=None)
Sets a new query to retrieve images parameters as described below
Arguments:
constraints
dict, optional - Constraints. Defaults to None.operations
dict, optional - Operations. Defaults to None.format
str, optional - Format of the returned images. Without this, the images are returned as they are stored. Defaults to None.limit
int, optional - number of values to restrict results to. Defaults to None.sort
dict, optional - Sort. Defaults to None.
search_by_property
def search_by_property(prop_key: str, prop_values: list)
Constructs a constraints block and does a new search
Arguments:
prop_key
str - Key on which to searchprop_values
list - The values that must match for the key.
display
def display(show_bboxes: bool = False,
bbox_constraints: Constraints = None,
show_polygons: bool = False,
limit: Union[int, object] = None,
polygon_constraints: Constraints = None,
polygon_tag_key: str = "_label",
polygon_tag_format: str = "{}") -> None
Display images with annotations
Arguments:
show_bboxes
- bool, optional Show bounding boxes, by default Falsebbox_constraints
- Constraints, optional Constraints for bounding boxes, by default Noneshow_polygons
- bool, optional Show polygons, by default Falselimit
- Union[int, object], optional Number of images to display, by default Nonepolygon_constraints
- Constraints, optional Constraints for polygons, by default Nonepolygon_tag_key
- str, optional Key for the polygon tag, by default "_label"polygon_tag_format
- str, optional Format for the polygon tag, by default "{}"
get_props_names
def get_props_names() -> List[str]
Get the names of the properties that apply to images
Returns:
properties
List[str] - The names of the properties of the images
get_properties
def get_properties(prop_list: Iterable[str] = []) -> Dict[str, Any]
Get the properties of the images
Arguments:
prop_list
List[str], optional - The list of properties to retrieve. Defaults to [].
Returns:
property_values Dict[str, Any]: The properties of the images
Frames Objects
class Frames(Images)
The python wrapper of frame images in ApertureDB.
Frames in ApertureDB are quite similar to images and so are modeled in python as a subclass.
Arguments:
client
- The database connector, perhaps as returned byCommonLibrary.create_connector