Skip to content

Processors

Processors adapt game images to the dimensions and interaction representation declared by player capabilities. Hydra player configuration constructs these objects from their public module paths.

Image dimensions

Classes

ImageDimensions dataclass

Dimensions of an image (width, height).

Attributes
width instance-attribute
width: int
height instance-attribute
height: int
long_side property
long_side: int

The length of the longer side of the image.

short_side property
short_side: int

The length of the shorter side of the image.

Image resizing

Classes

ImageResizer dataclass

Helper class for resizing provided images to specified dimensions.

Attributes
target_width instance-attribute
target_width: int
target_height instance-attribute
target_height: int
resampling_method class-attribute instance-attribute
resampling_method: Resampling | int = Resampling.LANCZOS
Methods:
resize_image
resize_image(image: Image, *, resampling_method_override: Resampling | int | None = None) -> Image

Resize image to target specifications.

resize_array
resize_array(array: NDArray[Any], *, resampling_method_override: Resampling | int | None = None) -> NDArray[Any]

Resize a numpy array representing an image to target specifications.

convert_absolute_to_relative
convert_absolute_to_relative(*, coordinate: PixelLocation) -> RelativeCoordinate

Convert absolute coordinate to relative coordinate based on target dimensions.

ImageResizer resizes frames and converts absolute pixel locations to relative game coordinates.

Set-of-marks processing

Classes

MaskDrawingParams dataclass

Parameters for drawing masks on the image.

Attributes
mask_thickness instance-attribute
mask_thickness: int
soft_mask_alpha instance-attribute
soft_mask_alpha: float
bw_outside_mask instance-attribute
bw_outside_mask: bool
mask_highlight_size class-attribute instance-attribute
mask_highlight_size: int | None = None

SetOfMarksHandler

Create a handler that manages the SoM labelling on screenshots of ktane.

Attributes
mark_to_coordinate instance-attribute
mark_to_coordinate: dict[SetOfMarksLocation, RelativeCoordinate] = {}
Methods:
reset
reset() -> None

Reset the mark to coordinate mapping.

extract_regions
extract_regions(colorful_image: RGBArray, zoomed_in_component: KtaneModuleId | None) -> tuple[RGBArray, list[RegionProperties]]

Extract regions from a colourful segmentation image.

run
run(*, observation: RGBArray, colorful_image: RGBArray, zoomed_in_component: KtaneModuleId | None = None) -> RGBArray

Draw the labels and bounding boxes onto the screenshot, based on the segmentation.

Output: Annotated screenshot with bounding boxes and labels drawn.

convert_mark_to_coordinate
convert_mark_to_coordinate(*, mark_id: SetOfMarksLocation) -> RelativeCoordinate

Convert a mark ID to a relative coordinate.

coordinate_to_mark
coordinate_to_mark(*, coordinate: RelativeCoordinate) -> SetOfMarksLocation

Convert a relative coordinate to a mark ID.

draw_labels
draw_labels(*, image: RGBArray, segm_img: RGBArray, regions: list[RegionProperties], module: KtaneModuleId | None) -> RGBArray

Draw labels on the image based on the segmentation image and observation.

Classes

AnnotationTextParams dataclass

Parameters for drawing the text of the annotation.

Attributes
font_scale instance-attribute
font_scale: float
thickness instance-attribute
thickness: int
space_between_boxes instance-attribute
space_between_boxes: int
font class-attribute instance-attribute
font: int = cv2.FONT_HERSHEY_SIMPLEX

AnnotationBackgroundParams dataclass

Parameters for drawing the background of the annotation.

Attributes
padding instance-attribute
padding: int
alpha class-attribute instance-attribute
alpha: float = 1

SetOfMarksHandler maps visible components to marks and retains the mapping needed to convert a predicted mark back to a game location. Drawing parameters set the text and background styles used to render labels on a segmentation mask.

Use the player configuration reference for capability fields that select these processors.