Skip to content
Snippets Groups Projects
Commit 3a39f8d4 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Merge branch 'decoration-button' into 'master'

Decoration button

See merge request !10
parents 5d3c2af3 2e7848a3
Branches
Tags
1 merge request!10Decoration button
Pipeline #26584 passed
...@@ -37,7 +37,7 @@ Keyboard shortcuts ...@@ -37,7 +37,7 @@ Keyboard shortcuts
object object
``i | <Shift>-Zero | <Shift>-KP_Zero`` ``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 point
``d | <Del>`` ``d | <Del>``
...@@ -68,6 +68,18 @@ Keyboard shortcuts ...@@ -68,6 +68,18 @@ Keyboard shortcuts
``p`` ``p``
moves to the previous image 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`` ``s``
saves current annotations saves current annotations
...@@ -203,7 +215,6 @@ class AnnotatorApp(tkinter.Tk): ...@@ -203,7 +215,6 @@ class AnnotatorApp(tkinter.Tk):
# setup internal variables # setup internal variables
self.curr_annotation = None #the currently annotated object self.curr_annotation = None #the currently annotated object
self.annotation = [] #annotations existing on the current image self.annotation = [] #annotations existing on the current image
self.filter = False
# builds the application interface - buttons, frames and the image canvas # builds the application interface - buttons, frames and the image canvas
self.frames = {} self.frames = {}
...@@ -290,19 +301,29 @@ class AnnotatorApp(tkinter.Tk): ...@@ -290,19 +301,29 @@ class AnnotatorApp(tkinter.Tk):
text='Displays the number of annotated points in the current ' \ text='Displays the number of annotated points in the current ' \
'object being annotated (highlit)') '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'], f = self.frames['filters'] = tkinter.ttk.LabelFrame(self.frames['left'],
text="Filters") text="Filters")
f.grid(row=2, sticky=tkinter.NSEW) f.grid(row=2, sticky=tkinter.NSEW)
v = self.variables['adaheq'] = tkinter.IntVar() v = self.variables['adaheq'] = tkinter.IntVar()
v.set(0) v.set(0)
b = self.buttons['adaheq'] = tkinter.ttk.Checkbutton(f, b = self.buttons['adaheq'] = tkinter.ttk.Checkbutton(f, text="CLAHE",
text="CLAHE", command=self.toggle_filter, variable=v) variable=v, command=self.toggle_filter)
b.grid(row=0, columnspan=3, sticky=tkinter.W) b.grid(row=0, columnspan=3, sticky=tkinter.W)
self.tooltips['adaheq'] = widgets.Tooltip(b, self.tooltips['adaheq'] = widgets.Tooltip(b,
text='Applies Contrast Limited Adaptive Histogram Equalization ' \ text='Applies Contrast Limited Adaptive Histogram Equalization ' \
'(CLAHE) to the displayed image. You can finetune parameters ' \ '(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 = self.variables['adaheq-kernel-size'] = tkinter.IntVar()
v.set(18) v.set(18)
...@@ -373,7 +394,7 @@ class AnnotatorApp(tkinter.Tk): ...@@ -373,7 +394,7 @@ class AnnotatorApp(tkinter.Tk):
# setup filter function # setup filter function
filter_function = None filter_function = None
if self.filter: if self.variables['adaheq'].get():
def _clahe(img, kernel, clip): def _clahe(img, kernel, clip):
nimg = numpy.array(img) nimg = numpy.array(img)
...@@ -467,6 +488,12 @@ class AnnotatorApp(tkinter.Tk): ...@@ -467,6 +488,12 @@ class AnnotatorApp(tkinter.Tk):
# sets the zoom level # sets the zoom level
self.variables['zoom'].set('%g' % self.zoom) 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): def save(self, *args, **kwargs):
"""Action executed when we need to save the current annotations""" """Action executed when we need to save the current annotations"""
...@@ -608,17 +635,28 @@ class AnnotatorApp(tkinter.Tk): ...@@ -608,17 +635,28 @@ class AnnotatorApp(tkinter.Tk):
self.create_new_annotation() # adds a new base annotation object 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""" """Shows all elements"""
logger.debug('Showing all...') logger.debug('Showing all...')
self.variables['decorations'].set(1)
for k in self.annotation: k.show_decoration() for k in self.annotation: k.show_decoration()
def on_hide_all(self, event): def on_hide_all(self, event=None):
"""Hides all elements""" """Hides all elements"""
logger.debug('Hiding all...') logger.debug('Hiding all...')
self.variables['decorations'].set(0)
for k in self.annotation: k.hide_decoration() for k in self.annotation: k.hide_decoration()
...@@ -680,15 +718,24 @@ class AnnotatorApp(tkinter.Tk): ...@@ -680,15 +718,24 @@ class AnnotatorApp(tkinter.Tk):
self._update_status() self._update_status()
def toggle_filter(self, event=None): def toggle_filter(self, *args):
"""Togglers filter/no-filter on the displayed image""" """Togglers filter/no-filter on the displayed image"""
if self.filter: self._rebuild_interface()
self.filter = False
self._rebuild_interface()
else: def turn_filter_on(self, event=None):
self.filter = True """Turns filtering on"""
self._rebuild_interface()
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): def _add_bindings(self):
...@@ -713,6 +760,10 @@ class AnnotatorApp(tkinter.Tk): ...@@ -713,6 +760,10 @@ class AnnotatorApp(tkinter.Tk):
self.bind("<Button-3>", self.remove_point_from_active_annotation) self.bind("<Button-3>", self.remove_point_from_active_annotation)
self.bind("c", self.create_new_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_next_annotation)
self.bind("O", self.activate_previous_annotation) self.bind("O", self.activate_previous_annotation)
self.bind("m", self.toggle_active_annotation_mode) self.bind("m", self.toggle_active_annotation_mode)
......
...@@ -45,19 +45,50 @@ and, finally *Help*. The *Objects* section show how many objects have been ...@@ -45,19 +45,50 @@ and, finally *Help*. The *Objects* section show how many objects have been
annotated on the image. You may annotate any number of objects in each image. annotated on the image. You may annotate any number of objects in each image.
Each annotation is just a set of points clicked on the screen. The sequence in Each annotation is just a set of points clicked on the screen. The sequence in
which the points are clicked is preserved. By pressing the ``ALT`` key on your which the points are clicked is preserved. By pressing the ``ALT`` key on your
keyboard (any of the two normally available), the application draws on the keyboard (any of the two normally available), the application *temporarily*
screen either a line or polygon connecting such dots so you can better draws on the screen either a line or polygon connecting such dots so you can
visualize annotated objects. The choice between drawing a line or polygon on better visualize annotated objects. The choice between drawing a line or
connecting annotated objects can be selected using the button that says *mode* polygon on connecting annotated objects can be selected using the button that
on the left pane. You may optionally press the keyboard shortcut ``m`` to says *mode* on the left pane. You may optionally press the keyboard shortcut
switch modes. Notice that lines and polygons drawn at the screen are drawn ``m`` to switch modes. Notice that lines and polygons drawn at the screen are
only for informational purposes - such information is not recorded to the drawn only for informational purposes - such information is not recorded to the
output files, which only preserve points and the order in which points were output files, which only preserve points and the order in which points were
annotated. annotated.
.. tip::
By using the check-button "Decorations" on the left pane, you may switch ON
or OFF the drawing of line/polygon connectors on the screen. The keyboard
shortcuts ``t`` and ``T`` can be used to switch ON or OFF this functionality
as well.
To annotate the image, click on the image using a mouse or trackpad. If using To annotate the image, click on the image using a mouse or trackpad. If using
a mouse, use its left button to add a key point to the current object being a mouse, use its left button to append a key point to the current object being
annotated. You may switch between the objects annotated using the keyboard annotated. Alternatively, use the ``a`` keyboard key to append a new keypoint,
under the pointer cursor, to the active annotation set. When you append a new
keypoint, it becomes automatically the last keypoint on the set. You may also
*insert* a new keypoint **before** another existing keypoint (notice order is
an important factor here). If you wish to insert a new keypoint **before** an
existing one, in the middle of a sequence, move the cursor so it highlights the
closest keypoint that will come **after** the keypoint you wish to insert.
Once you have it highlit, press ``i`` or use the ``SHIFT`` key combined with a
left-mouse button or trackpad click.
.. warning::
Currently, keypoint insertion only works this way. If you wish to insert a
keypoint such that it would be closer to an existing keypoint that must come
before the new entry, highlight the keypoint that comes immediately after,
insert the keypoint using the keyboard, mouse or trackpad and then move it
to the desired location.
To better visualize the order of keypoints, enable drawing of
*Decorations* by either click the check-button on the left pane or pushing
the keyboard key ``t``.
You may switch between the objects annotated using the keyboard
shortcuts ``o`` (next) or ``O`` (previous), or use the pane on the left. If shortcuts ``o`` (next) or ``O`` (previous), or use the pane on the left. If
you'd like to annotate a new object on the current image, click on ``create`` you'd like to annotate a new object on the current image, click on ``create``
or use the keyboard shortcut ``c``. To delete an object use the keyboard or use the keyboard shortcut ``c``. To delete an object use the keyboard
...@@ -81,11 +112,11 @@ the left pane. Once an annotation set is highlit (in yellow), a single ...@@ -81,11 +112,11 @@ the left pane. Once an annotation set is highlit (in yellow), a single
keypoint will be indicated in red - that is the *active* keypoint. Keyboard keypoint will be indicated in red - that is the *active* keypoint. Keyboard
commands apply only to the active keypoint. To delete a single keypoint, use commands apply only to the active keypoint. To delete a single keypoint, use
the ``d`` keyboard shortcut, or the right-button of your mouse. To do so, the ``d`` keyboard shortcut, or the right-button of your mouse. To do so,
first select the keypoint by simply approaching it with your mouse pointer, first select the keypoint by simply approaching it with your pointer cursor,
*without* clicking. Once you get close enough, the point of interest becomes *without* clicking. Once you get close enough, the point of interest becomes
red. Once the point is red, you may delete it using the ``d`` keyboard red. Once the point is red, you may delete it using the ``d`` keyboard
shortcut. You may also move the point using the arrow keys on your keyboard. shortcut. You may also move the point using the arrow keys on your keyboard.
The point from the current active set closest to the pointer is always the The point from the current active set closest to the cursor is always the
active one. active one.
.. _annotate-objects: .. _annotate-objects:
...@@ -202,7 +233,8 @@ Adaptive Histogram Equalization using ...@@ -202,7 +233,8 @@ Adaptive Histogram Equalization using
size and clipping parameters using the text boxes under the filter heading. If size and clipping parameters using the text boxes under the filter heading. If
the filter is already on, and you wish to change its parameters, then click it the filter is already on, and you wish to change its parameters, then click it
off and then on back again. Once the filter is active, it will remain active off and then on back again. Once the filter is active, it will remain active
for the next images as well. for the next images as well. Alternatively use the keyboard shortcuts ``f`` to
toggle the filter ON or ``F`` to toggle it off.
Further help Further help
......
doc/img/annotate-main.png

531 KiB | W: | H:

doc/img/annotate-main.png

571 KiB | W: | H:

doc/img/annotate-main.png
doc/img/annotate-main.png
doc/img/annotate-main.png
doc/img/annotate-main.png
  • 2-up
  • Swipe
  • Onion skin
doc/img/annotate-objects.png

530 KiB | W: | H:

doc/img/annotate-objects.png

573 KiB | W: | H:

doc/img/annotate-objects.png
doc/img/annotate-objects.png
doc/img/annotate-objects.png
doc/img/annotate-objects.png
  • 2-up
  • Swipe
  • Onion skin
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment