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
347257cb
Commit
347257cb
authored
Oct 27, 2017
by
Davis King
Browse files
Made random_cropper use cleaner and unbiased dlib::rand interface.
parent
faf8676a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
dlib/image_transforms/random_cropper.h
dlib/image_transforms/random_cropper.h
+5
-5
No files found.
dlib/image_transforms/random_cropper.h
View file @
347257cb
...
@@ -157,7 +157,7 @@ namespace dlib
...
@@ -157,7 +157,7 @@ namespace dlib
DLIB_CASSERT
(
images
.
size
()
==
rects
.
size
());
DLIB_CASSERT
(
images
.
size
()
==
rects
.
size
());
size_t
idx
;
size_t
idx
;
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
rnd_mutex
);
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
rnd_mutex
);
idx
=
rnd
.
get_
random_64bit_numb
er
(
)
%
images
.
size
();
idx
=
rnd
.
get_
integ
er
(
images
.
size
()
)
;
}
}
(
*
this
)(
images
[
idx
],
rects
[
idx
],
crop
,
crop_rects
);
(
*
this
)(
images
[
idx
],
rects
[
idx
],
crop
,
crop_rects
);
}
}
...
@@ -290,9 +290,9 @@ namespace dlib
...
@@ -290,9 +290,9 @@ namespace dlib
)
)
{
{
DLIB_CASSERT
(
has_non_ignored_box
(
rects
));
DLIB_CASSERT
(
has_non_ignored_box
(
rects
));
size_t
idx
=
rnd
.
get_
random_64bit_numb
er
(
)
%
rects
.
size
();
size_t
idx
=
rnd
.
get_
integ
er
(
rects
.
size
()
)
;
while
(
rects
[
idx
].
ignore
)
while
(
rects
[
idx
].
ignore
)
idx
=
rnd
.
get_
random_64bit_numb
er
(
)
%
rects
.
size
();
idx
=
rnd
.
get_
integ
er
(
rects
.
size
()
)
;
return
idx
;
return
idx
;
}
}
...
@@ -311,8 +311,8 @@ namespace dlib
...
@@ -311,8 +311,8 @@ namespace dlib
auto
scale
=
rnd
.
get_double_in_range
(
mins
,
maxs
);
auto
scale
=
rnd
.
get_double_in_range
(
mins
,
maxs
);
rectangle
rect
(
scale
*
dims
.
cols
,
scale
*
dims
.
rows
);
rectangle
rect
(
scale
*
dims
.
cols
,
scale
*
dims
.
rows
);
// randomly shift the box around
// randomly shift the box around
point
offset
(
rnd
.
get_
random_32bit_number
()
%
(
1
+
img
.
nc
()
-
rect
.
width
()),
point
offset
(
rnd
.
get_
integer
(
1
+
img
.
nc
()
-
rect
.
width
()),
rnd
.
get_
random_32bit_number
()
%
(
1
+
img
.
nr
()
-
rect
.
height
()));
rnd
.
get_
integer
(
1
+
img
.
nr
()
-
rect
.
height
()));
return
move_rect
(
rect
,
offset
);
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