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
1fd281ff
"...sampling/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "2d8d6fbb470dc1481018baf2ce8b6faaf69f3726"
Commit
1fd281ff
authored
Jun 20, 2011
by
Davis King
Browse files
Added an option to rename labels.
parent
c67636f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
1 deletion
+41
-1
tools/imglab/src/main.cpp
tools/imglab/src/main.cpp
+41
-1
No files found.
tools/imglab/src/main.cpp
View file @
1fd281ff
...
@@ -120,6 +120,25 @@ void print_all_labels (
...
@@ -120,6 +120,25 @@ void print_all_labels (
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void
rename_labels
(
dlib
::
image_dataset_metadata
::
dataset
&
data
,
const
std
::
string
&
from
,
const
std
::
string
&
to
)
{
for
(
unsigned
long
i
=
0
;
i
<
data
.
images
.
size
();
++
i
)
{
for
(
unsigned
long
j
=
0
;
j
<
data
.
images
[
i
].
boxes
.
size
();
++
j
)
{
if
(
data
.
images
[
i
].
boxes
[
j
].
label
==
from
)
data
.
images
[
i
].
boxes
[
j
].
label
=
to
;
}
}
}
// ----------------------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
try
try
...
@@ -131,12 +150,15 @@ int main(int argc, char** argv)
...
@@ -131,12 +150,15 @@ int main(int argc, char** argv)
parser
.
add_option
(
"c"
,
"Create an XML file named <arg> listing a set of images."
,
1
);
parser
.
add_option
(
"c"
,
"Create an XML file named <arg> listing a set of images."
,
1
);
parser
.
add_option
(
"r"
,
"Search directories recursively for images."
);
parser
.
add_option
(
"r"
,
"Search directories recursively for images."
);
parser
.
add_option
(
"l"
,
"List all the labels in the given XML file."
);
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
.
parse
(
argc
,
argv
);
parser
.
parse
(
argc
,
argv
);
const
char
*
singles
[]
=
{
"h"
,
"c"
,
"r"
};
const
char
*
singles
[]
=
{
"h"
,
"c"
,
"r"
,
"l"
};
parser
.
check_one_time_options
(
singles
);
parser
.
check_one_time_options
(
singles
);
parser
.
check_sub_option
(
"c"
,
"r"
);
parser
.
check_sub_option
(
"c"
,
"r"
);
parser
.
check_incompatible_options
(
"c"
,
"l"
);
parser
.
check_incompatible_options
(
"c"
,
"rename"
);
if
(
parser
.
option
(
"h"
))
if
(
parser
.
option
(
"h"
))
{
{
...
@@ -166,6 +188,24 @@ int main(int argc, char** argv)
...
@@ -166,6 +188,24 @@ int main(int argc, char** argv)
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
if
(
parser
.
option
(
"rename"
))
{
if
(
parser
.
number_of_arguments
()
!=
1
)
{
cerr
<<
"The --rename option requires you to give one XML file on the command line."
<<
endl
;
return
EXIT_FAILURE
;
}
dlib
::
image_dataset_metadata
::
dataset
data
;
load_image_dataset_metadata
(
data
,
parser
[
0
]);
for
(
unsigned
long
i
=
0
;
i
<
parser
.
option
(
"rename"
).
count
();
++
i
)
{
rename_labels
(
data
,
parser
.
option
(
"rename"
).
argument
(
0
,
i
),
parser
.
option
(
"rename"
).
argument
(
1
,
i
));
}
save_image_dataset_metadata
(
data
,
parser
[
0
]);
return
EXIT_SUCCESS
;
}
if
(
parser
.
number_of_arguments
()
==
1
)
if
(
parser
.
number_of_arguments
()
==
1
)
{
{
metadata_editor
editor
(
parser
[
0
]);
metadata_editor
editor
(
parser
[
0
]);
...
...
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