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
2241e2c2
Commit
2241e2c2
authored
Aug 18, 2017
by
Davis King
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
08633868
98cf44e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
random_cropper.h
dlib/image_transforms/random_cropper.h
+8
-6
No files found.
dlib/image_transforms/random_cropper.h
View file @
2241e2c2
...
...
@@ -235,7 +235,7 @@ namespace dlib
}
else
{
crop_rect
=
make_random_cropping_rect
_resnet
(
img
);
crop_rect
=
make_random_cropping_rect
(
img
);
}
should_flip_crop
=
randomly_flip
&&
rnd
.
get_random_double
()
>
0
.
5
;
const
double
angle
=
rnd
.
get_double_in_range
(
-
max_rotation_degrees
,
max_rotation_degrees
)
*
pi
/
180
;
...
...
@@ -266,16 +266,18 @@ namespace dlib
}
template
<
typename
image_type
>
rectangle
make_random_cropping_rect
_resnet
(
rectangle
make_random_cropping_rect
(
const
image_type
&
img_
)
{
const_image_view
<
image_type
>
img
(
img_
);
// figure out what rectangle we want to crop from the image
double
mins
=
0
.
1
,
maxs
=
0
.
95
;
// Figure out what rectangle we want to crop from the image. We are going to
// crop out an image of size this->dims, so we pick a random scale factor that
// lets this random box be either as big as it can be while still fitting in
// the image or as small as a 3x zoomed in box randomly somewhere in the image.
double
mins
=
1
.
0
/
3
.
0
,
maxs
=
std
::
min
(
img
.
nr
()
/
(
double
)
dims
.
rows
,
img
.
nc
()
/
(
double
)
dims
.
cols
);
auto
scale
=
rnd
.
get_double_in_range
(
mins
,
maxs
);
auto
size
=
scale
*
std
::
min
(
img
.
nr
(),
img
.
nc
());
rectangle
rect
(
size
,
size
);
rectangle
rect
(
scale
*
dims
.
cols
,
scale
*
dims
.
rows
);
// randomly shift the box around
point
offset
(
rnd
.
get_random_32bit_number
()
%
(
img
.
nc
()
-
rect
.
width
()),
rnd
.
get_random_32bit_number
()
%
(
img
.
nr
()
-
rect
.
height
()));
...
...
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