brails.types.image_set module
This module contains classes for managing and manipulating image sets.
- Classes:
Image: A class to represent an individual image.
ImageSet: A class for handling collections of images.
|
Represents an image and its associated metadata. |
|
A collection of Image objects. |
- class brails.types.image_set.Image(filename: str, properties: Dict[str, Any] | None = None)
Bases:
object
Represents an image and its associated metadata.
- Attributes:
- filename (str):
The name of the file containing the image.
- properties (dict):
A dictionary containing metadata or properties related to the image, such as camera settings, location, or depth maps.
- Methods:
- set_image(filename):
Update the filename associated with the image.
- update_properties(additional_properties):
Merge new key-value pairs into the existing image properties.
- print_info():
Print the filename and any associated properties to the console.
- print_info() None
Print the image filename and properties, if any.
- set_image(filename: str) None
Update the filename for the image.
- Args:
filename (str): New filename for the image.
- update_properties(additional_properties: Dict[str, Any]) None
Update the image’s properties.
- Args:
- additional_properties (Dict[str, Any]):
Key-value pairs to update image properties.
- class brails.types.image_set.ImageSet
Bases:
object
A collection of Image objects.
- Attributes:
- dir_path (str):
Path to the directory containing image files.
- images (Dict[Union[str, int], Image]):
Dictionary of Image objects keyed by user-defined identifiers.
- Methods:
- set_directory(path_to_dir, include_existing_images,
limited_to_extension_types):
Set the directory path and optionally load existing images.
- add_image(key, filename, properties):
Add a new Image to the collection.
- get_image(key):
Retrieve an Image by its key.
- print_info():
Print the directory path and details of all stored images.
- add_image(key: str | int, filename: str, properties: Dict[str, Any] | None = None) bool
Create and add a new Image to the ImageSet.
- Args:
- key (Union[str, int]):
Identifier for the image.
- filename (str):
Name of the image file.
- properties (Optional[Dict[str, Any]]):
Optional metadata for the image.
- Returns:
- bool:
True if image was added; False if the key already exists.
- get_image(key: str | int) Image | None
Retrieve an image by key.
- Args:
- key (Union[str, int]):
Identifier for the image.
- Returns:
- Optional[Image]:
The image if found; otherwise, None.
- print_info() None
Print the image directory and details of each image in the set.
- set_directory(path_to_dir: str, include_existing_images: bool = False, limited_to_extension_types: List[str] | None = None) bool
Set the image directory and optionally load existing images.
- Args:
- path_to_dir (str):
Path to the directory containing image files.
- include_existing_images (bool):
Whether to add existing image files in the directory.
- limited_to_extension_types (Optional[List[str]]):
If set, only include files with these extensions.
- Returns:
- bool:
True if the directory is valid and set; False otherwise.