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
32d62110
Commit
32d62110
authored
Jun 10, 2016
by
Davis King
Browse files
Made imglab assign a random color to boxes with labels.
parent
1a35d365
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
tools/imglab/src/metadata_editor.cpp
tools/imglab/src/metadata_editor.cpp
+24
-1
No files found.
tools/imglab/src/metadata_editor.cpp
View file @
32d62110
...
...
@@ -17,6 +17,27 @@ using namespace dlib;
extern
const
char
*
VERSION
;
rgb_alpha_pixel
string_to_color
(
const
std
::
string
&
str
)
{
if
(
str
.
size
()
==
0
)
{
return
rgb_alpha_pixel
(
255
,
0
,
0
,
255
);
}
else
{
// make up a random color based on the string label.
hsi_pixel
pix
;
pix
.
h
=
static_cast
<
unsigned
char
>
(
dlib
::
hash
(
str
)
&
0xFF
);
pix
.
s
=
255
;
pix
.
i
=
150
;
rgb_alpha_pixel
result
;
assign_pixel
(
result
,
pix
);
return
result
;
}
}
// ----------------------------------------------------------------------------------------
metadata_editor
::
...
...
@@ -407,7 +428,7 @@ std::vector<dlib::image_display::overlay_rect> get_overlays (
temp
[
i
].
label
=
data
.
boxes
[
i
].
label
;
temp
[
i
].
parts
=
data
.
boxes
[
i
].
parts
;
temp
[
i
].
crossed_out
=
data
.
boxes
[
i
].
ignore
;
assign_pixel
(
temp
[
i
].
color
,
rgb_pixel
(
255
,
0
,
0
)
);
temp
[
i
].
color
=
string_to_color
(
data
.
boxes
[
i
].
label
);
}
return
temp
;
}
...
...
@@ -519,6 +540,7 @@ on_overlay_label_changed(
)
{
display
.
set_default_overlay_rect_label
(
trim
(
overlay_label
.
text
()));
display
.
set_default_overlay_rect_color
(
string_to_color
(
trim
(
overlay_label
.
text
())));
}
// ----------------------------------------------------------------------------------------
...
...
@@ -530,6 +552,7 @@ on_overlay_rect_selected(
{
overlay_label
.
set_text
(
orect
.
label
);
display
.
set_default_overlay_rect_label
(
orect
.
label
);
display
.
set_default_overlay_rect_color
(
string_to_color
(
orect
.
label
));
}
// ----------------------------------------------------------------------------------------
...
...
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