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
991cb97a
Commit
991cb97a
authored
Jun 19, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the initial file selection more flexible.
parent
adaabf84
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
2 deletions
+60
-2
main.cpp
tools/imglab/src/main.cpp
+60
-2
No files found.
tools/imglab/src/main.cpp
View file @
991cb97a
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include <dlib/cmd_line_parser.h>
#include <dlib/cmd_line_parser.h>
#include <dlib/geometry.h>
#include <dlib/geometry.h>
#include <dlib/dir_nav.h>
#include <sstream>
#include <sstream>
#include <dlib/compress_stream.h>
#include <dlib/compress_stream.h>
...
@@ -366,6 +367,38 @@ namespace dlib
...
@@ -366,6 +367,38 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
std
::
string
strip_path
(
const
std
::
string
&
str
,
const
std
::
string
&
prefix
)
{
unsigned
long
i
;
for
(
i
=
0
;
i
<
str
.
size
()
&&
i
<
prefix
.
size
();
++
i
)
{
if
(
str
[
i
]
!=
prefix
[
i
])
return
str
;
}
if
(
i
<
str
.
size
()
&&
(
str
[
i
]
==
'/'
||
str
[
i
]
==
'\\'
))
++
i
;
return
str
.
substr
(
i
);
}
// ----------------------------------------------------------------------------------------
void
make_empty_file
(
const
std
::
string
&
filename
)
{
ofstream
fout
(
filename
.
c_str
());
if
(
!
fout
)
throw
dlib
::
error
(
"ERROR: Unable to open "
+
filename
+
" for writing."
);
}
// ----------------------------------------------------------------------------------------
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
try
try
...
@@ -398,15 +431,40 @@ int main(int argc, char** argv)
...
@@ -398,15 +431,40 @@ int main(int argc, char** argv)
{
{
using
namespace
dlib
::
imglab
;
using
namespace
dlib
::
imglab
;
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
();
image_dataset_metadata
metadata
;
image_dataset_metadata
metadata
;
metadata
.
name
=
"imglab dataset"
;
metadata
.
name
=
"imglab dataset"
;
metadata
.
comment
=
"Created by imglab tool."
;
metadata
.
comment
=
"Created by imglab tool."
;
for
(
unsigned
long
i
=
0
;
i
<
parser
.
number_of_arguments
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
parser
.
number_of_arguments
();
++
i
)
{
{
metadata
.
images
.
push_back
(
image
(
parser
[
i
]));
const
string
temp
=
strip_path
(
file
(
parser
[
i
]).
full_name
(),
parent_dir
);
metadata
.
images
.
push_back
(
image
(
temp
));
}
for
(
unsigned
long
i
=
0
;
i
<
parser
.
option
(
"d"
).
count
();
++
i
)
{
unsigned
long
depth
=
0
;
if
(
parser
.
option
(
"r"
))
depth
=
30
;
std
::
vector
<
file
>
files
=
get_files_in_directory_tree
(
parser
.
option
(
"d"
).
argument
(
0
,
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
)
{
metadata
.
images
.
push_back
(
image
(
strip_path
(
files
[
j
].
full_name
(),
parent_dir
)));
}
}
}
save_image_dataset_metadata
(
metadata
,
parser
.
option
(
"c"
).
argument
()
);
save_image_dataset_metadata
(
metadata
,
filename
);
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
...
...
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