Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard shortcuts for assigning flags #988

Closed
ghylander opened this issue Feb 23, 2022 · 3 comments
Closed

Keyboard shortcuts for assigning flags #988

ghylander opened this issue Feb 23, 2022 · 3 comments

Comments

@ghylander
Copy link

Is your feature request related to a problem? Please describe.
I'd like to be able to create shortcuts to quickly start a polygon tool or assign a flag to the image, and to advance to the next image or to go back to the previous image.

Describe the solution you'd like
Either pre-defined or user-definable keyboard shortcuts for labelme functions

@wkentaro
Copy link
Owner

You can edit ~/.labelmerc file and add shortcuts there.
Here are predefined ones:

shortcuts:
close: Ctrl+W
open: Ctrl+O
open_dir: Ctrl+U
quit: Ctrl+Q
save: Ctrl+S
save_as: Ctrl+Shift+S
save_to: null
delete_file: Ctrl+Delete
open_next: [D, Ctrl+Shift+D]
open_prev: [A, Ctrl+Shift+A]
zoom_in: [Ctrl++, Ctrl+=]
zoom_out: Ctrl+-
zoom_to_original: Ctrl+0
fit_window: Ctrl+F
fit_width: Ctrl+Shift+F
create_polygon: Ctrl+N
create_rectangle: Ctrl+R
create_circle: null
create_line: null
create_point: null
create_linestrip: null
edit_polygon: Ctrl+J
delete_polygon: Delete
duplicate_polygon: Ctrl+D
copy_polygon: Ctrl+C
paste_polygon: Ctrl+V
undo: Ctrl+Z
undo_last_point: Ctrl+Z
add_point_to_edge: Ctrl+Shift+P
edit_label: Ctrl+E
toggle_keep_prev_mode: Ctrl+P
remove_selected_point: [Meta+H, Backspace]

@wkentaro wkentaro self-assigned this Feb 25, 2022
@wkentaro wkentaro changed the title [Feature] Add keyboard shortcuts? Add keyboard shortcuts? Feb 25, 2022
@ghylander
Copy link
Author

ghylander commented Mar 1, 2022

that's amazing to know, I had a look at the docs/tried hitting some keys but did not try 'ctrl+key' combinations
Should i close it or do you prefer to keep it open until docs are ready?

@ghylander
Copy link
Author

I've been reading the source code to try and add a shortcut to quickly assign flags, but I'm having some trouble

If I understood it correctly, I have to add the shortcut names to and key combinations to the ~/.labelmerc file:

  assign_flag_1: P
  assign_flag_2: N

Then, in app.py, I have to create the action(s), which I have initially written as:

        assign_flag_1 = action(
            self.tr("&Assign flag"),
            self.assignFlag(1),
            shortcuts["assign_flag_1"],
            "edit",
            self.tr("Assigns flag 1 to the current image"),
        )
        assign_flag_2 = action(
            self.tr("&Assign flag"),
            self.assignFlag(2),
            shortcuts["assign_flag_2"],
            "edit",
            self.tr("Assigns flag 2 to the current image"),
        )

And in app.py as well, I define the assignFlag function, def assignFlag(self, flag_n):, and this is where I got stuck. I've been trying to read the existing functions (such as editLabel), but I'm having trouble understanding it.

@wkentaro wkentaro changed the title Add keyboard shortcuts? Keyboard shortcuts for assigning flags Mar 1, 2022
@wkentaro wkentaro removed their assignment Mar 1, 2022
Repository owner locked and limited conversation to collaborators Jun 25, 2022
@wkentaro wkentaro converted this issue into discussion #1062 Jun 25, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants