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
c67636f4
Commit
c67636f4
authored
Jun 21, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the ability to list all the labels in a dataset.
parent
d0339e68
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
1 deletion
+41
-1
main.cpp
tools/imglab/src/main.cpp
+41
-1
No files found.
tools/imglab/src/main.cpp
View file @
c67636f4
...
...
@@ -5,6 +5,7 @@
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <dlib/cmd_line_parser.h>
#include <dlib/dir_nav.h>
...
...
@@ -95,6 +96,30 @@ void create_new_dataset (
// ----------------------------------------------------------------------------------------
void
print_all_labels
(
const
dlib
::
image_dataset_metadata
::
dataset
&
data
)
{
std
::
set
<
std
::
string
>
labels
;
for
(
unsigned
long
i
=
0
;
i
<
data
.
images
.
size
();
++
i
)
{
for
(
unsigned
long
j
=
0
;
j
<
data
.
images
[
i
].
boxes
.
size
();
++
j
)
{
labels
.
insert
(
data
.
images
[
i
].
boxes
[
j
].
label
);
}
}
for
(
std
::
set
<
std
::
string
>::
iterator
i
=
labels
.
begin
();
i
!=
labels
.
end
();
++
i
)
{
if
(
i
->
size
()
!=
0
)
{
cout
<<
*
i
<<
endl
;
}
}
}
// ----------------------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
{
try
...
...
@@ -105,6 +130,7 @@ int main(int argc, char** argv)
parser
.
add_option
(
"h"
,
"Displays this information."
);
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
(
"l"
,
"List all the labels in the given XML file."
);
parser
.
parse
(
argc
,
argv
);
...
...
@@ -126,6 +152,20 @@ int main(int argc, char** argv)
return
EXIT_SUCCESS
;
}
if
(
parser
.
option
(
"l"
))
{
if
(
parser
.
number_of_arguments
()
!=
1
)
{
cerr
<<
"The -l 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
]);
print_all_labels
(
data
);
return
EXIT_SUCCESS
;
}
if
(
parser
.
number_of_arguments
()
==
1
)
{
metadata_editor
editor
(
parser
[
0
]);
...
...
@@ -134,7 +174,7 @@ int main(int argc, char** argv)
}
catch
(
exception
&
e
)
{
c
out
<<
e
.
what
()
<<
endl
;
c
err
<<
e
.
what
()
<<
endl
;
return
EXIT_FAILURE
;
}
}
...
...
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