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
de663ec2
Commit
de663ec2
authored
Aug 05, 2013
by
Davis King
Browse files
Added the --stats option to imglab
parent
e2350cae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
tools/imglab/src/main.cpp
tools/imglab/src/main.cpp
+54
-0
No files found.
tools/imglab/src/main.cpp
View file @
de663ec2
...
@@ -95,6 +95,45 @@ void print_all_labels (
...
@@ -95,6 +95,45 @@ void print_all_labels (
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void
print_all_label_stats
(
const
dlib
::
image_dataset_metadata
::
dataset
&
data
)
{
std
::
map
<
std
::
string
,
running_stats
<
double
>
>
area_stats
,
aspect_ratio
;
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
);
area_stats
[
data
.
images
[
i
].
boxes
[
j
].
label
].
add
(
data
.
images
[
i
].
boxes
[
j
].
rect
.
area
());
aspect_ratio
[
data
.
images
[
i
].
boxes
[
j
].
label
].
add
(
data
.
images
[
i
].
boxes
[
j
].
rect
.
width
()
/
(
double
)
data
.
images
[
i
].
boxes
[
j
].
rect
.
height
());
}
}
cout
<<
"Number of different labels: "
<<
labels
.
size
()
<<
endl
<<
endl
;
for
(
std
::
set
<
std
::
string
>::
iterator
i
=
labels
.
begin
();
i
!=
labels
.
end
();
++
i
)
{
if
(
i
->
size
()
!=
0
)
{
cout
<<
"Label: "
<<
*
i
<<
endl
;
cout
<<
" number of occurrences: "
<<
area_stats
[
*
i
].
current_n
()
<<
endl
;
cout
<<
" min box area: "
<<
area_stats
[
*
i
].
min
()
<<
endl
;
cout
<<
" max box area: "
<<
area_stats
[
*
i
].
max
()
<<
endl
;
cout
<<
" mean box area: "
<<
area_stats
[
*
i
].
mean
()
<<
endl
;
cout
<<
" stddev box area: "
<<
area_stats
[
*
i
].
stddev
()
<<
endl
;
cout
<<
" mean width/height ratio: "
<<
aspect_ratio
[
*
i
].
mean
()
<<
endl
;
cout
<<
" stddev width/height ratio: "
<<
aspect_ratio
[
*
i
].
stddev
()
<<
endl
;
cout
<<
endl
;
}
}
}
// ----------------------------------------------------------------------------------------
void
rename_labels
(
void
rename_labels
(
dlib
::
image_dataset_metadata
::
dataset
&
data
,
dlib
::
image_dataset_metadata
::
dataset
&
data
,
const
std
::
string
&
from
,
const
std
::
string
&
from
,
...
@@ -132,6 +171,7 @@ int main(int argc, char** argv)
...
@@ -132,6 +171,7 @@ int main(int argc, char** argv)
parser
.
set_group_name
(
"Viewing/Editing XML files"
);
parser
.
set_group_name
(
"Viewing/Editing XML files"
);
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
(
"stats"
,
"List detailed statistics on the object labels in the given XML file."
);
parser
.
add_option
(
"rename"
,
"Rename all labels of <arg1> to <arg2>."
,
2
);
parser
.
add_option
(
"rename"
,
"Rename all labels of <arg1> to <arg2>."
,
2
);
parser
.
add_option
(
"parts"
,
"The display will allow image parts to be labeled. The set of allowable parts "
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
);
"defined in a space separated list contained in <arg>."
,
1
);
...
@@ -229,6 +269,20 @@ int main(int argc, char** argv)
...
@@ -229,6 +269,20 @@ int main(int argc, char** argv)
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
if
(
parser
.
option
(
"stats"
))
{
if
(
parser
.
number_of_arguments
()
!=
1
)
{
cerr
<<
"The --stats 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_label_stats
(
data
);
return
EXIT_SUCCESS
;
}
if
(
parser
.
option
(
"rename"
))
if
(
parser
.
option
(
"rename"
))
{
{
if
(
parser
.
number_of_arguments
()
!=
1
)
if
(
parser
.
number_of_arguments
()
!=
1
)
...
...
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