Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
c0d0adba
Commit
c0d0adba
authored
Dec 10, 2014
by
Patrick Snape
Browse files
Add a list of points
Also, change point x and y to be properties
parent
85f0c0ff
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
3 deletions
+16
-3
tools/python/src/vector.cpp
tools/python/src/vector.cpp
+16
-3
No files found.
tools/python/src/vector.cpp
View file @
c0d0adba
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include <dlib/python.h>
#include <dlib/python.h>
#include <boost/shared_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <dlib/matrix.h>
#include <dlib/matrix.h>
#include <boost/python/slice.hpp>
#include <boost/python/slice.hpp>
#include <dlib/geometry/vector.h>
#include <dlib/geometry/vector.h>
...
@@ -14,6 +15,9 @@ using namespace boost::python;
...
@@ -14,6 +15,9 @@ using namespace boost::python;
typedef
matrix
<
double
,
0
,
1
>
cv
;
typedef
matrix
<
double
,
0
,
1
>
cv
;
template
<
typename
T
>
void
resize
(
T
&
v
,
unsigned
long
n
)
{
v
.
resize
(
n
);
}
void
cv_set_size
(
cv
&
m
,
long
s
)
void
cv_set_size
(
cv
&
m
,
long
s
)
{
{
m
.
set_size
(
s
);
m
.
set_size
(
s
);
...
@@ -170,6 +174,8 @@ void bind_vector()
...
@@ -170,6 +174,8 @@ void bind_vector()
.
def
(
"__setitem__"
,
&
cv__setitem__
)
.
def
(
"__setitem__"
,
&
cv__setitem__
)
.
add_property
(
"shape"
,
&
cv_get_matrix_size
)
.
add_property
(
"shape"
,
&
cv_get_matrix_size
)
.
def_pickle
(
serialize_pickle
<
cv
>
());
.
def_pickle
(
serialize_pickle
<
cv
>
());
def
(
"dot"
,
dotprod
,
"Compute the dot product between two dense column vectors."
);
}
}
{
{
typedef
point
type
;
typedef
point
type
;
...
@@ -177,9 +183,16 @@ void bind_vector()
...
@@ -177,9 +183,16 @@ void bind_vector()
.
def
(
init
<
long
,
long
>
((
arg
(
"x"
),
arg
(
"y"
))))
.
def
(
init
<
long
,
long
>
((
arg
(
"x"
),
arg
(
"y"
))))
.
def
(
"__repr__"
,
&
point__repr__
)
.
def
(
"__repr__"
,
&
point__repr__
)
.
def
(
"__str__"
,
&
point__str__
)
.
def
(
"__str__"
,
&
point__str__
)
.
def
(
"x"
,
&
point_x
)
.
add_property
(
"x"
,
&
point_x
,
"The x-coordinate of the point."
)
.
def
(
"y"
,
&
point_y
)
.
add_property
(
"y"
,
&
point_y
,
"The y-coordinate of the point."
)
.
def_pickle
(
serialize_pickle
<
type
>
());
}
{
typedef
std
::
vector
<
point
>
type
;
class_
<
type
>
(
"points"
,
"An array of point objects."
)
.
def
(
vector_indexing_suite
<
type
>
())
.
def
(
"clear"
,
&
type
::
clear
)
.
def
(
"resize"
,
resize
<
type
>
)
.
def_pickle
(
serialize_pickle
<
type
>
());
.
def_pickle
(
serialize_pickle
<
type
>
());
}
}
def
(
"dot"
,
dotprod
,
"Compute the dot product between two dense column vectors."
);
}
}
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