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
c0097a78
Commit
c0097a78
authored
May 20, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added dpoint to the python API.
parent
da943c69
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
opaque_types.h
tools/python/src/opaque_types.h
+1
-0
vector.cpp
tools/python/src/vector.cpp
+35
-0
No files found.
tools/python/src/opaque_types.h
View file @
c0097a78
...
...
@@ -50,6 +50,7 @@ PYBIND11_MAKE_OPAQUE(sparse_ranking_pairs);
PYBIND11_MAKE_OPAQUE
(
std
::
vector
<
dlib
::
point
>
);
PYBIND11_MAKE_OPAQUE
(
std
::
vector
<
dlib
::
dpoint
>
);
#endif // DLIB_PyTHON_OPAQUE_TYPES_H_
tools/python/src/vector.cpp
View file @
c0097a78
...
...
@@ -138,8 +138,24 @@ string point__str__(const point& p)
return
sout
.
str
();
}
string
dpoint__repr__
(
const
dpoint
&
p
)
{
std
::
ostringstream
sout
;
sout
<<
"dpoint("
<<
p
.
x
()
<<
", "
<<
p
.
y
()
<<
")"
;
return
sout
.
str
();
}
string
dpoint__str__
(
const
dpoint
&
p
)
{
std
::
ostringstream
sout
;
sout
<<
"("
<<
p
.
x
()
<<
", "
<<
p
.
y
()
<<
")"
;
return
sout
.
str
();
}
long
point_x
(
const
point
&
p
)
{
return
p
.
x
();
}
long
point_y
(
const
point
&
p
)
{
return
p
.
y
();
}
double
dpoint_x
(
const
dpoint
&
p
)
{
return
p
.
x
();
}
double
dpoint_y
(
const
dpoint
&
p
)
{
return
p
.
y
();
}
// ----------------------------------------------------------------------------------------
void
bind_vector
(
py
::
module
&
m
)
...
...
@@ -179,4 +195,23 @@ void bind_vector(py::module& m)
.
def
(
"extend"
,
extend_vector_with_python_list
<
point
>
)
.
def
(
py
::
pickle
(
&
getstate
<
type
>
,
&
setstate
<
type
>
));
}
{
typedef
dpoint
type
;
py
::
class_
<
type
>
(
m
,
"dpoint"
,
"This object represents a single point of floating point coordinates that maps directly to a dlib::dpoint."
)
.
def
(
py
::
init
<
double
,
double
>
(),
py
::
arg
(
"x"
),
py
::
arg
(
"y"
))
.
def
(
"__repr__"
,
&
dpoint__repr__
)
.
def
(
"__str__"
,
&
dpoint__str__
)
.
def_property
(
"x"
,
&
dpoint_x
,
[](
dpoint
&
p
,
double
x
){
p
.
x
()
=
x
;},
"The x-coordinate of the dpoint."
)
.
def_property
(
"y"
,
&
dpoint_y
,
[](
dpoint
&
p
,
double
y
){
p
.
x
()
=
y
;},
"The y-coordinate of the dpoint."
)
.
def
(
py
::
pickle
(
&
getstate
<
type
>
,
&
setstate
<
type
>
));
}
{
typedef
std
::
vector
<
dpoint
>
type
;
py
::
bind_vector
<
type
>
(
m
,
"dpoints"
,
"An array of dpoint objects."
)
.
def
(
"clear"
,
&
type
::
clear
)
.
def
(
"resize"
,
resize
<
type
>
)
.
def
(
"extend"
,
extend_vector_with_python_list
<
dpoint
>
)
.
def
(
py
::
pickle
(
&
getstate
<
type
>
,
&
setstate
<
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