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¶
Image resizing¶
Classes¶
ImageResizer
dataclass
¶
Helper class for resizing provided images to specified dimensions.
Attributes¶
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.
SetOfMarksHandler
¶
Create a handler that manages the SoM labelling on screenshots of ktane.
Attributes¶
alphabet
class-attribute
¶
alphabet: list[str] = list(itertools.chain(string.ascii_uppercase, map(''.join, itertools.combinations_with_replacement(string.ascii_uppercase, 2))))
mark_to_coordinate
instance-attribute
¶
mark_to_coordinate: dict[SetOfMarksLocation, RelativeCoordinate] = {}
Methods:¶
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.
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.