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
1df8c441
Commit
1df8c441
authored
Nov 21, 2013
by
Davis King
Browse files
Upgraded load_image_dataset() so that it returns the list of ignored
rectangles.
parent
647285e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
13 deletions
+29
-13
dlib/data_io/load_image_dataset.h
dlib/data_io/load_image_dataset.h
+13
-5
dlib/data_io/load_image_dataset_abstract.h
dlib/data_io/load_image_dataset_abstract.h
+16
-8
No files found.
dlib/data_io/load_image_dataset.h
View file @
1df8c441
...
@@ -24,7 +24,7 @@ namespace dlib
...
@@ -24,7 +24,7 @@ namespace dlib
typename
image_type
,
typename
image_type
,
typename
MM
typename
MM
>
>
void
load_image_dataset
(
std
::
vector
<
std
::
vector
<
rectangle
>
>
load_image_dataset
(
array
<
image_type
,
MM
>&
images
,
array
<
image_type
,
MM
>&
images
,
std
::
vector
<
std
::
vector
<
rectangle
>
>&
object_locations
,
std
::
vector
<
std
::
vector
<
rectangle
>
>&
object_locations
,
const
std
::
string
&
filename
,
const
std
::
string
&
filename
,
...
@@ -36,6 +36,8 @@ namespace dlib
...
@@ -36,6 +36,8 @@ namespace dlib
object_locations
.
clear
();
object_locations
.
clear
();
const
std
::
string
old_working_dir
=
get_current_dir
();
const
std
::
string
old_working_dir
=
get_current_dir
();
std
::
vector
<
std
::
vector
<
rectangle
>
>
ignored_rects
;
// Set the current directory to be the one that contains the
// Set the current directory to be the one that contains the
// metadata file. We do this because the file might contain
// metadata file. We do this because the file might contain
// file paths which are relative to this folder.
// file paths which are relative to this folder.
...
@@ -49,27 +51,33 @@ namespace dlib
...
@@ -49,27 +51,33 @@ namespace dlib
load_image_dataset_metadata
(
data
,
filename
);
load_image_dataset_metadata
(
data
,
filename
);
image_type
img
;
image_type
img
;
std
::
vector
<
rectangle
>
rects
;
std
::
vector
<
rectangle
>
rects
,
ignored
;
for
(
unsigned
long
i
=
0
;
i
<
data
.
images
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
data
.
images
.
size
();
++
i
)
{
{
rects
.
clear
();
rects
.
clear
();
ignored
.
clear
();
for
(
unsigned
long
j
=
0
;
j
<
data
.
images
[
i
].
boxes
.
size
();
++
j
)
for
(
unsigned
long
j
=
0
;
j
<
data
.
images
[
i
].
boxes
.
size
();
++
j
)
{
{
if
(
label
.
size
()
==
0
||
data
.
images
[
i
].
boxes
[
j
].
label
==
label
)
if
(
label
.
size
()
==
0
||
data
.
images
[
i
].
boxes
[
j
].
label
==
label
)
{
{
rects
.
push_back
(
data
.
images
[
i
].
boxes
[
j
].
rect
);
if
(
data
.
images
[
i
].
boxes
[
j
].
ignore
)
ignored
.
push_back
(
data
.
images
[
i
].
boxes
[
j
].
rect
);
else
rects
.
push_back
(
data
.
images
[
i
].
boxes
[
j
].
rect
);
}
}
}
}
if
(
!
skip_empty_images
||
rects
.
size
()
!=
0
)
if
(
!
skip_empty_images
||
rects
.
size
()
!=
0
)
{
{
object_locations
.
push_back
(
rects
);
object_locations
.
push_back
(
rects
);
ignored_rects
.
push_back
(
ignored
);
load_image
(
img
,
data
.
images
[
i
].
filename
);
load_image
(
img
,
data
.
images
[
i
].
filename
);
images
.
push_back
(
img
);
images
.
push_back
(
img
);
}
}
}
}
set_current_dir
(
old_working_dir
);
set_current_dir
(
old_working_dir
);
return
ignored_rects
;
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -78,13 +86,13 @@ namespace dlib
...
@@ -78,13 +86,13 @@ namespace dlib
typename
image_type
,
typename
image_type
,
typename
MM
typename
MM
>
>
void
load_image_dataset
(
std
::
vector
<
std
::
vector
<
rectangle
>
>
load_image_dataset
(
array
<
image_type
,
MM
>&
images
,
array
<
image_type
,
MM
>&
images
,
std
::
vector
<
std
::
vector
<
rectangle
>
>&
object_locations
,
std
::
vector
<
std
::
vector
<
rectangle
>
>&
object_locations
,
const
std
::
string
&
filename
const
std
::
string
&
filename
)
)
{
{
load_image_dataset
(
images
,
object_locations
,
filename
,
""
);
return
load_image_dataset
(
images
,
object_locations
,
filename
,
""
);
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/data_io/load_image_dataset_abstract.h
View file @
1df8c441
...
@@ -19,7 +19,7 @@ namespace dlib
...
@@ -19,7 +19,7 @@ namespace dlib
typename
image_type
,
typename
image_type
,
typename
MM
typename
MM
>
>
void
load_image_dataset
(
std
::
vector
<
std
::
vector
<
rectangle
>
>
load_image_dataset
(
array
<
image_type
,
MM
>&
images
,
array
<
image_type
,
MM
>&
images
,
std
::
vector
<
std
::
vector
<
rectangle
>
>&
object_locations
,
std
::
vector
<
std
::
vector
<
rectangle
>
>&
object_locations
,
const
std
::
string
&
filename
,
const
std
::
string
&
filename
,
...
@@ -39,17 +39,25 @@ namespace dlib
...
@@ -39,17 +39,25 @@ namespace dlib
- #images.size() == #object_locations.size()
- #images.size() == #object_locations.size()
- This routine is capable of loading any image format which can be read by the
- This routine is capable of loading any image format which can be read by the
load_image() routine.
load_image() routine.
- let IGNORED_RECTS denote the vector returned from this function.
- IGNORED_RECTS.size() == #object_locations.size()
- IGNORED_RECTS == a list of the rectangles which have the "ignore" flag set to
true in the XML file.
- for all valid i:
- for all valid i:
- #images[i] == a copy of the i-th image from the dataset
- #images[i] == a copy of the i-th image from the dataset
.
- #object_locations[i] == a vector of all the rectangles associated with
- #object_locations[i] == a vector of all the rectangles associated with
#images[i].
#images[i]. Note that only rectangles that are not marked as "ignore"
are stored into #object_locations.
- IGNORED_RECTS[i] == A vector of all the rectangles associated with
#images[i] that are marked as "ignore".
- if (skip_empty_images == true) then
- if (skip_empty_images == true) then
- #object_locations[i].size() != 0
- #object_locations[i].size() != 0
(i.e. only images with
detection
boxes in them will be loaded.)
(i.e. only images with
non-ignored
boxes in them will be loaded.)
- if (labels != "") then
- if (labels != "") then
- only boxes with the given label will be loaded into object_locations.
- Only boxes with the given label will be loaded into object_locations
and IGNORED_RECTS.
- else
- else
- all boxes in the dataset will be loaded
into object_location
s.
- all boxes in the dataset will be loaded
regardless of their label
s.
!*/
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -58,7 +66,7 @@ namespace dlib
...
@@ -58,7 +66,7 @@ namespace dlib
typename
image_type
,
typename
image_type
,
typename
MM
typename
MM
>
>
void
load_image_dataset
(
std
::
vector
<
std
::
vector
<
rectangle
>
>
load_image_dataset
(
array
<
image_type
,
MM
>&
images
,
array
<
image_type
,
MM
>&
images
,
std
::
vector
<
std
::
vector
<
rectangle
>
>&
object_locations
,
std
::
vector
<
std
::
vector
<
rectangle
>
>&
object_locations
,
const
std
::
string
&
filename
const
std
::
string
&
filename
...
@@ -68,7 +76,7 @@ namespace dlib
...
@@ -68,7 +76,7 @@ namespace dlib
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<typename image_type::type> is defined
- pixel_traits<typename image_type::type> is defined
ensures
ensures
- performs: load_image_dataset(images, object_locations, filename, "");
- performs:
return
load_image_dataset(images, object_locations, filename, "");
(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)
!*/
!*/
...
...
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