Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
95887df0
Commit
95887df0
authored
Jul 12, 2015
by
Davis King
Browse files
Gave imglab the ability to jump to a specific image via a keyboard command.
parent
a3c98799
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
3 deletions
+33
-3
tools/imglab/src/metadata_editor.cpp
tools/imglab/src/metadata_editor.cpp
+30
-3
tools/imglab/src/metadata_editor.h
tools/imglab/src/metadata_editor.h
+3
-0
No files found.
tools/imglab/src/metadata_editor.cpp
View file @
95887df0
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include <dlib/array2d.h>
#include <dlib/array2d.h>
#include <dlib/pixel.h>
#include <dlib/pixel.h>
#include <sstream>
#include <sstream>
#include <ctime>
using
namespace
std
;
using
namespace
std
;
using
namespace
dlib
;
using
namespace
dlib
;
...
@@ -27,7 +28,9 @@ metadata_editor(
...
@@ -27,7 +28,9 @@ metadata_editor(
image_pos
(
0
),
image_pos
(
0
),
display
(
*
this
),
display
(
*
this
),
overlay_label_name
(
*
this
),
overlay_label_name
(
*
this
),
overlay_label
(
*
this
)
overlay_label
(
*
this
),
keyboard_jump_pos
(
0
),
last_keyboard_jump_pos_update
(
0
)
{
{
file
metadata_file
(
filename_
);
file
metadata_file
(
filename_
);
filename
=
metadata_file
.
full_name
();
filename
=
metadata_file
.
full_name
();
...
@@ -290,6 +293,29 @@ on_keydown (
...
@@ -290,6 +293,29 @@ on_keydown (
overlay_label
.
select_all_text
();
overlay_label
.
select_all_text
();
}
}
// If the user types a number then jump to that image.
if
(
'0'
<=
key
&&
key
<=
'9'
&&
metadata
.
images
.
size
()
!=
0
&&
!
overlay_label
.
has_input_focus
())
{
time_t
curtime
=
time
(
0
);
// If it's been a while since the user typed numbers then forget the last jump
// position and start accumulating numbers over again.
if
(
curtime
-
last_keyboard_jump_pos_update
>=
2
)
keyboard_jump_pos
=
0
;
last_keyboard_jump_pos_update
=
curtime
;
keyboard_jump_pos
*=
10
;
keyboard_jump_pos
+=
key
-
'0'
;
if
(
keyboard_jump_pos
>=
metadata
.
images
.
size
())
keyboard_jump_pos
=
metadata
.
images
.
size
()
-
1
;
image_pos
=
keyboard_jump_pos
;
select_image
(
image_pos
);
}
else
{
last_keyboard_jump_pos_update
=
0
;
}
return
;
return
;
}
}
...
@@ -536,8 +562,9 @@ display_about(
...
@@ -536,8 +562,9 @@ display_about(
"and drag allows you to navigate around the image. Holding ctrl and "
"and drag allows you to navigate around the image. Holding ctrl and "
"left clicking a rectangle will give it the label from the Next Label field. "
"left clicking a rectangle will give it the label from the Next Label field. "
"Holding shift + right click and then dragging allows you to move things around. "
"Holding shift + right click and then dragging allows you to move things around. "
"Finally, holding ctrl and pressing the up or down keyboard keys will propagate "
"Holding ctrl and pressing the up or down keyboard keys will propagate "
"rectangle labels from one image to the next and also skip empty images."
,
0
,
0
)
<<
endl
;
"rectangle labels from one image to the next and also skip empty images. "
"Finally, typing a number on the keyboard will jump you to a specific image."
,
0
,
0
)
<<
endl
;
message_box
(
"About Image Labeler"
,
sout
.
str
());
message_box
(
"About Image Labeler"
,
sout
.
str
());
}
}
...
...
tools/imglab/src/metadata_editor.h
View file @
95887df0
...
@@ -55,6 +55,9 @@ private:
...
@@ -55,6 +55,9 @@ private:
dlib
::
image_display
display
;
dlib
::
image_display
display
;
dlib
::
label
overlay_label_name
;
dlib
::
label
overlay_label_name
;
dlib
::
text_field
overlay_label
;
dlib
::
text_field
overlay_label
;
unsigned
long
keyboard_jump_pos
;
time_t
last_keyboard_jump_pos_update
;
};
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment