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
8f5c5a3c
Commit
8f5c5a3c
authored
Feb 15, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refined drectangle a little.
parent
53168ba4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
drectangle.h
dlib/geometry/drectangle.h
+4
-2
drectangle_abstract.h
dlib/geometry/drectangle_abstract.h
+1
-1
geometry.cpp
dlib/test/geometry.cpp
+24
-0
No files found.
dlib/geometry/drectangle.h
View file @
8f5c5a3c
...
...
@@ -95,7 +95,8 @@ namespace dlib
double
width
(
)
const
{
if
(
is_empty
())
// if either the width or height would be 0.
if
(
t
>=
b
||
l
>=
r
)
return
0
;
else
return
r
-
l
;
...
...
@@ -104,7 +105,8 @@ namespace dlib
double
height
(
)
const
{
if
(
is_empty
())
// if either the width or height would be 0.
if
(
t
>=
b
||
l
>=
r
)
return
0
;
else
return
b
-
t
;
...
...
dlib/geometry/drectangle_abstract.h
View file @
8f5c5a3c
...
...
@@ -95,7 +95,7 @@ namespace dlib
- top() == rect.top()-0.5
- right() == rect.right()+0.5
- bottom() == rect.bottom()+0.5
-
center(*this) ==
center(rect)
-
dcenter(*this) == d
center(rect)
- width() == rect.width()
- height() == rect.height()
!*/
...
...
dlib/test/geometry.cpp
View file @
8f5c5a3c
...
...
@@ -772,6 +772,29 @@ namespace
}
}
// ----------------------------------------------------------------------------------------
void
test_rect_to_drect
()
{
print_spinner
();
dlib
::
rand
rnd
;
for
(
int
i
=
0
;
i
<
5000
;
++
i
)
{
rectangle
rect
=
centered_rect
(
rnd
.
get_random_32bit_number
()
%
100
,
rnd
.
get_random_32bit_number
()
%
100
,
rnd
.
get_random_32bit_number
()
%
100
,
rnd
.
get_random_32bit_number
()
%
100
);
drectangle
drect
=
rect
;
rectangle
rect2
=
drect
;
DLIB_TEST
(
rect2
==
rect
);
DLIB_TEST
(
rect
.
width
()
==
drect
.
width
());
DLIB_TEST
(
rect
.
height
()
==
drect
.
height
());
DLIB_TEST
(
dcenter
(
rect
)
==
dcenter
(
drect
));
}
}
// ----------------------------------------------------------------------------------------
class
geometry_tester
:
public
tester
...
...
@@ -786,6 +809,7 @@ namespace
void
perform_test
(
)
{
test_rect_to_drect
();
geometry_test
();
test_border_enumerator
();
test_find_affine_transform
();
...
...
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