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
cab12bb1
Commit
cab12bb1
authored
Aug 23, 2013
by
Davis King
Browse files
Added add_image_left_right_flips()
parent
dc907c33
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
dlib/image_transforms/interpolation.h
dlib/image_transforms/interpolation.h
+54
-0
dlib/image_transforms/interpolation_abstract.h
dlib/image_transforms/interpolation_abstract.h
+25
-0
No files found.
dlib/image_transforms/interpolation.h
View file @
cab12bb1
...
...
@@ -578,6 +578,60 @@ namespace dlib
assign_image
(
out_img
,
flipud
(
mat
(
in_img
)));
}
// ----------------------------------------------------------------------------------------
namespace
impl
{
inline
rectangle
flip_rect_left_right
(
const
rectangle
&
rect
,
const
rectangle
&
window
)
{
rectangle
temp
;
temp
.
top
()
=
rect
.
top
();
temp
.
bottom
()
=
rect
.
bottom
();
const
long
left_dist
=
rect
.
left
()
-
window
.
left
();
temp
.
right
()
=
window
.
right
()
-
left_dist
;
temp
.
left
()
=
temp
.
right
()
-
rect
.
width
()
+
1
;
return
temp
;
}
}
template
<
typename
image_type
>
void
add_image_left_right_flips
(
dlib
::
array
<
image_type
>&
images
,
std
::
vector
<
std
::
vector
<
rectangle
>
>&
objects
)
{
// make sure requires clause is not broken
DLIB_ASSERT
(
images
.
size
()
==
objects
.
size
(),
"
\t
void add_image_left_right_flips()"
<<
"
\n\t
Invalid inputs were given to this function."
<<
"
\n\t
images.size(): "
<<
images
.
size
()
<<
"
\n\t
objects.size(): "
<<
objects
.
size
()
);
image_type
temp
;
std
::
vector
<
rectangle
>
rects
;
const
unsigned
long
num
=
images
.
size
();
for
(
unsigned
long
j
=
0
;
j
<
num
;
++
j
)
{
flip_image_left_right
(
images
[
j
],
temp
);
rects
.
clear
();
for
(
unsigned
long
i
=
0
;
i
<
objects
[
j
].
size
();
++
i
)
rects
.
push_back
(
impl
::
flip_rect_left_right
(
objects
[
j
][
i
],
get_rect
(
images
[
j
])));
images
.
push_back
(
temp
);
objects
.
push_back
(
rects
);
}
}
// ----------------------------------------------------------------------------------------
namespace
impl
...
...
dlib/image_transforms/interpolation_abstract.h
View file @
cab12bb1
...
...
@@ -421,6 +421,31 @@ namespace dlib
(i.e. it is flipped as if viewed though a mirror)
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
>
void
add_image_left_right_flips
(
dlib
::
array
<
image_type
>&
images
,
std
::
vector
<
std
::
vector
<
rectangle
>
>&
objects
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<typename image_type::type> is defined
- images.size() == objects.size()
ensures
- This function computes all the left/right flips of the contents of images and
then appends them onto the end of the images array. It also finds the
left/right flips of the rectangles in objects and similarly appends them into
objects. That is, we assume objects[i] is the set of bounding boxes in
images[i] and we flip the bounding boxes so that they still bound the same
objects in the new flipped images.
- #images.size() == images.size()*2
- #objects.size() == objects.size()*2
!*/
// ----------------------------------------------------------------------------------------
template
<
...
...
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