Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
e368f17c
Commit
e368f17c
authored
Jul 30, 2014
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed python bindings generation
parent
ba3783d2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
15 deletions
+12
-15
cv2.cpp
modules/python/src2/cv2.cpp
+1
-8
gen2.py
modules/python/src2/gen2.py
+3
-3
hdr_parser.py
modules/python/src2/hdr_parser.py
+8
-4
No files found.
modules/python/src2/cv2.cpp
View file @
e368f17c
...
...
@@ -10,6 +10,7 @@
#include <numpy/ndarrayobject.h>
#include "pyopencv_generated_include.h"
#include "opencv2/core/types_c.h"
#include "opencv2/opencv_modules.hpp"
...
...
@@ -1089,14 +1090,6 @@ bool pyopencv_to(PyObject* obj, CvSlice& r, const char* name)
return
PyArg_ParseTuple
(
obj
,
"ii"
,
&
r
.
start_index
,
&
r
.
end_index
)
>
0
;
}
template
<>
PyObject
*
pyopencv_from
(
CvDTreeNode
*
const
&
node
)
{
double
value
=
node
->
value
;
int
ivalue
=
cvRound
(
value
);
return
value
==
ivalue
?
PyInt_FromLong
(
ivalue
)
:
PyFloat_FromDouble
(
value
);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
static
void
OnMouse
(
int
event
,
int
x
,
int
y
,
int
flags
,
void
*
param
)
...
...
modules/python/src2/gen2.py
View file @
e368f17c
...
...
@@ -267,7 +267,7 @@ class ClassInfo(object):
#return sys.exit(-1)
if
self
.
bases
and
self
.
bases
[
0
]
.
startswith
(
"cv::"
):
self
.
bases
[
0
]
=
self
.
bases
[
0
][
4
:]
if
self
.
bases
and
self
.
bases
[
0
]
==
"Algorithm"
:
if
self
.
bases
and
self
.
bases
[
0
]
==
"
cv::
Algorithm"
:
self
.
isalgorithm
=
True
for
m
in
decl
[
2
]:
if
m
.
startswith
(
"="
):
...
...
@@ -286,7 +286,7 @@ class ClassInfo(object):
code
=
"static bool pyopencv_to(PyObject* src,
%
s& dst, const char* name)
\n
{
\n
PyObject* tmp;
\n
bool ok;
\n
"
%
(
self
.
cname
)
code
+=
""
.
join
([
gen_template_set_prop_from_map
.
substitute
(
propname
=
p
.
name
,
proptype
=
p
.
tp
)
for
p
in
self
.
props
])
if
self
.
bases
:
code
+=
"
\n
return pyopencv_to(src, (
%
s&)dst, name);
\n
}
\n
"
%
all_classes
[
self
.
bases
[
0
]]
.
cname
code
+=
"
\n
return pyopencv_to(src, (
%
s&)dst, name);
\n
}
\n
"
%
all_classes
[
self
.
bases
[
0
]
.
replace
(
"::"
,
"_"
)
]
.
cname
else
:
code
+=
"
\n
return true;
\n
}
\n
"
return
code
...
...
@@ -761,7 +761,7 @@ class PythonWrapperGenerator(object):
sys
.
exit
(
-
1
)
self
.
classes
[
classinfo
.
name
]
=
classinfo
if
classinfo
.
bases
and
not
classinfo
.
isalgorithm
:
classinfo
.
isalgorithm
=
self
.
classes
[
classinfo
.
bases
[
0
]]
.
isalgorithm
classinfo
.
isalgorithm
=
self
.
classes
[
classinfo
.
bases
[
0
]
.
replace
(
"::"
,
"_"
)
]
.
isalgorithm
def
add_const
(
self
,
name
,
decl
):
constinfo
=
ConstInfo
(
name
,
decl
[
1
])
...
...
modules/python/src2/hdr_parser.py
View file @
e368f17c
...
...
@@ -582,6 +582,7 @@ class CppHeaderParser(object):
return
name
if
name
.
startswith
(
"cv."
):
return
name
qualified_name
=
((
"."
in
name
)
or
(
"::"
in
name
))
n
=
""
for
b
in
self
.
block_stack
:
block_type
,
block_name
=
b
[
self
.
BLOCK_TYPE
],
b
[
self
.
BLOCK_NAME
]
...
...
@@ -590,9 +591,12 @@ class CppHeaderParser(object):
if
block_type
not
in
[
"struct"
,
"class"
,
"namespace"
]:
print
(
"Error at
%
d: there are non-valid entries in the current block stack "
%
(
self
.
lineno
,
self
.
block_stack
))
sys
.
exit
(
-
1
)
if
block_name
:
if
block_name
and
(
block_type
==
"namespace"
or
not
qualified_name
)
:
n
+=
block_name
+
"."
return
n
+
name
.
replace
(
"::"
,
"."
)
n
+=
name
.
replace
(
"::"
,
"."
)
if
n
.
endswith
(
".Algorithm"
):
n
=
"cv.Algorithm"
return
n
def
parse_stmt
(
self
,
stmt
,
end_token
):
"""
...
...
@@ -643,7 +647,7 @@ class CppHeaderParser(object):
classname
=
classname
[
1
:]
decl
=
[
stmt_type
+
" "
+
self
.
get_dotted_name
(
classname
),
""
,
modlist
,
[]]
if
bases
:
decl
[
1
]
=
": "
+
", "
.
join
([
b
if
"::"
in
b
else
self
.
get_dotted_name
(
b
)
.
replace
(
"."
,
"::"
)
for
b
in
bases
])
decl
[
1
]
=
": "
+
", "
.
join
([
self
.
get_dotted_name
(
b
)
.
replace
(
"."
,
"::"
)
for
b
in
bases
])
return
stmt_type
,
classname
,
True
,
decl
if
stmt
.
startswith
(
"class"
)
or
stmt
.
startswith
(
"struct"
):
...
...
@@ -658,7 +662,7 @@ class CppHeaderParser(object):
if
(
"CV_EXPORTS_W"
in
stmt
)
or
(
"CV_EXPORTS_AS"
in
stmt
)
or
(
not
self
.
wrap_mode
):
# and ("CV_EXPORTS" in stmt)):
decl
=
[
stmt_type
+
" "
+
self
.
get_dotted_name
(
classname
),
""
,
modlist
,
[]]
if
bases
:
decl
[
1
]
=
": "
+
", "
.
join
([
b
if
"::"
in
b
else
self
.
get_dotted_name
(
b
)
.
replace
(
"."
,
"::"
)
for
b
in
bases
])
decl
[
1
]
=
": "
+
", "
.
join
([
self
.
get_dotted_name
(
b
)
.
replace
(
"."
,
"::"
)
for
b
in
bases
])
return
stmt_type
,
classname
,
True
,
decl
if
stmt
.
startswith
(
"enum"
):
...
...
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