pyclickimage.click_image_app#

class pyclickimage.click_image_app.ClickImageApp(images: str | Path | list[str | Path] | None = None, session: str | Path | None = None)[source]#

Bases: QMainWindow

PyQt application for collecting precise mouse clicks on images.

Features#

  • Subpixel precision (float coordinates)

  • Optional integer rounding mode

  • Multiple click groups

  • CSV export/import

  • Real-time overlay rendering

Notes

The image is displayed by an embedded QtImageToolWindow, whose toolbar (display mode, colormap, Interpolation) handles the display contrast.

_append_log(msg: str)[source]#

Append log message.

_check_annotation_ready() → bool[source]#

Check if an image and a group are selected.

Returns:

True if annotations can be added.

Return type:

bool

_format_value(v)[source]#

Format a coordinate for display in the table.

_init_left_panel()[source]#

Build the left interface for multi-image annotation session.

_init_shortcuts()[source]#

Initialize global keyboard shortcuts.

_init_toolbar()[source]#

Build toolbar

_process_left_click(x: float, y: float)[source]#

Add click to current image/group.

_process_right_click(x: float, y: float)[source]#

Add empty click placeholder.

choose_color() → None[source]#

Change annotation marker color.

choose_other_color() → None[source]#

Change annotation marker color.

clear_logs()[source]#

Clear log message.

closeEvent(event)[source]#

Confirm exit if unsaved.

crosshair_choose_color() → None[source]#

Change viewer crosshair color.

get_current_image() → ndarray | None[source]#

Return the current image from cache.

If the image is not cached, it is loaded from disk.

Returns:

Current BGR image.

Return type:

numpy.ndarray or None

next_group()[source]#

Select the next annotation group.

next_image()[source]#

Select the next image in the session.

on_add_group() → None[source]#

Create a new annotation group.

on_add_images()[source]#

Add one or multiple images to the current annotation session.

on_change_current_group(index: int) → None[source]#

Change the currently active annotation group.

on_change_current_image(index: int) → None[source]#

Change the currently displayed image.

on_delete_group() → None[source]#

Delete the current annotation group.

on_display_clicks_changed(state: int) → None[source]#

Toggle annotation marker visibility.

on_display_other_clicks_changed(state: int) → None[source]#

Toggle annotation marker visibility.

on_half_shift_changed(state)[source]#

Toggle half-shift mode for the whole session.

on_load_session() → None[source]#

Load an annotation session from CSV or JSON.

on_marker_size_changed(value: str) → None[source]#

Update annotation marker size.

on_other_marker_size_changed(value: str) → None[source]#

Update annotation marker size.

on_precision_changed(state)[source]#

Change displayed coordinate precision.

on_remove_all_clicks() → None[source]#

Remove all clicks from the current image and group.

on_remove_image()[source]#

Remove the current image from the annotation session.

on_remove_last_click() → None[source]#

Remove the last click.

on_rename_group() → None[source]#

Rename the current annotation group.

on_save_session() → None[source]#

Save the current annotation session.

Supported formats:

  • JSON: complete project backup.

  • CSV: annotation export.

on_sort_groups_alpha()[source]#

Sort groups alphabetically.

on_sort_groups_natural()[source]#

Sort groups using natural numeric ordering.

on_sort_images_alpha()[source]#

Sort images alphabetically.

on_sort_images_natural()[source]#

Sort images using natural numeric ordering.

previous_group()[source]#

Select the previous annotation group.

previous_image()[source]#

Select the previous image in the session.

select_group_index(index)[source]#

Select an annotation group by its combobox index.

Parameters:

index (int) – Index of the group to select.

select_image_index(index)[source]#

Select an image by its combobox index.

Parameters:

index (int) – Index of the image to select.

show_help()[source]#

Open the help dialog.

The help is organized in tabs, one per topic. Each tab is a read-only QTextBrowser, so links are clickable.

synchronize_groups()[source]#

Synchronize group selector with current session groups.

synchronize_images()[source]#

Synchronize image selector with current session images.

synchronize_params()[source]#

Synchronize checkbox with current session.

toggle_display_clicks()[source]#

Toggle the display of annotation markers.

This updates the associated checkbox state, which triggers the display callback.

update()[source]#

Refresh complete interface.

update_table()[source]#

Update table with current image/group clicks.

update_viewer()[source]#

Render current image and annotations.

Notes

The image is sent to QtImageToolWindow only when it changed. Normalization, contrast and colormap are handled by the tool window. Markers are redrawn on every call.