Commit 88e4625c authored by André Anjos's avatar André Anjos 💬

[gui] Allow the user to show decorations permanently via toggle switch and button

parent 5d3c2af3
Pipeline #26580 passed with stage
in 11 minutes and 26 seconds
......@@ -37,7 +37,7 @@ Keyboard shortcuts
object
``i | <Shift>-Zero | <Shift>-KP_Zero``
inserts new point on a currently active object, before the current active
inserts new point on a currently active object, **before** the current active
point
``d | <Del>``
......@@ -68,6 +68,18 @@ Keyboard shortcuts
``p``
moves to the previous image
``t``
turns-on keypoint decoration (lines or polygon depending on current mode)
``T``
turns-off keypoint decoration
``f``
turns-on image filtering
``F``
turns-off image filtering
``s``
saves current annotations
......@@ -203,7 +215,6 @@ class AnnotatorApp(tkinter.Tk):
# setup internal variables
self.curr_annotation = None #the currently annotated object
self.annotation = [] #annotations existing on the current image
self.filter = False
# builds the application interface - buttons, frames and the image canvas
self.frames = {}
......@@ -290,19 +301,29 @@ class AnnotatorApp(tkinter.Tk):
text='Displays the number of annotated points in the current ' \
'object being annotated (highlit)')
v = self.variables['decorations'] = tkinter.IntVar()
v.set(0)
b = self.buttons['decorations'] = tkinter.ttk.Checkbutton(f,
text="Decorations", variable=v, command=self.toggle_decorations)
b.grid(row=5, columnspan=2, sticky=tkinter.NSEW)
self.tooltips['decorations'] = widgets.Tooltip(b,
text='Shows line connectors or polygon fills depending on the ' \
'current drawing mode (keyboard: t/T - on/off)')
f = self.frames['filters'] = tkinter.ttk.LabelFrame(self.frames['left'],
text="Filters")
f.grid(row=2, sticky=tkinter.NSEW)
v = self.variables['adaheq'] = tkinter.IntVar()
v.set(0)
b = self.buttons['adaheq'] = tkinter.ttk.Checkbutton(f,
text="CLAHE", command=self.toggle_filter, variable=v)
b = self.buttons['adaheq'] = tkinter.ttk.Checkbutton(f, text="CLAHE",
variable=v, command=self.toggle_filter)
b.grid(row=0, columnspan=3, sticky=tkinter.W)
self.tooltips['adaheq'] = widgets.Tooltip(b,
text='Applies Contrast Limited Adaptive Histogram Equalization ' \
'(CLAHE) to the displayed image. You can finetune parameters ' \
'on the text boxes below')
'on the text boxes below (keyboard: f/F - on/off)')
v = self.variables['adaheq-kernel-size'] = tkinter.IntVar()
v.set(18)
......@@ -373,7 +394,7 @@ class AnnotatorApp(tkinter.Tk):
# setup filter function
filter_function = None
if self.filter:
if self.variables['adaheq'].get():
def _clahe(img, kernel, clip):
nimg = numpy.array(img)
......@@ -467,6 +488,12 @@ class AnnotatorApp(tkinter.Tk):
# sets the zoom level
self.variables['zoom'].set('%g' % self.zoom)
# if decorations are to be shown, set them
if self.variables['decorations'].get():
self.on_show_all()
else:
self.on_hide_all()
def save(self, *args, **kwargs):
"""Action executed when we need to save the current annotations"""
......@@ -608,17 +635,28 @@ class AnnotatorApp(tkinter.Tk):
self.create_new_annotation() # adds a new base annotation object
def on_show_all(self, event):
def toggle_decorations(self, *args):
"""Toggles current decoration status"""
if self.variables['decorations'].get():
self.on_show_all()
else:
self.on_hide_all()
def on_show_all(self, event=None):
"""Shows all elements"""
logger.debug('Showing all...')
self.variables['decorations'].set(1)
for k in self.annotation: k.show_decoration()
def on_hide_all(self, event):
def on_hide_all(self, event=None):
"""Hides all elements"""
logger.debug('Hiding all...')
self.variables['decorations'].set(0)
for k in self.annotation: k.hide_decoration()
......@@ -680,15 +718,24 @@ class AnnotatorApp(tkinter.Tk):
self._update_status()
def toggle_filter(self, event=None):
def toggle_filter(self, *args):
"""Togglers filter/no-filter on the displayed image"""
if self.filter:
self.filter = False
self._rebuild_interface()
else:
self.filter = True
self._rebuild_interface()
self._rebuild_interface()
def turn_filter_on(self, event=None):
"""Turns filtering on"""
self.variables['adaheq'].set(1)
self._rebuild_interface()
def turn_filter_off(self, event=None):
"""Turns filtering off"""
self.variables['adaheq'].set(0)
self._rebuild_interface()
def _add_bindings(self):
......@@ -713,6 +760,10 @@ class AnnotatorApp(tkinter.Tk):
self.bind("<Button-3>", self.remove_point_from_active_annotation)
self.bind("c", self.create_new_annotation)
self.bind("f", self.turn_filter_on)
self.bind("F", self.turn_filter_off)
self.bind("t", self.on_show_all)
self.bind("T", self.on_hide_all)
self.bind("o", self.activate_next_annotation)
self.bind("O", self.activate_previous_annotation)
self.bind("m", self.toggle_active_annotation_mode)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment