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
bc332150
Commit
bc332150
authored
Jan 06, 2014
by
Davis King
Browse files
Added a version of draw_rectangle() that can draw directly onto an array2d.
parent
f6c42f7d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
dlib/image_transforms/draw.h
dlib/image_transforms/draw.h
+40
-0
dlib/image_transforms/draw_abstract.h
dlib/image_transforms/draw_abstract.h
+23
-0
No files found.
dlib/image_transforms/draw.h
View file @
bc332150
...
...
@@ -166,6 +166,46 @@ namespace dlib
draw_line
(
p1
.
x
(),
p1
.
y
(),
p2
.
x
(),
p2
.
y
(),
c
,
val
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
,
typename
pixel_type
>
void
draw_rectangle
(
image_type
&
c
,
const
rectangle
&
rect
,
const
pixel_type
&
val
)
{
draw_line
(
c
,
rect
.
tl_corner
(),
rect
.
tr_corner
(),
val
);
draw_line
(
c
,
rect
.
bl_corner
(),
rect
.
br_corner
(),
val
);
draw_line
(
c
,
rect
.
tl_corner
(),
rect
.
bl_corner
(),
val
);
draw_line
(
c
,
rect
.
tr_corner
(),
rect
.
br_corner
(),
val
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
,
typename
pixel_type
>
void
draw_rectangle
(
image_type
&
c
,
const
rectangle
&
rect
,
const
pixel_type
&
val
,
unsigned
int
thickness
)
{
for
(
int
i
=
0
;
i
<
thickness
;
++
i
)
{
if
((
i
%
2
)
==
0
)
draw_rectangle
(
c
,
shrink_rect
(
rect
,(
i
+
1
)
/
2
),
val
);
else
draw_rectangle
(
c
,
grow_rect
(
rect
,(
i
+
1
)
/
2
),
val
);
}
}
// ----------------------------------------------------------------------------------------
template
<
...
...
dlib/image_transforms/draw_abstract.h
View file @
bc332150
...
...
@@ -55,6 +55,29 @@ namespace dlib
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
,
typename
pixel_type
>
void
draw_rectangle
(
image_type
&
img
,
const
rectangle
&
rect
,
const
pixel_type
&
val
,
unsigned
int
thickness
=
1
);
/*!
requires
- image_type == is an implementation of array2d/array2d_kernel_abstract.h
- pixel_traits<pixel_type> is defined
ensures
- Draws the given rectangle onto the image img. It does this by calling
draw_line() four times to draw the four sides of the rectangle.
- The rectancle is drawn with the color given by val.
- The drawn rectangle will have edges that are thickness pixels wide.
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
image_type
,
typename
pixel_type
...
...
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