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
83efde62
Commit
83efde62
authored
Sep 28, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12678 from cv3d:cleanup/python/enums
parents
2c6ab654
e104fcc0
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
31 additions
and
70 deletions
+31
-70
pyopencv_core.hpp
modules/core/misc/python/pyopencv_core.hpp
+0
-6
pyopencv_umat.hpp
modules/core/misc/python/pyopencv_umat.hpp
+0
-3
pyopencv_features2d.hpp
modules/features2d/misc/python/pyopencv_features2d.hpp
+0
-16
pyopencv_objdetect.hpp
modules/objdetect/misc/python/pyopencv_objdetect.hpp
+0
-5
cv2.cpp
modules/python/src2/cv2.cpp
+1
-0
gen2.py
modules/python/src2/gen2.py
+30
-7
pyopencv_stitching.hpp
modules/stitching/misc/python/pyopencv_stitching.hpp
+0
-6
pyopencv_videoio.hpp
modules/videoio/misc/python/pyopencv_videoio.hpp
+0
-27
No files found.
modules/core/misc/python/pyopencv_core.hpp
View file @
83efde62
...
...
@@ -15,16 +15,10 @@ CV_PY_TO_CLASS(cuda::HostMem);
CV_PY_TO_CLASS_PTR
(
cuda
::
GpuMat
);
CV_PY_TO_CLASS_PTR
(
cuda
::
GpuMat
::
Allocator
);
CV_PY_TO_ENUM
(
cuda
::
Event
::
CreateFlags
);
CV_PY_TO_ENUM
(
cuda
::
HostMem
::
AllocType
);
CV_PY_TO_ENUM
(
cuda
::
FeatureSet
);
CV_PY_FROM_CLASS
(
cuda
::
GpuMat
);
CV_PY_FROM_CLASS
(
cuda
::
Stream
);
CV_PY_FROM_CLASS
(
cuda
::
HostMem
);
CV_PY_FROM_CLASS_PTR
(
cuda
::
GpuMat
::
Allocator
);
CV_PY_FROM_ENUM
(
cuda
::
DeviceInfo
::
ComputeMode
);
#endif
modules/core/misc/python/pyopencv_umat.hpp
View file @
83efde62
...
...
@@ -6,9 +6,6 @@ typedef std::vector<Range> vector_Range;
CV_PY_TO_CLASS
(
UMat
);
CV_PY_FROM_CLASS
(
UMat
);
CV_PY_TO_ENUM
(
UMatUsageFlags
);
CV_PY_FROM_ENUM
(
AccessFlag
);
CV_PY_TO_ENUM
(
AccessFlag
);
static
bool
cv_mappable_to
(
const
Ptr
<
Mat
>&
src
,
Ptr
<
UMat
>&
dst
)
{
...
...
modules/features2d/misc/python/pyopencv_features2d.hpp
View file @
83efde62
...
...
@@ -6,19 +6,4 @@ typedef FastFeatureDetector::DetectorType FastFeatureDetector_DetectorType;
typedef
DescriptorMatcher
::
MatcherType
DescriptorMatcher_MatcherType
;
typedef
KAZE
::
DiffusivityType
KAZE_DiffusivityType
;
typedef
ORB
::
ScoreType
ORB_ScoreType
;
CV_PY_FROM_ENUM
(
AKAZE
::
DescriptorType
);
CV_PY_TO_ENUM
(
AKAZE
::
DescriptorType
);
CV_PY_FROM_ENUM
(
AgastFeatureDetector
::
DetectorType
);
CV_PY_TO_ENUM
(
AgastFeatureDetector
::
DetectorType
);
CV_PY_FROM_ENUM
(
DrawMatchesFlags
);
CV_PY_TO_ENUM
(
DrawMatchesFlags
);
CV_PY_FROM_ENUM
(
FastFeatureDetector
::
DetectorType
);
CV_PY_TO_ENUM
(
FastFeatureDetector
::
DetectorType
);
CV_PY_FROM_ENUM
(
DescriptorMatcher
::
MatcherType
);
CV_PY_TO_ENUM
(
DescriptorMatcher
::
MatcherType
);
CV_PY_FROM_ENUM
(
KAZE
::
DiffusivityType
);
CV_PY_TO_ENUM
(
KAZE
::
DiffusivityType
);
CV_PY_FROM_ENUM
(
ORB
::
ScoreType
);
CV_PY_TO_ENUM
(
ORB
::
ScoreType
);
#endif
\ No newline at end of file
modules/objdetect/misc/python/pyopencv_objdetect.hpp
View file @
83efde62
...
...
@@ -5,9 +5,4 @@
typedef
HOGDescriptor
::
HistogramNormType
HOGDescriptor_HistogramNormType
;
typedef
HOGDescriptor
::
DescriptorStorageFormat
HOGDescriptor_DescriptorStorageFormat
;
CV_PY_FROM_ENUM
(
HOGDescriptor
::
HistogramNormType
);
CV_PY_TO_ENUM
(
HOGDescriptor
::
HistogramNormType
);
CV_PY_FROM_ENUM
(
HOGDescriptor
::
DescriptorStorageFormat
);
CV_PY_TO_ENUM
(
HOGDescriptor
::
DescriptorStorageFormat
);
#endif
modules/python/src2/cv2.cpp
View file @
83efde62
...
...
@@ -1669,6 +1669,7 @@ static int convert_to_char(PyObject *o, char *dst, const char *name = "no_name")
# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
#include "pyopencv_generated_enums.h"
#include "pyopencv_custom_headers.h"
#include "pyopencv_generated_types.h"
#include "pyopencv_generated_funcs.h"
...
...
modules/python/src2/gen2.py
View file @
83efde62
...
...
@@ -691,7 +691,7 @@ class FuncInfo(object):
defval0
=
"0"
tp1
=
tp
.
replace
(
"*"
,
"_ptr"
)
tp_candidates
=
[
a
.
tp
,
normalize_class_name
(
self
.
namespace
+
"."
+
a
.
tp
)]
if
any
(
tp
in
codegen
.
enum
Types
for
tp
in
tp_candidates
):
if
any
(
tp
in
codegen
.
enum
s
.
keys
()
for
tp
in
tp_candidates
):
defval0
=
"static_cast<
%
s>(
%
d)"
%
(
a
.
tp
,
0
)
amapping
=
simple_argtype_mapping
.
get
(
tp
,
(
tp
,
"O"
,
defval0
))
...
...
@@ -866,8 +866,9 @@ class PythonWrapperGenerator(object):
self
.
classes
=
{}
self
.
namespaces
=
{}
self
.
consts
=
{}
self
.
enum
Types
=
[]
self
.
enum
s
=
{}
self
.
code_include
=
StringIO
()
self
.
code_enums
=
StringIO
()
self
.
code_types
=
StringIO
()
self
.
code_funcs
=
StringIO
()
self
.
code_type_reg
=
StringIO
()
...
...
@@ -925,11 +926,11 @@ class PythonWrapperGenerator(object):
#print(cname + ' => ' + str(py_name) + ' (value=' + value + ')')
def
add_enum
(
self
,
name
,
decl
):
enumTyp
e
=
normalize_class_name
(
name
)
if
enumTyp
e
.
endswith
(
"<unnamed>"
):
enumTyp
e
=
None
wnam
e
=
normalize_class_name
(
name
)
if
wnam
e
.
endswith
(
"<unnamed>"
):
wnam
e
=
None
else
:
self
.
enum
Types
.
append
(
enumType
)
self
.
enum
s
[
wname
]
=
name
const_decls
=
decl
[
3
]
for
decl
in
const_decls
:
...
...
@@ -1020,6 +1021,21 @@ class PythonWrapperGenerator(object):
self
.
code_ns_reg
.
write
(
' init_submodule(root, MODULESTR"
%
s", methods_
%
s, consts_
%
s);
\n
'
%
(
ns_name
[
2
:],
wname
,
wname
))
self
.
code_ns_reg
.
write
(
'};
\n
'
)
def
gen_enum_reg
(
self
,
enum_name
):
name_seg
=
enum_name
.
split
(
"."
)
is_enum_class
=
False
if
len
(
name_seg
)
>=
2
and
name_seg
[
-
1
]
==
name_seg
[
-
2
]:
enum_name
=
"."
.
join
(
name_seg
[:
-
1
])
is_enum_class
=
True
wname
=
normalize_class_name
(
enum_name
)
cname
=
enum_name
.
replace
(
"."
,
"::"
)
code
=
""
if
re
.
sub
(
r"^cv\."
,
""
,
enum_name
)
!=
wname
:
code
+=
"typedef {0} {1};
\n
"
.
format
(
cname
,
wname
)
code
+=
"CV_PY_FROM_ENUM({0});
\n
CV_PY_TO_ENUM({0});
\n\n
"
.
format
(
wname
)
self
.
code_enums
.
write
(
code
)
def
save
(
self
,
path
,
name
,
buf
):
with
open
(
path
+
"/"
+
name
,
"wt"
)
as
f
:
...
...
@@ -1134,7 +1150,13 @@ class PythonWrapperGenerator(object):
self
.
gen_namespace
(
ns_name
)
self
.
gen_namespaces_reg
()
# step 4: generate the code for constants
# step 4: generate the code for enum types
enumlist
=
list
(
self
.
enums
.
values
())
enumlist
.
sort
()
for
name
in
enumlist
:
self
.
gen_enum_reg
(
name
)
# step 5: generate the code for constants
constlist
=
list
(
self
.
consts
.
items
())
constlist
.
sort
()
for
name
,
constinfo
in
constlist
:
...
...
@@ -1143,6 +1165,7 @@ class PythonWrapperGenerator(object):
# That's it. Now save all the files
self
.
save
(
output_path
,
"pyopencv_generated_include.h"
,
self
.
code_include
)
self
.
save
(
output_path
,
"pyopencv_generated_funcs.h"
,
self
.
code_funcs
)
self
.
save
(
output_path
,
"pyopencv_generated_enums.h"
,
self
.
code_enums
)
self
.
save
(
output_path
,
"pyopencv_generated_types.h"
,
self
.
code_types
)
self
.
save
(
output_path
,
"pyopencv_generated_type_reg.h"
,
self
.
code_type_reg
)
self
.
save
(
output_path
,
"pyopencv_generated_ns_reg.h"
,
self
.
code_ns_reg
)
...
...
modules/stitching/misc/python/pyopencv_stitching.hpp
View file @
83efde62
#ifdef HAVE_OPENCV_STITCHING
typedef
Stitcher
::
Status
Status
;
template
<>
PyObject
*
pyopencv_from
(
const
Status
&
value
)
{
return
PyInt_FromLong
(
value
);
}
#endif
\ No newline at end of file
modules/videoio/misc/python/pyopencv_videoio.hpp
View file @
83efde62
#ifdef HAVE_OPENCV_VIDEOIO
typedef
std
::
vector
<
VideoCaptureAPIs
>
vector_VideoCaptureAPIs
;
template
<>
bool
pyopencv_to
(
PyObject
*
o
,
cv
::
VideoCaptureAPIs
&
v
,
const
char
*
name
)
{
(
void
)
name
;
v
=
CAP_ANY
;
if
(
!
o
||
o
==
Py_None
)
return
false
;
else
if
(
PyLong_Check
(
o
))
{
v
=
VideoCaptureAPIs
((
int64
)
PyLong_AsLongLong
(
o
));
return
true
;
}
else
if
(
PyInt_Check
(
o
))
{
v
=
VideoCaptureAPIs
((
int64
)
PyInt_AS_LONG
(
o
));
return
true
;
}
else
return
false
;
}
template
<>
PyObject
*
pyopencv_from
(
const
cv
::
VideoCaptureAPIs
&
v
)
{
return
pyopencv_from
((
int
)(
v
));
}
template
<>
struct
pyopencvVecConverter
<
cv
::
VideoCaptureAPIs
>
{
static
bool
to
(
PyObject
*
obj
,
std
::
vector
<
cv
::
VideoCaptureAPIs
>&
value
,
const
ArgInfo
info
)
...
...
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