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
5726c55d
Commit
5726c55d
authored
Apr 13, 2014
by
Davis King
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
7e787bcc
a3430ef3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
155 additions
and
0 deletions
+155
-0
point_transforms.h
dlib/geometry/point_transforms.h
+80
-0
point_transforms_abstract.h
dlib/geometry/point_transforms_abstract.h
+59
-0
geometry.cpp
dlib/test/geometry.cpp
+16
-0
No files found.
dlib/geometry/point_transforms.h
View file @
5726c55d
...
...
@@ -19,6 +19,13 @@ namespace dlib
class
point_rotator
{
public
:
point_rotator
(
)
{
sin_angle
=
0
;
cos_angle
=
1
;
}
point_rotator
(
const
double
&
angle
)
...
...
@@ -47,6 +54,18 @@ namespace dlib
return
temp
;
}
inline
friend
void
serialize
(
const
point_rotator
&
item
,
std
::
ostream
&
out
)
{
serialize
(
item
.
sin_angle
,
out
);
serialize
(
item
.
cos_angle
,
out
);
}
inline
friend
void
deserialize
(
point_rotator
&
item
,
std
::
istream
&
in
)
{
deserialize
(
item
.
sin_angle
,
in
);
deserialize
(
item
.
cos_angle
,
in
);
}
private
:
double
sin_angle
;
double
cos_angle
;
...
...
@@ -57,6 +76,16 @@ namespace dlib
class
point_transform
{
public
:
point_transform
(
)
{
sin_angle
=
0
;
cos_angle
=
1
;
translate
.
x
()
=
0
;
translate
.
y
()
=
0
;
}
point_transform
(
const
double
&
angle
,
const
dlib
::
vector
<
double
,
2
>&
translate_
...
...
@@ -90,6 +119,20 @@ namespace dlib
const
dlib
::
vector
<
double
,
2
>
get_b
(
)
const
{
return
translate
;
}
inline
friend
void
serialize
(
const
point_transform
&
item
,
std
::
ostream
&
out
)
{
serialize
(
item
.
sin_angle
,
out
);
serialize
(
item
.
cos_angle
,
out
);
serialize
(
item
.
translate
,
out
);
}
inline
friend
void
deserialize
(
point_transform
&
item
,
std
::
istream
&
in
)
{
deserialize
(
item
.
sin_angle
,
in
);
deserialize
(
item
.
cos_angle
,
in
);
deserialize
(
item
.
translate
,
in
);
}
private
:
double
sin_angle
;
double
cos_angle
;
...
...
@@ -101,6 +144,15 @@ namespace dlib
class
point_transform_affine
{
public
:
point_transform_affine
(
)
{
m
=
identity_matrix
<
double
>
(
2
);
b
.
x
()
=
0
;
b
.
y
()
=
0
;
}
point_transform_affine
(
const
matrix
<
double
,
2
,
2
>&
m_
,
const
dlib
::
vector
<
double
,
2
>&
b_
...
...
@@ -121,6 +173,18 @@ namespace dlib
const
dlib
::
vector
<
double
,
2
>&
get_b
(
)
const
{
return
b
;
}
inline
friend
void
serialize
(
const
point_transform_affine
&
item
,
std
::
ostream
&
out
)
{
serialize
(
item
.
m
,
out
);
serialize
(
item
.
b
,
out
);
}
inline
friend
void
deserialize
(
point_transform_affine
&
item
,
std
::
istream
&
in
)
{
deserialize
(
item
.
m
,
in
);
deserialize
(
item
.
b
,
in
);
}
private
:
matrix
<
double
,
2
,
2
>
m
;
dlib
::
vector
<
double
,
2
>
b
;
...
...
@@ -175,6 +239,13 @@ namespace dlib
class
point_transform_projective
{
public
:
point_transform_projective
(
)
{
m
=
identity_matrix
<
double
>
(
3
);
}
point_transform_projective
(
const
matrix
<
double
,
3
,
3
>&
m_
)
:
m
(
m_
)
...
...
@@ -208,6 +279,15 @@ namespace dlib
const
matrix
<
double
,
3
,
3
>&
get_m
(
)
const
{
return
m
;
}
inline
friend
void
serialize
(
const
point_transform_projective
&
item
,
std
::
ostream
&
out
)
{
serialize
(
item
.
m
,
out
);
}
inline
friend
void
deserialize
(
point_transform_projective
&
item
,
std
::
istream
&
in
)
{
deserialize
(
item
.
m
,
in
);
}
private
:
matrix
<
double
,
3
,
3
>
m
;
...
...
dlib/geometry/point_transforms_abstract.h
View file @
5726c55d
...
...
@@ -20,6 +20,15 @@ namespace dlib
applies an affine transformation to them.
!*/
public
:
point_transform_affine
(
);
/*!
ensures
- This object will perform the identity transform. That is, given a point
as input it will return the same point as output.
!*/
point_transform_affine
(
const
matrix
<
double
,
2
,
2
>&
m
,
const
dlib
::
vector
<
double
,
2
>&
b
...
...
@@ -57,6 +66,12 @@ namespace dlib
};
void
serialize
(
const
point_transform_affine
&
item
,
std
::
ostream
&
out
);
void
deserialize
(
point_transform_affine
&
item
,
std
::
istream
&
in
);
/*!
provides serialization support
!*/
// ----------------------------------------------------------------------------------------
point_transform_affine
inv
(
...
...
@@ -104,6 +119,14 @@ namespace dlib
public
:
point_transform_projective
(
);
/*!
ensures
- This object will perform the identity transform. That is, given a point
as input it will return the same point as output.
!*/
point_transform_projective
(
const
matrix
<
double
,
3
,
3
>&
m
);
...
...
@@ -145,6 +168,12 @@ namespace dlib
};
void
serialize
(
const
point_transform_projective
&
item
,
std
::
ostream
&
out
);
void
deserialize
(
point_transform_projective
&
item
,
std
::
istream
&
in
);
/*!
provides serialization support
!*/
// ----------------------------------------------------------------------------------------
point_transform_projective
inv
(
...
...
@@ -186,6 +215,15 @@ namespace dlib
translates them.
!*/
public
:
point_transform
(
);
/*!
ensures
- This object will perform the identity transform. That is, given a point
as input it will return the same point as output.
!*/
point_transform
(
const
double
&
angle
,
const
dlib
::
vector
<
double
,
2
>&
translate
...
...
@@ -226,6 +264,12 @@ namespace dlib
};
void
serialize
(
const
point_transform
&
item
,
std
::
ostream
&
out
);
void
deserialize
(
point_transform
&
item
,
std
::
istream
&
in
);
/*!
provides serialization support
!*/
// ----------------------------------------------------------------------------------------
class
point_rotator
...
...
@@ -236,6 +280,15 @@ namespace dlib
rotates them around the origin by a given angle.
!*/
public
:
point_rotator
(
);
/*!
ensures
- This object will perform the identity transform. That is, given a point
as input it will return the same point as output.
!*/
point_rotator
(
const
double
&
angle
);
...
...
@@ -267,6 +320,12 @@ namespace dlib
!*/
};
void
serialize
(
const
point_rotator
&
item
,
std
::
ostream
&
out
);
void
deserialize
(
point_rotator
&
item
,
std
::
istream
&
in
);
/*!
provides serialization support
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
...
...
dlib/test/geometry.cpp
View file @
5726c55d
...
...
@@ -648,6 +648,14 @@ namespace
DLIB_TEST
(
length
(
t
(
tinv
(
from
[
i
]))
-
from
[
i
])
<
1e-14
);
}
ostringstream
sout
;
serialize
(
t
,
sout
);
istringstream
sin
(
sout
.
str
());
point_transform_affine
t2
;
DLIB_TEST
(
length
(
t2
(
point
(
2
,
3
))
-
point
(
2
,
3
))
<
1e-14
);
deserialize
(
t2
,
sin
);
DLIB_TEST
(
max
(
abs
(
t2
.
get_m
()
-
t
.
get_m
()))
<
1e-14
);
DLIB_TEST
(
max
(
abs
(
t2
.
get_b
()
-
t
.
get_b
()))
<
1e-14
);
}
// ----------------------------------------------------------------------------------------
...
...
@@ -706,6 +714,14 @@ namespace
dlog
<<
LINFO
<<
" errors: mean/max: "
<<
rs
.
mean
()
<<
" "
<<
rs
.
max
();
pass_rate
.
add
(
0
);
}
ostringstream
sout
;
serialize
(
tran
,
sout
);
istringstream
sin
(
sout
.
str
());
point_transform_projective
tran3
;
DLIB_TEST
(
length
(
tran3
(
point
(
2
,
3
))
-
point
(
2
,
3
))
<
1e-14
);
deserialize
(
tran3
,
sin
);
DLIB_TEST
(
max
(
abs
(
tran3
.
get_m
()
-
tran
.
get_m
()))
<
1e-14
);
}
dlog
<<
LINFO
<<
" pass_rate.mean(): "
<<
pass_rate
.
mean
();
...
...
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