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
8dece3ff
Commit
8dece3ff
authored
Nov 26, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the random translation amount user settable.
parent
3fca40f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
2 deletions
+34
-2
random_cropper.h
dlib/image_transforms/random_cropper.h
+14
-2
random_cropper_abstract.h
dlib/image_transforms/random_cropper_abstract.h
+20
-0
No files found.
dlib/image_transforms/random_cropper.h
View file @
8dece3ff
...
...
@@ -21,6 +21,7 @@ namespace dlib
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
background_crops_fraction
=
0
.
5
;
double
translate_amount
=
0
.
10
;
std
::
mutex
rnd_mutex
;
dlib
::
rand
rnd
;
...
...
@@ -30,6 +31,17 @@ namespace dlib
time_t
seed
)
{
rnd
=
dlib
::
rand
(
seed
);
}
double
get_translate_amount
(
)
const
{
return
translate_amount
;
}
void
set_translate_amount
(
double
value
)
{
DLIB_CASSERT
(
0
<=
value
);
translate_amount
=
value
;
}
double
get_background_crops_fraction
(
)
const
{
return
background_crops_fraction
;
}
...
...
@@ -191,8 +203,8 @@ namespace dlib
{
auto
rect
=
rects
[
randomly_pick_rect
(
rects
)].
rect
;
// perturb the location of the crop by a small fraction of the object's size.
const
point
rand_translate
=
dpoint
(
rnd
.
get_double_in_range
(
-
0
.
1
,
0
.
1
)
*
rect
.
width
(),
rnd
.
get_double_in_range
(
-
0
.
1
,
0
.
1
)
*
rect
.
height
());
const
point
rand_translate
=
dpoint
(
rnd
.
get_double_in_range
(
-
translate_amount
,
translate_amount
)
*
rect
.
width
(),
rnd
.
get_double_in_range
(
-
translate_amount
,
translate_amount
)
*
rect
.
height
());
// perturb the scale of the crop by a fraction of the object's size
const
double
rand_scale_perturb
=
rnd
.
get_double_in_range
(
min_object_height
,
max_object_height
);
...
...
dlib/image_transforms/random_cropper_abstract.h
View file @
8dece3ff
...
...
@@ -38,6 +38,7 @@ namespace dlib
- #get_min_object_height() == 0.25
- #get_max_object_height() == 0.7
- #get_background_crops_fraction() == 0.5
- #get_translate_amount() == 0.1
!*/
void
set_seed
(
...
...
@@ -48,6 +49,25 @@ namespace dlib
- Seeds the internal random number generator with the given seed.
!*/
double
get_translate_amount
(
)
const
;
/*!
ensures
- When a box is cropped out, it will be randomly translated prior to
cropping by #get_translate_amount()*(the box's height) up or down and
#get_translate_amount()*(the box's width) left or right.
!*/
void
set_translate_amount
(
double
value
);
/*!
requires
- value >= 0
ensures
- #get_translate_amount() == value
!*/
double
get_background_crops_fraction
(
)
const
;
/*!
...
...
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