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
a92b875f
Commit
a92b875f
authored
Sep 01, 2012
by
Davis King
Browse files
made imglab work with image parts.
parent
78006f27
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
tools/imglab/src/main.cpp
tools/imglab/src/main.cpp
+16
-2
tools/imglab/src/metadata_editor.cpp
tools/imglab/src/metadata_editor.cpp
+18
-0
tools/imglab/src/metadata_editor.h
tools/imglab/src/metadata_editor.h
+4
-0
No files found.
tools/imglab/src/main.cpp
View file @
a92b875f
#include "dlib/data_io.h"
#include "dlib/string.h"
#include "metadata_editor.h"
#include "convert_pascal_xml.h"
#include "convert_pascal_v1.h"
...
...
@@ -13,7 +14,7 @@
#include <dlib/dir_nav.h>
const
char
*
VERSION
=
"0.
3
"
;
const
char
*
VERSION
=
"0.
4
"
;
...
...
@@ -125,20 +126,25 @@ int main(int argc, char** argv)
parser
.
add_option
(
"l"
,
"List all the labels in the given XML file."
);
parser
.
add_option
(
"rename"
,
"Rename all labels of <arg1> to <arg2>."
,
2
);
parser
.
add_option
(
"v"
,
"Display version."
);
parser
.
add_option
(
"parts"
,
"The display will allow image parts to be labeled. The set of allowable parts "
"defined in a space separated list contained in <arg>."
,
1
);
parser
.
add_option
(
"convert"
,
"Convert foreign image Annotations from <arg> format to the imglab format. "
"Supported formats: pascal-xml, pascal-v1, idl."
,
1
);
parser
.
parse
(
argc
,
argv
);
const
char
*
singles
[]
=
{
"h"
,
"c"
,
"r"
,
"l"
,
"convert"
};
const
char
*
singles
[]
=
{
"h"
,
"c"
,
"r"
,
"l"
,
"convert"
,
"parts"
};
parser
.
check_one_time_options
(
singles
);
const
char
*
c_sub_ops
[]
=
{
"r"
,
"convert"
};
parser
.
check_sub_options
(
"c"
,
c_sub_ops
);
parser
.
check_incompatible_options
(
"c"
,
"l"
);
parser
.
check_incompatible_options
(
"c"
,
"rename"
);
parser
.
check_incompatible_options
(
"c"
,
"parts"
);
parser
.
check_incompatible_options
(
"l"
,
"rename"
);
parser
.
check_incompatible_options
(
"l"
,
"parts"
);
parser
.
check_incompatible_options
(
"convert"
,
"l"
);
parser
.
check_incompatible_options
(
"convert"
,
"rename"
);
parser
.
check_incompatible_options
(
"convert"
,
"parts"
);
const
char
*
convert_args
[]
=
{
"pascal-xml"
,
"pascal-v1"
,
"idl"
};
parser
.
check_option_arg_range
(
"convert"
,
convert_args
);
...
...
@@ -212,6 +218,14 @@ int main(int argc, char** argv)
if
(
parser
.
number_of_arguments
()
==
1
)
{
metadata_editor
editor
(
parser
[
0
]);
if
(
parser
.
option
(
"parts"
))
{
std
::
vector
<
string
>
parts
=
split
(
parser
.
option
(
"parts"
).
argument
());
for
(
unsigned
long
i
=
0
;
i
<
parts
.
size
();
++
i
)
{
editor
.
add_labelable_part_name
(
parts
[
i
]);
}
}
editor
.
wait_until_closed
();
}
}
...
...
tools/imglab/src/metadata_editor.cpp
View file @
a92b875f
...
...
@@ -99,6 +99,16 @@ metadata_editor::
// ----------------------------------------------------------------------------------------
void
metadata_editor
::
add_labelable_part_name
(
const
std
::
string
&
name
)
{
display
.
add_labelable_part_name
(
name
);
}
// ----------------------------------------------------------------------------------------
void
metadata_editor
::
file_save
()
{
...
...
@@ -279,6 +289,7 @@ std::vector<dlib::image_display::overlay_rect> get_overlays (
{
temp
[
i
].
rect
=
data
.
boxes
[
i
].
rect
;
temp
[
i
].
label
=
data
.
boxes
[
i
].
label
;
temp
[
i
].
parts
=
data
.
boxes
[
i
].
parts
;
assign_pixel
(
temp
[
i
].
color
,
rgb_pixel
(
255
,
0
,
0
));
}
return
temp
;
...
...
@@ -376,6 +387,7 @@ on_overlay_rects_changed(
box
temp
;
temp
.
label
=
rects
[
i
].
label
;
temp
.
rect
=
rects
[
i
].
rect
;
temp
.
parts
=
rects
[
i
].
parts
;
boxes
.
push_back
(
temp
);
}
}
...
...
@@ -417,6 +429,12 @@ display_about(
"a rectangle selects it and the delete key removes it."
,
0
,
0
)
<<
endl
<<
endl
;
sout
<<
wrap_string
(
"It is also possible to label object parts by selecting a rectangle and "
"then right clicking. A popup menu will appear and you can select a part label. "
"Note that you must define the allowable part labels by giving --parts on the "
"command line. An example would be '--parts
\"
leye reye nose mouth
\"
'."
,
0
,
0
)
<<
endl
<<
endl
;
sout
<<
wrap_string
(
"Finally, hold ctrl and scroll the mouse wheel to zoom while normal left click "
"and drag allows you to navigate around the image."
,
0
,
0
)
<<
endl
;
...
...
tools/imglab/src/metadata_editor.h
View file @
a92b875f
...
...
@@ -17,6 +17,10 @@ public:
~
metadata_editor
();
void
add_labelable_part_name
(
const
std
::
string
&
name
);
private:
void
file_save
();
...
...
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