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
8c7f36ce
Commit
8c7f36ce
authored
Sep 05, 2016
by
Davis King
Browse files
Gave the random_cropper the option to randomly include background patches.
parent
d03bdb78
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
dlib/image_transforms/random_cropper.h
dlib/image_transforms/random_cropper.h
+13
-1
dlib/image_transforms/random_cropper_abstract.h
dlib/image_transforms/random_cropper_abstract.h
+20
-0
No files found.
dlib/image_transforms/random_cropper.h
View file @
8c7f36ce
...
@@ -20,8 +20,20 @@ namespace dlib
...
@@ -20,8 +20,20 @@ namespace dlib
double
max_rotation_degrees
=
30
;
double
max_rotation_degrees
=
30
;
double
min_object_height
=
0.25
;
// cropped object will be at least this fraction of the height of the image.
double
min_object_height
=
0.25
;
// cropped object will be at least this fraction of the height of the image.
double
max_object_height
=
0.7
;
// cropped object will be at most this fraction of the height of the image.
double
max_object_height
=
0.7
;
// cropped object will be at most this fraction of the height of the image.
double
background_crops_fraction
=
0.1
;
public:
public:
double
get_background_crops_fraction
(
)
const
{
return
background_crops_fraction
;
}
void
set_background_crops_fraction
(
double
value
)
{
DLIB_CASSERT
(
0
<=
value
&&
value
<
1
);
background_crops_fraction
=
value
;
}
const
chip_dims
&
get_chip_dims
(
const
chip_dims
&
get_chip_dims
(
)
const
{
return
dims
;
}
)
const
{
return
dims
;
}
...
@@ -167,7 +179,7 @@ namespace dlib
...
@@ -167,7 +179,7 @@ namespace dlib
{
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
rnd_mutex
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
rnd_mutex
);
rectangle
crop_rect
;
rectangle
crop_rect
;
if
(
has_non_ignored_box
(
rects
))
if
(
has_non_ignored_box
(
rects
)
&&
rnd
.
get_random_double
()
>=
background_crops_fraction
)
{
{
auto
rect
=
rects
[
randomly_pick_rect
(
rects
)].
rect
;
auto
rect
=
rects
[
randomly_pick_rect
(
rects
)].
rect
;
// perturb the location of the crop by a small fraction of the object's size.
// perturb the location of the crop by a small fraction of the object's size.
...
...
dlib/image_transforms/random_cropper_abstract.h
View file @
8c7f36ce
...
@@ -37,6 +37,26 @@ namespace dlib
...
@@ -37,6 +37,26 @@ namespace dlib
- #get_max_rotation_degrees() == 30
- #get_max_rotation_degrees() == 30
- #get_min_object_height() == 0.25
- #get_min_object_height() == 0.25
- #get_max_object_height() == 0.7
- #get_max_object_height() == 0.7
- #get_background_crops_fraction() == 0.1
!*/
double
get_background_crops_fraction
(
)
const
;
/*!
ensures
- When making random crops, get_background_crops_fraction() fraction of
them will be from random background rather than being centered on some
object in the dataset.
!*/
void
set_background_crops_fraction
(
double
value
);
/*!
requires
- 0 <= value < 1
ensures
- #get_background_crops_fraction() == value
!*/
!*/
const
chip_dims
&
get_chip_dims
(
const
chip_dims
&
get_chip_dims
(
...
...
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