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
10d61a2b
Commit
10d61a2b
authored
Mar 21, 2019
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Limited API support for Python3
parent
878af7ad
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
26 deletions
+63
-26
pyopencv_dnn.hpp
modules/dnn/misc/python/pyopencv_dnn.hpp
+10
-7
pyopencv_flann.hpp
modules/flann/misc/python/pyopencv_flann.hpp
+17
-13
CMakeLists.txt
modules/python/bindings/CMakeLists.txt
+5
-3
common.cmake
modules/python/common.cmake
+23
-3
CMakeLists.txt
modules/python/python3/CMakeLists.txt
+8
-0
cv2.cpp
modules/python/src2/cv2.cpp
+0
-0
gen2.py
modules/python/src2/gen2.py
+0
-0
pycompat.hpp
modules/python/src2/pycompat.hpp
+0
-0
No files found.
modules/dnn/misc/python/pyopencv_dnn.hpp
View file @
10d61a2b
...
...
@@ -21,16 +21,19 @@ bool pyopencv_to(PyObject *o, dnn::DictValue &dv, const char *name)
}
else
if
(
PyFloat_Check
(
o
))
{
dv
=
dnn
::
DictValue
(
PyFloat_A
S_DOUBLE
(
o
));
dv
=
dnn
::
DictValue
(
PyFloat_A
sDouble
(
o
));
return
true
;
}
else
if
(
PyString_Check
(
o
))
else
{
dv
=
dnn
::
DictValue
(
String
(
PyString_AsString
(
o
)));
return
true
;
std
::
string
str
;
if
(
getUnicodeString
(
o
,
str
))
{
dv
=
dnn
::
DictValue
(
str
);
return
true
;
}
}
else
return
false
;
return
false
;
}
template
<>
...
...
@@ -134,7 +137,7 @@ public:
PyObject
*
args
=
PyList_New
(
inputs
.
size
());
for
(
size_t
i
=
0
;
i
<
inputs
.
size
();
++
i
)
PyList_S
ET_ITEM
(
args
,
i
,
pyopencv_from_generic_vec
(
inputs
[
i
]));
PyList_S
etItem
(
args
,
i
,
pyopencv_from_generic_vec
(
inputs
[
i
]));
PyObject
*
res
=
PyObject_CallMethodObjArgs
(
o
,
PyString_FromString
(
"getMemoryShapes"
),
args
,
NULL
);
Py_DECREF
(
args
);
...
...
modules/flann/misc/python/pyopencv_flann.hpp
View file @
10d61a2b
...
...
@@ -27,20 +27,20 @@ bool pyopencv_to(PyObject *o, cv::flann::IndexParams& p, const char *name)
return
true
;
if
(
PyDict_Check
(
o
))
{
while
(
PyDict_Next
(
o
,
&
pos
,
&
key
,
&
item
))
{
if
(
!
PyString_Check
(
key
)
)
{
while
(
PyDict_Next
(
o
,
&
pos
,
&
key
,
&
item
))
{
// get key
std
::
string
k
;
if
(
!
getUnicodeString
(
key
,
k
))
{
ok
=
false
;
break
;
}
String
k
=
PyString_AsString
(
key
);
if
(
PyString_Check
(
item
)
)
// get value
if
(
!!
PyBool_Check
(
item
)
)
{
const
char
*
value
=
PyString_AsString
(
item
);
p
.
setString
(
k
,
value
);
}
else
if
(
!!
PyBool_Check
(
item
)
)
p
.
setBool
(
k
,
item
==
Py_True
);
}
else
if
(
PyInt_Check
(
item
)
)
{
int
value
=
(
int
)
PyInt_AsLong
(
item
);
...
...
@@ -56,8 +56,13 @@ bool pyopencv_to(PyObject *o, cv::flann::IndexParams& p, const char *name)
}
else
{
ok
=
false
;
break
;
std
::
string
val_str
;
if
(
!
getUnicodeString
(
item
,
val_str
))
{
ok
=
false
;
break
;
}
p
.
setString
(
k
,
val_str
);
}
}
}
...
...
@@ -79,4 +84,4 @@ bool pyopencv_to(PyObject *o, cvflann::flann_distance_t& dist, const char *name)
dist
=
(
cvflann
::
flann_distance_t
)
d
;
return
ok
;
}
#endif
\ No newline at end of file
#endif
modules/python/bindings/CMakeLists.txt
View file @
10d61a2b
...
...
@@ -51,11 +51,13 @@ if(NOT HAVE_CUDA)
endif
()
set
(
cv2_generated_files
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_
include
.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_
enums
.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_funcs.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_include.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_modules.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_modules_content.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_types.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_type_reg.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_ns_reg.h"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pyopencv_generated_types_content.h"
"
${
OPENCV_PYTHON_SIGNATURES_FILE
}
"
)
...
...
modules/python/common.cmake
View file @
10d61a2b
...
...
@@ -24,6 +24,22 @@ if(TARGET gen_opencv_python_source)
add_dependencies
(
${
the_module
}
gen_opencv_python_source
)
endif
()
ocv_assert
(
${
PYTHON
}
_VERSION_MAJOR
)
ocv_assert
(
${
PYTHON
}
_VERSION_MINOR
)
if
(
${
PYTHON
}
_LIMITED_API
)
# support only python3.3+
ocv_assert
(
${
PYTHON
}
_VERSION_MAJOR EQUAL 3 AND
${
PYTHON
}
_VERSION_MINOR GREATER 2
)
target_compile_definitions
(
${
the_module
}
PRIVATE CVPY_DYNAMIC_INIT
)
if
(
WIN32
)
string
(
REPLACE
"python
${${
PYTHON
}
_VERSION_MAJOR
}${${
PYTHON
}
_VERSION_MINOR
}
.lib"
"python
${${
PYTHON
}
_VERSION_MAJOR
}
.lib"
${
PYTHON
}
_LIBRARIES
"
${${
PYTHON
}
_LIBRARIES
}
"
)
endif
()
endif
()
if
(
APPLE
)
set_target_properties
(
${
the_module
}
PROPERTIES LINK_FLAGS
"-undefined dynamic_lookup"
)
elseif
(
WIN32 OR OPENCV_FORCE_PYTHON_LIBS
)
...
...
@@ -54,6 +70,13 @@ else()
if
(
NOT PYTHON_CVPY_PROCESS EQUAL 0
)
set
(
CVPY_SUFFIX
".so"
)
endif
()
if
(
${
PYTHON
}
_LIMITED_API
)
if
(
WIN32
)
string
(
REGEX REPLACE
"
\\
.[^
\\
.]*
\\
."
"."
CVPY_SUFFIX
"
${
CVPY_SUFFIX
}
"
)
else
()
string
(
REGEX REPLACE
"
\\
.[^
\\
.]*
\\
."
".abi
${${
PYTHON
}
_VERSION_MAJOR
}
."
CVPY_SUFFIX
"
${
CVPY_SUFFIX
}
"
)
endif
()
endif
()
endif
()
ocv_update
(
OPENCV_PYTHON_EXTENSION_BUILD_PATH
"
${
LIBRARY_OUTPUT_PATH
}
/
${
MODULE_INSTALL_SUBDIR
}
"
)
...
...
@@ -111,9 +134,6 @@ else()
set
(
PYTHON_INSTALL_ARCHIVE ARCHIVE DESTINATION
${${
PYTHON
}
_PACKAGES_PATH
}
COMPONENT python
)
endif
()
ocv_assert
(
${
PYTHON
}
_VERSION_MAJOR
)
ocv_assert
(
${
PYTHON
}
_VERSION_MINOR
)
set
(
__python_loader_subdir
""
)
if
(
NOT OPENCV_SKIP_PYTHON_LOADER
)
set
(
__python_loader_subdir
"cv2/"
)
...
...
modules/python/python3/CMakeLists.txt
View file @
10d61a2b
...
...
@@ -2,6 +2,14 @@ if(NOT PYTHON3_INCLUDE_PATH OR NOT PYTHON3_NUMPY_INCLUDE_DIRS)
ocv_module_disable
(
python3
)
endif
()
# Problem in numpy >=1.15 <1.17
if
(
PYTHON3_LIMITED_API
AND NOT PYTHON3_NUMPY_VERSION VERSION_LESS
"1.15"
AND PYTHON3_NUMPY_VERSION VERSION_LESS
"1.17"
)
set
(
PYTHON3_LIMITED_API OFF
)
endif
()
set
(
the_description
"The python3 bindings"
)
set
(
MODULE_NAME python3
)
set
(
MODULE_INSTALL_SUBDIR python3
)
...
...
modules/python/src2/cv2.cpp
View file @
10d61a2b
This diff is collapsed.
Click to expand it.
modules/python/src2/gen2.py
View file @
10d61a2b
This diff is collapsed.
Click to expand it.
modules/python/src2/pycompat.hpp
View file @
10d61a2b
This diff is collapsed.
Click to expand it.
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