Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
a20f401e
Commit
a20f401e
authored
Feb 12, 2014
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gave imglab the ability to propagate rectangle labels between images.
parent
885a19e6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
2 deletions
+49
-2
metadata_editor.cpp
tools/imglab/src/metadata_editor.cpp
+49
-2
No files found.
tools/imglab/src/metadata_editor.cpp
View file @
a20f401e
...
@@ -208,6 +208,47 @@ on_window_resized(
...
@@ -208,6 +208,47 @@ on_window_resized(
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void
propagate_labels
(
const
std
::
string
&
label
,
dlib
::
image_dataset_metadata
::
dataset
&
data
,
unsigned
long
prev
,
unsigned
long
next
)
{
if
(
prev
==
next
||
next
>=
data
.
images
.
size
())
return
;
for
(
unsigned
long
i
=
0
;
i
<
data
.
images
[
prev
].
boxes
.
size
();
++
i
)
{
if
(
data
.
images
[
prev
].
boxes
[
i
].
label
!=
label
)
continue
;
// figure out which box in the next image matches the current one the best
const
rectangle
cur
=
data
.
images
[
prev
].
boxes
[
i
].
rect
;
double
best_overlap
=
0
;
unsigned
long
best_idx
=
0
;
for
(
unsigned
long
j
=
0
;
j
<
data
.
images
[
next
].
boxes
.
size
();
++
j
)
{
const
rectangle
next_box
=
data
.
images
[
next
].
boxes
[
j
].
rect
;
const
double
overlap
=
cur
.
intersect
(
next_box
).
area
()
/
(
double
)(
cur
+
next_box
).
area
();
if
(
overlap
>
best_overlap
)
{
best_overlap
=
overlap
;
best_idx
=
j
;
}
}
// If we found a matching rectangle in the next image and the best match doesn't
// already have a label.
if
(
best_overlap
>
0.5
&&
data
.
images
[
next
].
boxes
[
best_idx
].
label
==
""
)
{
data
.
images
[
next
].
boxes
[
best_idx
].
label
=
label
;
}
}
}
void
metadata_editor
::
void
metadata_editor
::
on_keydown
(
on_keydown
(
unsigned
long
key
,
unsigned
long
key
,
...
@@ -230,10 +271,14 @@ on_keydown (
...
@@ -230,10 +271,14 @@ on_keydown (
if
(
key
==
base_window
::
KEY_UP
)
if
(
key
==
base_window
::
KEY_UP
)
{
{
if
(
state
&
base_window
::
KBD_MOD_CONTROL
)
propagate_labels
(
display
.
get_default_overlay_rect_label
(),
metadata
,
image_pos
,
image_pos
-
1
);
select_image
(
image_pos
-
1
);
select_image
(
image_pos
-
1
);
}
}
else
if
(
key
==
base_window
::
KEY_DOWN
)
else
if
(
key
==
base_window
::
KEY_DOWN
)
{
{
if
(
state
&
base_window
::
KBD_MOD_CONTROL
)
propagate_labels
(
display
.
get_default_overlay_rect_label
(),
metadata
,
image_pos
,
image_pos
+
1
);
select_image
(
image_pos
+
1
);
select_image
(
image_pos
+
1
);
}
}
}
}
...
@@ -441,8 +486,10 @@ display_about(
...
@@ -441,8 +486,10 @@ display_about(
,
0
,
0
)
<<
endl
<<
endl
;
,
0
,
0
)
<<
endl
<<
endl
;
sout
<<
wrap_string
(
"Additionally, you can hold ctrl and then scroll the mouse wheel to zoom. A normal left click "
sout
<<
wrap_string
(
"Additionally, you can hold ctrl and then scroll the mouse wheel to zoom. A normal left click "
"and drag allows you to navigate around the image. Finally, 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."
,
0
,
0
)
<<
endl
;
"left clicking a rectangle will give it the label from the Next Label field. "
"Finally, holding ctrl and pressing the up or down keyboard keys will propagate "
"rectangle labels from one image to the next."
,
0
,
0
)
<<
endl
;
message_box
(
"About Image Labeler"
,
sout
.
str
());
message_box
(
"About Image Labeler"
,
sout
.
str
());
}
}
...
...
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