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
6adfdac9
Commit
6adfdac9
authored
Feb 03, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added shrink_rect() and grow_rect() for drectangle objects.
parent
43e29a07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
0 deletions
+85
-0
drectangle.h
dlib/geometry/drectangle.h
+34
-0
drectangle_abstract.h
dlib/geometry/drectangle_abstract.h
+51
-0
No files found.
dlib/geometry/drectangle.h
View file @
6adfdac9
...
...
@@ -365,6 +365,40 @@ namespace dlib
return
drectangle
(
p
.
x
()
-
width
/
2
,
p
.
y
()
-
height
/
2
,
p
.
x
()
+
width
/
2
,
p
.
y
()
+
height
/
2
);
}
inline
const
drectangle
shrink_rect
(
const
drectangle
&
rect
,
double
num
)
{
return
drectangle
(
rect
.
left
()
+
num
,
rect
.
top
()
+
num
,
rect
.
right
()
-
num
,
rect
.
bottom
()
-
num
);
}
inline
const
drectangle
grow_rect
(
const
drectangle
&
rect
,
double
num
)
{
return
shrink_rect
(
rect
,
-
num
);
}
inline
const
drectangle
shrink_rect
(
const
drectangle
&
rect
,
double
width
,
double
height
)
{
return
drectangle
(
rect
.
left
()
+
width
,
rect
.
top
()
+
height
,
rect
.
right
()
-
width
,
rect
.
bottom
()
-
height
);
}
inline
const
drectangle
grow_rect
(
const
drectangle
&
rect
,
double
width
,
double
height
)
{
return
shrink_rect
(
rect
,
-
width
,
-
height
);
}
// ----------------------------------------------------------------------------------------
}
...
...
dlib/geometry/drectangle_abstract.h
View file @
6adfdac9
...
...
@@ -490,6 +490,57 @@ namespace dlib
- R.tl_corner() == point(p.x()-width/2, p.y()-height/2)
!*/
// ----------------------------------------------------------------------------------------
const
drectangle
shrink_rect
(
const
drectangle
&
rect
,
double
num
);
/*!
ensures
- returns drectangle(rect.left()+num, rect.top()+num, rect.right()-num, rect.bottom()-num)
(i.e. shrinks the given drectangle by shrinking its border by num)
!*/
// ----------------------------------------------------------------------------------------
const
drectangle
grow_rect
(
const
drectangle
&
rect
,
double
num
);
/*!
ensures
- return shrink_rect(rect, -num)
(i.e. grows the given drectangle by expanding its border by num)
!*/
// ----------------------------------------------------------------------------------------
const
drectangle
shrink_rect
(
const
drectangle
&
rect
,
double
width
,
double
height
);
/*!
ensures
- returns drectangle(rect.left()+width, rect.top()+height, rect.right()-width, rect.bottom()-height)
(i.e. shrinks the given drectangle by shrinking its left and right borders by width
and its top and bottom borders by height. )
!*/
// ----------------------------------------------------------------------------------------
const
drectangle
grow_rect
(
const
drectangle
&
rect
,
double
width
,
double
height
);
/*!
ensures
- return shrink_rect(rect, -width, -height)
(i.e. grows the given drectangle by expanding its border)
!*/
// ----------------------------------------------------------------------------------------
}
...
...
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