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
66bbc515
Commit
66bbc515
authored
Jun 19, 2011
by
Davis King
Browse files
Minor code cleanup
parent
78094af4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
41 deletions
+50
-41
tools/imglab/src/main.cpp
tools/imglab/src/main.cpp
+50
-41
No files found.
tools/imglab/src/main.cpp
View file @
66bbc515
...
...
@@ -9,6 +9,7 @@
#include <dlib/dir_nav.h>
typedef
dlib
::
cmd_line_parser
<
char
>::
check_1a_c
parser_type
;
using
namespace
std
;
using
namespace
dlib
;
...
...
@@ -46,12 +47,57 @@ void make_empty_file (
// ----------------------------------------------------------------------------------------
void
create_new_dataset
(
const
parser_type
&
parser
)
{
using
namespace
dlib
::
image_dataset_metadata
;
const
std
::
string
filename
=
parser
.
option
(
"c"
).
argument
();
// make sure the file exists so we can use the get_parent_directory() command to
// figure out it's parent directory.
make_empty_file
(
filename
);
const
std
::
string
parent_dir
=
get_parent_directory
(
file
(
filename
)).
full_name
();
unsigned
long
depth
=
0
;
if
(
parser
.
option
(
"r"
))
depth
=
30
;
dataset
meta
;
meta
.
name
=
"imglab dataset"
;
meta
.
comment
=
"Created by imglab tool."
;
for
(
unsigned
long
i
=
0
;
i
<
parser
.
number_of_arguments
();
++
i
)
{
try
{
const
string
temp
=
strip_path
(
file
(
parser
[
i
]).
full_name
(),
parent_dir
);
meta
.
images
.
push_back
(
image
(
temp
));
}
catch
(
dlib
::
file
::
file_not_found
&
)
{
// then parser[i] should be a directory
std
::
vector
<
file
>
files
=
get_files_in_directory_tree
(
parser
[
i
],
match_endings
(
".png .PNG .jpeg .JPEG .jpg .JPG .bmp .BMP .dng .DNG"
),
depth
);
sort
(
files
.
begin
(),
files
.
end
());
for
(
unsigned
long
j
=
0
;
j
<
files
.
size
();
++
j
)
{
meta
.
images
.
push_back
(
image
(
strip_path
(
files
[
j
].
full_name
(),
parent_dir
)));
}
}
}
save_image_dataset_metadata
(
meta
,
filename
);
}
// ----------------------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
{
try
{
typedef
dlib
::
cmd_line_parser
<
char
>::
check_1a_c
parser_type
;
parser_type
parser
;
...
...
@@ -75,46 +121,7 @@ int main(int argc, char** argv)
if
(
parser
.
option
(
"c"
))
{
using
namespace
dlib
::
image_dataset_metadata
;
const
std
::
string
filename
=
parser
.
option
(
"c"
).
argument
();
// make sure the file exists so we can use the get_parent_directory() command to
// figure out it's parent directory.
make_empty_file
(
filename
);
const
std
::
string
parent_dir
=
get_parent_directory
(
file
(
filename
)).
full_name
();
unsigned
long
depth
=
0
;
if
(
parser
.
option
(
"r"
))
depth
=
30
;
dataset
meta
;
meta
.
name
=
"imglab dataset"
;
meta
.
comment
=
"Created by imglab tool."
;
for
(
unsigned
long
i
=
0
;
i
<
parser
.
number_of_arguments
();
++
i
)
{
try
{
const
string
temp
=
strip_path
(
file
(
parser
[
i
]).
full_name
(),
parent_dir
);
meta
.
images
.
push_back
(
image
(
temp
));
}
catch
(
dlib
::
file
::
file_not_found
&
)
{
// then parser[i] should be a directory
std
::
vector
<
file
>
files
=
get_files_in_directory_tree
(
parser
[
i
],
match_endings
(
".png .PNG .jpeg .JPEG .jpg .JPG .bmp .BMP .dng .DNG"
),
depth
);
sort
(
files
.
begin
(),
files
.
end
());
for
(
unsigned
long
j
=
0
;
j
<
files
.
size
();
++
j
)
{
meta
.
images
.
push_back
(
image
(
strip_path
(
files
[
j
].
full_name
(),
parent_dir
)));
}
}
}
save_image_dataset_metadata
(
meta
,
filename
);
create_new_dataset
(
parser
);
return
EXIT_SUCCESS
;
}
...
...
@@ -132,3 +139,5 @@ int main(int argc, char** argv)
}
}
// ----------------------------------------------------------------------------------------
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