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
93f3a09f
Commit
93f3a09f
authored
Nov 26, 2016
by
Davis King
Browse files
Added append() to random_cropper.
parent
8dece3ff
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
3 deletions
+53
-3
dlib/image_transforms/random_cropper.h
dlib/image_transforms/random_cropper.h
+23
-3
dlib/image_transforms/random_cropper_abstract.h
dlib/image_transforms/random_cropper_abstract.h
+30
-0
No files found.
dlib/image_transforms/random_cropper.h
View file @
93f3a09f
...
...
@@ -110,13 +110,33 @@ namespace dlib
)
{
DLIB_CASSERT
(
images
.
size
()
==
rects
.
size
());
crops
.
resize
(
num_crops
);
crop_rects
.
resize
(
num_crops
);
parallel_for
(
0
,
num_crops
,
[
&
](
long
i
)
{
crops
.
clear
();
crop_rects
.
clear
();
append
(
num_crops
,
images
,
rects
,
crops
,
crop_rects
);
}
template
<
typename
array_type
>
void
append
(
size_t
num_crops
,
const
array_type
&
images
,
const
std
::
vector
<
std
::
vector
<
mmod_rect
>>&
rects
,
array_type
&
crops
,
std
::
vector
<
std
::
vector
<
mmod_rect
>>&
crop_rects
)
{
DLIB_CASSERT
(
images
.
size
()
==
rects
.
size
());
DLIB_CASSERT
(
crops
.
size
()
==
crop_rects
.
size
());
auto
original_size
=
crops
.
size
();
crops
.
resize
(
crops
.
size
()
+
num_crops
);
crop_rects
.
resize
(
crop_rects
.
size
()
+
num_crops
);
parallel_for
(
original_size
,
original_size
+
num_crops
,
[
&
](
long
i
)
{
(
*
this
)(
images
,
rects
,
crops
[
i
],
crop_rects
[
i
]);
});
}
template
<
typename
array_type
,
typename
image_type
...
...
dlib/image_transforms/random_cropper_abstract.h
View file @
93f3a09f
...
...
@@ -181,6 +181,36 @@ namespace dlib
- #get_max_object_height() == value
!*/
template
<
typename
array_type
>
void
append
(
size_t
num_crops
,
const
array_type
&
images
,
const
std
::
vector
<
std
::
vector
<
mmod_rect
>>&
rects
,
array_type
&
crops
,
std
::
vector
<
std
::
vector
<
mmod_rect
>>&
crop_rects
);
/*!
requires
- images.size() == rects.size()
- crops.size() == crop_rects.size()
- for all valid i:
- images[i].size() != 0
- array_type is a type with an interface compatible with dlib::array or
std::vector and it must in turn contain image objects that implement the
interface defined in dlib/image_processing/generic_image.h
ensures
- Randomly extracts num_crops chips from images and appends them to the end
of crops. We also copy the object metadata for each extracted crop and
store it into #crop_rects. In particular, calling this function is the
same as making multiple calls to the version of operator() below that
outputs a single crop, except that append() will use multiple CPU cores
to do the processing and is therefore faster.
- #crops.size() == crops.size()+num_crops
- #crop_rects.size() == crop_rects.size()+num_crops
!*/
template
<
typename
array_type
>
...
...
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