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
32d62110
Commit
32d62110
authored
Jun 11, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made imglab assign a random color to boxes with labels.
parent
1a35d365
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
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;
...
@@ -17,6 +17,27 @@ using namespace dlib;
extern
const
char
*
VERSION
;
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
::
metadata_editor
::
...
@@ -407,7 +428,7 @@ std::vector<dlib::image_display::overlay_rect> get_overlays (
...
@@ -407,7 +428,7 @@ std::vector<dlib::image_display::overlay_rect> get_overlays (
temp
[
i
].
label
=
data
.
boxes
[
i
].
label
;
temp
[
i
].
label
=
data
.
boxes
[
i
].
label
;
temp
[
i
].
parts
=
data
.
boxes
[
i
].
parts
;
temp
[
i
].
parts
=
data
.
boxes
[
i
].
parts
;
temp
[
i
].
crossed_out
=
data
.
boxes
[
i
].
ignore
;
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
;
return
temp
;
}
}
...
@@ -519,6 +540,7 @@ on_overlay_label_changed(
...
@@ -519,6 +540,7 @@ on_overlay_label_changed(
)
)
{
{
display
.
set_default_overlay_rect_label
(
trim
(
overlay_label
.
text
()));
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(
...
@@ -530,6 +552,7 @@ on_overlay_rect_selected(
{
{
overlay_label
.
set_text
(
orect
.
label
);
overlay_label
.
set_text
(
orect
.
label
);
display
.
set_default_overlay_rect_label
(
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