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
bc332150
Commit
bc332150
authored
Jan 07, 2014
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a version of draw_rectangle() that can draw directly onto an array2d.
parent
f6c42f7d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
0 deletions
+63
-0
draw.h
dlib/image_transforms/draw.h
+40
-0
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
...
@@ -166,6 +166,46 @@ namespace dlib
draw_line
(
p1
.
x
(),
p1
.
y
(),
p2
.
x
(),
p2
.
y
(),
c
,
val
);
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
<
template
<
...
...
dlib/image_transforms/draw_abstract.h
View file @
bc332150
...
@@ -55,6 +55,29 @@ namespace dlib
...
@@ -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
<
template
<
typename
image_type
,
typename
image_type
,
typename
pixel_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