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
7ec91aef
Commit
7ec91aef
authored
Nov 15, 2019
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python: force using of ArgInfo
parent
1f57eb93
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
36 deletions
+30
-36
pyopencv_dnn.hpp
modules/dnn/misc/python/pyopencv_dnn.hpp
+2
-8
pyopencv_flann.hpp
modules/flann/misc/python/pyopencv_flann.hpp
+6
-6
pyopencv_ml.hpp
modules/ml/misc/python/pyopencv_ml.hpp
+4
-4
cv2.cpp
modules/python/src2/cv2.cpp
+0
-0
gen2.py
modules/python/src2/gen2.py
+9
-9
pycompat.hpp
modules/python/src2/pycompat.hpp
+6
-6
pyopencv_videoio.hpp
modules/videoio/misc/python/pyopencv_videoio.hpp
+3
-3
No files found.
modules/dnn/misc/python/pyopencv_dnn.hpp
View file @
7ec91aef
...
...
@@ -4,9 +4,9 @@ typedef std::vector<dnn::MatShape> vector_MatShape;
typedef
std
::
vector
<
std
::
vector
<
dnn
::
MatShape
>
>
vector_vector_MatShape
;
template
<>
bool
pyopencv_to
(
PyObject
*
o
,
dnn
::
DictValue
&
dv
,
const
char
*
name
)
bool
pyopencv_to
(
PyObject
*
o
,
dnn
::
DictValue
&
dv
,
const
ArgInfo
&
info
)
{
CV_UNUSED
(
name
);
CV_UNUSED
(
info
);
if
(
!
o
||
o
==
Py_None
)
return
true
;
//Current state will be used
else
if
(
PyLong_Check
(
o
))
...
...
@@ -36,12 +36,6 @@ bool pyopencv_to(PyObject *o, dnn::DictValue &dv, const char *name)
return
false
;
}
template
<>
bool
pyopencv_to
(
PyObject
*
o
,
std
::
vector
<
Mat
>
&
blobs
,
const
char
*
name
)
//required for Layer::blobs RW
{
return
pyopencvVecConverter
<
Mat
>::
to
(
o
,
blobs
,
ArgInfo
(
name
,
false
));
}
template
<
typename
T
>
PyObject
*
pyopencv_from
(
const
dnn
::
DictValue
&
dv
)
{
...
...
modules/flann/misc/python/pyopencv_flann.hpp
View file @
7ec91aef
...
...
@@ -15,9 +15,9 @@ PyObject* pyopencv_from(const cvflann_flann_distance_t& value)
}
template
<>
bool
pyopencv_to
(
PyObject
*
o
,
cv
::
flann
::
IndexParams
&
p
,
const
char
*
name
)
bool
pyopencv_to
(
PyObject
*
o
,
cv
::
flann
::
IndexParams
&
p
,
const
ArgInfo
&
info
)
{
CV_UNUSED
(
name
);
CV_UNUSED
(
info
);
bool
ok
=
true
;
PyObject
*
key
=
NULL
;
PyObject
*
item
=
NULL
;
...
...
@@ -71,16 +71,16 @@ bool pyopencv_to(PyObject *o, cv::flann::IndexParams& p, const char *name)
}
template
<>
bool
pyopencv_to
(
PyObject
*
obj
,
cv
::
flann
::
SearchParams
&
value
,
const
char
*
name
)
bool
pyopencv_to
(
PyObject
*
obj
,
cv
::
flann
::
SearchParams
&
value
,
const
ArgInfo
&
info
)
{
return
pyopencv_to
<
cv
::
flann
::
IndexParams
>
(
obj
,
value
,
name
);
return
pyopencv_to
<
cv
::
flann
::
IndexParams
>
(
obj
,
value
,
info
);
}
template
<>
bool
pyopencv_to
(
PyObject
*
o
,
cvflann
::
flann_distance_t
&
dist
,
const
char
*
name
)
bool
pyopencv_to
(
PyObject
*
o
,
cvflann
::
flann_distance_t
&
dist
,
const
ArgInfo
&
info
)
{
int
d
=
(
int
)
dist
;
bool
ok
=
pyopencv_to
(
o
,
d
,
name
);
bool
ok
=
pyopencv_to
(
o
,
d
,
info
);
dist
=
(
cvflann
::
flann_distance_t
)
d
;
return
ok
;
}
...
...
modules/ml/misc/python/pyopencv_ml.hpp
View file @
7ec91aef
template
<>
bool
pyopencv_to
(
PyObject
*
obj
,
CvTermCriteria
&
dst
,
const
char
*
name
)
bool
pyopencv_to
(
PyObject
*
obj
,
CvTermCriteria
&
dst
,
const
ArgInfo
&
info
)
{
CV_UNUSED
(
name
);
CV_UNUSED
(
info
);
if
(
!
obj
)
return
true
;
return
PyArg_ParseTuple
(
obj
,
"iid"
,
&
dst
.
type
,
&
dst
.
max_iter
,
&
dst
.
epsilon
)
>
0
;
}
template
<>
bool
pyopencv_to
(
PyObject
*
obj
,
CvSlice
&
r
,
const
char
*
name
)
bool
pyopencv_to
(
PyObject
*
obj
,
CvSlice
&
r
,
const
ArgInfo
&
info
)
{
CV_UNUSED
(
name
);
CV_UNUSED
(
info
);
if
(
!
obj
||
obj
==
Py_None
)
return
true
;
if
(
PyObject_Size
(
obj
)
==
0
)
...
...
modules/python/src2/cv2.cpp
View file @
7ec91aef
This diff is collapsed.
Click to expand it.
modules/python/src2/gen2.py
View file @
7ec91aef
...
...
@@ -45,7 +45,7 @@ gen_template_func_body = Template("""$code_decl
gen_template_mappable
=
Template
(
"""
{
${mappable} _src;
if (pyopencv_to(src, _src,
name
))
if (pyopencv_to(src, _src,
info
))
{
return cv_mappable_to(_src, dst);
}
...
...
@@ -62,7 +62,7 @@ struct PyOpenCV_Converter< ${cname} >
{
return pyopencv_${name}_Instance(r);
}
static bool to(PyObject* src, ${cname}& dst, const
char* name
)
static bool to(PyObject* src, ${cname}& dst, const
ArgInfo& info
)
{
if(!src || src == Py_None)
return true;
...
...
@@ -73,7 +73,7 @@ struct PyOpenCV_Converter< ${cname} >
return true;
}
${mappable_code}
failmsg("Expected ${cname} for argument '
%
s'", name);
failmsg("Expected ${cname} for argument '
%
s'",
info.
name);
return false;
}
};
...
...
@@ -81,7 +81,7 @@ struct PyOpenCV_Converter< ${cname} >
"""
)
gen_template_map_type_cvt
=
Template
(
"""
template<> bool pyopencv_to(PyObject* src, ${cname}& dst, const
char* name
);
template<> bool pyopencv_to(PyObject* src, ${cname}& dst, const
ArgInfo& info
);
"""
)
...
...
@@ -89,7 +89,7 @@ gen_template_set_prop_from_map = Template("""
if( PyMapping_HasKeyString(src, (char*)"$propname") )
{
tmp = PyMapping_GetItemString(src, (char*)"$propname");
ok = tmp && pyopencv_to(tmp, dst.$propname);
ok = tmp && pyopencv_to(tmp, dst.$propname
, ArgInfo("$propname", false)
);
Py_DECREF(tmp);
if(!ok) return false;
}"""
)
...
...
@@ -143,7 +143,7 @@ static int pyopencv_${name}_set_${member}(pyopencv_${name}_t* p, PyObject *value
PyErr_SetString(PyExc_TypeError, "Cannot delete the ${member} attribute");
return -1;
}
return pyopencv_to(value, p->v${access}${member}) ? 0 : -1;
return pyopencv_to(value, p->v${access}${member}
, ArgInfo("value", false)
) ? 0 : -1;
}
"""
)
...
...
@@ -161,7 +161,7 @@ static int pyopencv_${name}_set_${member}(pyopencv_${name}_t* p, PyObject *value
failmsgp("Incorrect type of object (must be '${name}' or its derivative)");
return -1;
}
return pyopencv_to(value, _self_${access}${member}) ? 0 : -1;
return pyopencv_to(value, _self_${access}${member}
, ArgInfo("value", false)
) ? 0 : -1;
}
"""
)
...
...
@@ -238,10 +238,10 @@ class ClassInfo(object):
def
gen_map_code
(
self
,
codegen
):
all_classes
=
codegen
.
classes
code
=
"static bool pyopencv_to(PyObject* src,
%
s& dst, const
char* name
)
\n
{
\n
PyObject* tmp;
\n
bool ok;
\n
"
%
(
self
.
cname
)
code
=
"static bool pyopencv_to(PyObject* src,
%
s& dst, const
ArgInfo& info
)
\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
.
base
:
code
+=
"
\n
return pyopencv_to(src, (
%
s&)dst,
name
);
\n
}
\n
"
%
all_classes
[
self
.
base
]
.
cname
code
+=
"
\n
return pyopencv_to(src, (
%
s&)dst,
info
);
\n
}
\n
"
%
all_classes
[
self
.
base
]
.
cname
else
:
code
+=
"
\n
return true;
\n
}
\n
"
return
code
...
...
modules/python/src2/pycompat.hpp
View file @
7ec91aef
...
...
@@ -101,13 +101,13 @@ static inline bool getUnicodeString(PyObject * obj, std::string &str)
#define CV_PY_TO_CLASS(TYPE) \
template<> \
bool pyopencv_to(PyObject* dst, TYPE& src, const
char* name)
\
bool pyopencv_to(PyObject* dst, TYPE& src, const
ArgInfo& info)
\
{ \
if (!dst || dst == Py_None) \
return true; \
Ptr<TYPE> ptr; \
\
if (!pyopencv_to(dst, ptr,
name
)) return false; \
if (!pyopencv_to(dst, ptr,
info
)) return false; \
src = *ptr; \
return true; \
}
...
...
@@ -124,13 +124,13 @@ PyObject* pyopencv_from(const TYPE& src)
#define CV_PY_TO_CLASS_PTR(TYPE) \
template<> \
bool pyopencv_to(PyObject* dst, TYPE*& src, const
char* name)
\
bool pyopencv_to(PyObject* dst, TYPE*& src, const
ArgInfo& info)
\
{ \
if (!dst || dst == Py_None) \
return true; \
Ptr<TYPE> ptr; \
\
if (!pyopencv_to(dst, ptr,
name
)) return false; \
if (!pyopencv_to(dst, ptr,
info
)) return false; \
src = ptr; \
return true; \
}
...
...
@@ -143,13 +143,13 @@ static PyObject* pyopencv_from(TYPE*& src)
#define CV_PY_TO_ENUM(TYPE) \
template<> \
bool pyopencv_to(PyObject* dst, TYPE& src, const
char* name)
\
bool pyopencv_to(PyObject* dst, TYPE& src, const
ArgInfo& info)
\
{ \
if (!dst || dst == Py_None) \
return true; \
int underlying = 0; \
\
if (!pyopencv_to(dst, underlying,
name
)) return false; \
if (!pyopencv_to(dst, underlying,
info
)) return false; \
src = static_cast<TYPE>(underlying); \
return true; \
}
...
...
modules/videoio/misc/python/pyopencv_videoio.hpp
View file @
7ec91aef
...
...
@@ -3,7 +3,7 @@ typedef std::vector<VideoCaptureAPIs> vector_VideoCaptureAPIs;
template
<>
struct
pyopencvVecConverter
<
cv
::
VideoCaptureAPIs
>
{
static
bool
to
(
PyObject
*
obj
,
std
::
vector
<
cv
::
VideoCaptureAPIs
>&
value
,
const
ArgInfo
info
)
static
bool
to
(
PyObject
*
obj
,
std
::
vector
<
cv
::
VideoCaptureAPIs
>&
value
,
const
ArgInfo
&
info
)
{
return
pyopencv_to_generic_vec
(
obj
,
value
,
info
);
}
...
...
@@ -15,9 +15,9 @@ template<> struct pyopencvVecConverter<cv::VideoCaptureAPIs>
};
template
<>
bool
pyopencv_to
(
PyObject
*
o
,
std
::
vector
<
cv
::
VideoCaptureAPIs
>&
apis
,
const
char
*
name
)
bool
pyopencv_to
(
PyObject
*
o
,
std
::
vector
<
cv
::
VideoCaptureAPIs
>&
apis
,
const
ArgInfo
&
info
)
{
return
pyopencvVecConverter
<
cv
::
VideoCaptureAPIs
>::
to
(
o
,
apis
,
ArgInfo
(
name
,
false
)
);
return
pyopencvVecConverter
<
cv
::
VideoCaptureAPIs
>::
to
(
o
,
apis
,
info
);
}
#endif // HAVE_OPENCV_VIDEOIO
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