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
cabad6d5
Commit
cabad6d5
authored
Sep 17, 2017
by
Davis King
Browse files
Fixed a bug in the random_cropper where it might crash due to division by 0
if small images are given as input.
parent
da968fa5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
dlib/image_transforms/random_cropper.h
dlib/image_transforms/random_cropper.h
+3
-2
No files found.
dlib/image_transforms/random_cropper.h
View file @
cabad6d5
...
...
@@ -276,11 +276,12 @@ namespace dlib
// 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
);
mins
=
std
::
min
(
mins
,
maxs
);
auto
scale
=
rnd
.
get_double_in_range
(
mins
,
maxs
);
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
()));
point
offset
(
rnd
.
get_random_32bit_number
()
%
(
1
+
img
.
nc
()
-
rect
.
width
()),
rnd
.
get_random_32bit_number
()
%
(
1
+
img
.
nr
()
-
rect
.
height
()));
return
move_rect
(
rect
,
offset
);
}
...
...
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