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
a280e48c
Commit
a280e48c
authored
Sep 04, 2016
by
Davis King
Browse files
Added an overload of load_image_dataset() that outputs directly to mmod_rect
instead of rectangle.
parent
eae0c2fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
0 deletions
+73
-0
dlib/data_io/load_image_dataset.h
dlib/data_io/load_image_dataset.h
+51
-0
dlib/data_io/load_image_dataset_abstract.h
dlib/data_io/load_image_dataset_abstract.h
+22
-0
No files found.
dlib/data_io/load_image_dataset.h
View file @
a280e48c
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#include <string>
#include <string>
#include <set>
#include <set>
#include "../image_processing/full_object_detection.h"
#include "../image_processing/full_object_detection.h"
#include <utility>
namespace
dlib
namespace
dlib
...
@@ -141,6 +142,56 @@ namespace dlib
...
@@ -141,6 +142,56 @@ namespace dlib
return
ignored_rects
;
return
ignored_rects
;
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
array_type
>
void
load_image_dataset
(
array_type
&
images
,
std
::
vector
<
std
::
vector
<
mmod_rect
>
>&
object_locations
,
const
image_dataset_file
&
source
)
{
images
.
clear
();
object_locations
.
clear
();
using
namespace
dlib
::
image_dataset_metadata
;
dataset
data
;
load_image_dataset_metadata
(
data
,
source
.
get_filename
());
// Set the current directory to be the one that contains the
// metadata file. We do this because the file might contain
// file paths which are relative to this folder.
locally_change_current_dir
chdir
(
get_parent_directory
(
file
(
source
.
get_filename
())));
typedef
typename
array_type
::
value_type
image_type
;
image_type
img
;
std
::
vector
<
mmod_rect
>
rects
;
for
(
unsigned
long
i
=
0
;
i
<
data
.
images
.
size
();
++
i
)
{
rects
.
clear
();
for
(
unsigned
long
j
=
0
;
j
<
data
.
images
[
i
].
boxes
.
size
();
++
j
)
{
if
(
source
.
should_load_box
(
data
.
images
[
i
].
boxes
[
j
]))
{
if
(
data
.
images
[
i
].
boxes
[
j
].
ignore
)
rects
.
push_back
(
ignored_mmod_rect
(
data
.
images
[
i
].
boxes
[
j
].
rect
));
else
rects
.
push_back
(
mmod_rect
(
data
.
images
[
i
].
boxes
[
j
].
rect
));
}
}
if
(
!
source
.
should_skip_empty_images
()
||
rects
.
size
()
!=
0
)
{
object_locations
.
push_back
(
std
::
move
(
rects
));
load_image
(
img
,
data
.
images
[
i
].
filename
);
images
.
push_back
(
std
::
move
(
img
));
}
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ******* THIS FUNCTION IS DEPRECATED, you should use another version of load_image_dataset() *******
// ******* THIS FUNCTION IS DEPRECATED, you should use another version of load_image_dataset() *******
...
...
dlib/data_io/load_image_dataset_abstract.h
View file @
a280e48c
...
@@ -181,6 +181,28 @@ namespace dlib
...
@@ -181,6 +181,28 @@ namespace dlib
(i.e. it ignores box labels and therefore loads all the boxes in the dataset)
(i.e. it ignores box labels and therefore loads all the boxes in the dataset)
!*/
!*/
template
<
typename
array_type
>
void
load_image_dataset
(
array_type
&
images
,
std
::
vector
<
std
::
vector
<
mmod_rect
>
>&
object_locations
,
const
image_dataset_file
&
source
);
/*!
requires
- array_type == An array of images. This is anything with an interface that
looks like std::vector<some generic image type> where a "generic image" is
anything that implements the generic image interface defined in
dlib/image_processing/generic_image.h.
ensures
- This function has essentially the same behavior as the above
load_image_dataset() routines, except here we out put to a vector of
mmod_rects instead of rectangles. In this case, both ignore and non-ignore
rectangles go into object_locations since mmod_rect has an ignore boolean
field that records the ignored/non-ignored state of each rectangle.
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
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