pyclickimage.click_manager#
- class pyclickimage.click_manager.ClickManager[source]#
Bases:
objectA class to manage user clicks grouped into named categories.
This class stores 2D coordinates of points clicked on an image, grouped by string identifiers.
Points are all the time saved as float but the precision mode (float or integer) apply on output.
- _convert(value: int | float, precision_mode: Literal['float', 'int']) int | float[source]#
Convert value according to precision mode.
- add_group(group_name: str) None[source]#
Add a new group.
Note
If the group already exist, nothing is done.
- Parameters:
group_name (str) – Name of the group to add.
- clear_group(group_name: str) None[source]#
Clear all clicks in a group.
- Parameters:
group_name (str) – Group name.
- extract_group(group_name: str, *, precision_mode: Literal['float', 'int'] = 'float') List[Tuple[int | float | None, int | float | None]][source]#
Extracts the clicks for the specified group.
- Parameters:
group_name (str) – The name of the group whose clicks are to be extracted.
precision_mode (str, default is "float") – The precision mode between “int” and “float”.
- Returns:
A list of tuples with the format (Click X, Click Y) for each click in the group.
- Return type:
List[Point]
- get_click(index: int, *, group_name: str, precision_mode: Literal['float', 'int'] = 'float') Tuple[int | float | None, int | float | None][source]#
Get a specific click.
- groups: Dict[str, List[Tuple[int | float | None, int | float | None]]]#
- property n_clicks: int#
Return the number of clicks
- remove_click(index: int, *, group_name: str) None[source]#
Remove a click by index.
- Parameters:
index (int) – Index of the click.
group_name (str) – Group name.
- remove_group(group_name: str) None[source]#
Remove a group.
- Parameters:
group_name (str) – Name of the group to remove.
- rename_group(old_name: str, new_name: str) None[source]#
Rename a group.
- Parameters:
old_name (str) – Existing group name.
new_name (str) – New group name.
- Raises:
KeyError – If new name already used or old name not exist.
- to_dict(precision_mode: Literal['float', 'int'] = 'float') Dict[str, List[Tuple[int | float | None, int | float | None]]][source]#
Return internal data as dictionary.
- Parameters:
precision_mode (str, default is "float") – The precision mode between “int” and “float”.
- Returns:
Dictionary mapping group names to lists of points. Each point is a tuple (x, y) with values converted using _convert() depending on the current precision mode.
- Return type:
dict
- class pyclickimage.click_manager.ClickManagerError[source]#
Bases:
PyClickImageErrorBase ClickManager exception.
- class pyclickimage.click_manager.GroupNotFoundError[source]#
Bases:
ClickManagerError
- class pyclickimage.click_manager.GroupAlreadyExistError[source]#
Bases:
ClickManagerError
- class pyclickimage.click_manager.InvalidPrecisionError[source]#
Bases:
ClickManagerError