Commit Graph

82 Commits

Author SHA1 Message Date
Alexander Alekhin
1615afd7f4 Merge pull request #19814 from alalek:pyopencv_to_safe 2021-03-31 22:58:18 +00:00
Alexander Alekhin
d651ff8d6b python: exception-free pyopencv_to() wrapper 2021-03-31 14:18:32 +00:00
Alexander Alekhin
bb6e15f2c0 python: fix CV_WRAP_AS handling 2021-03-30 22:02:48 +00:00
Vadim Levin
a0bdb78a99 feat: add overload resolution exception for Python bindings 2021-01-18 16:29:17 +03:00
Vadim Levin
31289d2f32 Merge pull request #15915 from VadimLevin:dev/norm_fix
Fix implicit conversion from array to scalar in python bindings

* Fix wrong conversion behavior for primitive types

  - Introduce ArgTypeInfo namedtuple instead of plain tuple.
    If strict conversion parameter for type is set to true, it is
    handled like object argument in PyArg_ParseTupleAndKeywords and
    converted to concrete type with the appropriate pyopencv_to function
    call.
  - Remove deadcode and unused variables.
  - Fix implicit conversion from numpy array with 1 element to scalar
  - Fix narrowing conversion to size_t type.

* Fix wrong conversion behavior for primitive types

  - Introduce ArgTypeInfo namedtuple instead of plain tuple.
    If strict conversion parameter for type is set to true, it is
    handled like object argument in PyArg_ParseTupleAndKeywords and
    converted to concrete type with the appropriate pyopencv_to function
    call.
  - Remove deadcode and unused variables.
  - Fix implicit conversion from numpy array with 1 element to scalar
  - Fix narrowing conversion to size_t type.·
  - Enable tests with wrong conversion behavior
  - Restrict passing None as value
  - Restrict bool to integer/floating types conversion

* Add PyIntType support for Python 2

* Remove possible narrowing conversion of size_t

* Bindings conversion update

  - Remove unused macro
  - Add better conversion for types to numpy types descriptors
  - Add argument name to fail messages
  - NoneType treated as a valid argument. Better handling will be added
    as a standalone patch

* Add descriptor specialization for size_t

* Add check for signed to unsigned integer conversion safety

  - If signed integer is positive it can be safely converted
    to unsigned
  - Add check for plain python 2 objects
  - Add check for numpy scalars
  - Add simple type_traits implementation for better code style

* Resolve type "overflow" false negative in safe casting check

 - Move type_traits to separate header

* Add copyright message to type_traits.hpp

* Limit conversion scope for integral numpy types

  - Made canBeSafelyCasted specialized only for size_t, so
    type_traits header became unused and was removed.
  - Added clarification about descriptor pointer
2020-01-13 18:11:34 +03:00
Alexander Alekhin
7ec91aefc1 python: force using of ArgInfo 2019-11-15 19:16:22 +03:00
berak
b7c8e9e874 python: fix type error msg 2019-11-02 08:17:07 +01:00
luz.paz
fcc7d8dd4e Fix modules/ typos
Found using `codespell -q 3 -S ./3rdparty -L activ,amin,ang,atleast,childs,dof,endwhile,halfs,hist,iff,nd,od,uint`

backporting of commit: ec43292e1e
2019-08-16 17:34:29 +03:00
Maksim Shabunin
10d61a2b44 Limited API support for Python3 2019-06-11 15:15:49 +03:00
Alexander Alekhin
f5b58e5fc9 bindings: backport generator from OpenCV 4.x
- better handling of enum arguments
- less merge conflicts
2019-03-01 20:18:48 +00:00
Diego Barrios Romero
7a884ab6a5 Fix closing input file 2018-10-29 13:05:46 +01:00
Alexander Alekhin
1207300e01 python: avoid direct cast PyCFunctionWithKeywords->PyCFunction 2018-05-30 17:24:43 +03:00
Alexander Alekhin
768f4cb7bc python: 'sub-module' for binding sources and documentation meta information 2017-12-09 21:01:46 +00:00
Alexander Alekhin
cbf2b51e40 bindings(py): fix handling of 'isalgorithm' 2017-11-24 09:54:44 +03:00
Cartucho
7267e94be7 Merge pull request #9736 from Cartucho/const_and_class_to_json
* Adding constants to json file

* adding sub-module to constants name

* adding namespace to functions

* adding namespace to classes

* remove namespace from methods

* static methods

* python signatures generation

* python: more fixes for signatures generation

Python names existence can be checked via command:

    python -c "import cv2 as cv; print(repr(<py_name>))"
2017-11-04 06:38:18 +03:00
Alexander Alekhin
200c8a0d3a python: generate pyopencv_signatures.json file 2017-09-06 08:23:04 +03:00
Lewis B
1caca2112b Merge pull request #8934 from lewisjb:python-classes
* Refactor Python Classes
2017-09-05 05:38:17 +00:00
Alexander Alekhin
b32d914aab static analyze: python dynamic_cast checks 2017-07-06 17:11:51 +03:00
Alexander Alekhin
6ea6e4bceb binding: fix headers processing 2017-06-30 14:53:21 +03:00
lewisjb
078b4cc971 Added Python Docstrings 2017-06-14 16:46:08 +10:00
Vadim Pisarevsky
a799cc13d9 Merge pull request #6078 from PolarNick239:master 2016-10-05 17:27:23 +00:00
Vitaliy Lyudvichenko
ab8de8f506 Adding of user-defined type conversions for python bindings inside module directories
Adding of destructor and placement new constructors for classes wrapped with CV_EXPORTS_W_SIMPLE macro
2016-08-16 13:10:17 +03:00
Alexander Alekhin
c0fe374490 cmake: python, allow dynamic symbols lookup from libpython.so 2016-07-07 14:23:35 +03:00
berak
11e563fd5d python: support for size_t args (default value) 2016-05-03 09:50:08 +02:00
Nikolay Polyarniy
46e08d34dd T-API python support implemented:
- cv2.UMat implemented - python thin wrapper for UMat
 - no implicit copy from GPU to Host done, resulting UMat can be passed to next function without overhead
 - cv2.UMat.get() - to fetch data to Host
 - new tests covers: ORB, BFMatcher, goodFeaturesToTrack, calcOpticalFlowPyrLK
2016-02-09 12:33:07 +03:00
Maksim Shabunin
78ddc567f9 Python generator: moved base class handling to the generate step 2015-06-05 12:41:23 +03:00
Maksim Shabunin
c137ba53a0 Wrap ANN_MLP class into Python 2015-05-06 15:21:23 +03:00
Maksim Shabunin
82adf7955f Fix python submodules inheritance detection 2015-03-26 11:22:56 +03:00
Mike Izbicki
ac47c0c624 fix to work with python 2.6
I had to make this modification locally to get opencv to build with python 2.6.  Python 2.6 requires indices in the format string (the `0` I added).  This requirement was relaxed in 2.7, so what used to be there would be working for people who could upgrade. I don't think the change has any negative consequences for future python versions, but I'm no expert.
2015-01-02 14:41:44 -08:00
Alexander Mordvintsev
2a9e252f77 fix namespace conflicts (like cv::inpaint and cv::xphoto::inpaint)
whitespace fix
2014-08-21 17:33:21 +04:00
Alexander Mordvintsev
74c77d826f base class name resolution
fixed find_obj.py
2014-08-21 14:51:03 +04:00
Alexander Mordvintsev
c4c731c0aa fixing warnings
keep old const names for compatibility
2014-08-19 16:57:37 +04:00
Alexander Mordvintsev
c22dcb04af fixing warnings 2014-08-19 16:40:09 +04:00
Alexander Mordvintsev
e74cddfbd1 put consts into python submodules
maintain set of visited namespaces in CppHeaderParser
WARNING: REMOVED const name conversion (SomeConstName -> SOME_CONST_NAME), discussion needed
2014-08-19 16:40:09 +04:00
Alexander Mordvintsev
6d1c02ffed unified namespace population with 'init_submodule' 2014-08-19 16:40:08 +04:00
Alexander Mordvintsev
4a519a25f3 nested classes support 2014-08-19 16:40:08 +04:00
Alexander Mordvintsev
5ad7f9910f function namespaces partially work 2014-08-19 16:40:07 +04:00
Alexander Mordvintsev
e85e83f491 handling namespaces on parsing functions
submodule method tables generation
2014-08-19 16:40:06 +04:00
Vadim Pisarevsky
e368f17caf fixed python bindings generation 2014-07-30 16:11:08 +04:00
Alexander Mordvintsev
9ab3b89c53 pass header list to gen2.py by a text file (avoid command line length limit on windows) 2014-07-27 17:17:36 +04:00
Alexander Mordvintsev
42ecfc5538 fixed parsing enums with tailing comma
gen2.py reports headers it processes
cmake file restructured
2014-07-27 17:17:35 +04:00
Alexander Mordvintsev
1d1bfd3d7d automatic search for headers for python wrapper generation 2014-07-27 17:17:35 +04:00
Alexander Mordvintsev
2756ae2051 exposed OpenCL-control functions to python 2014-05-14 17:42:21 +04:00
Alexander Mordvintsev
dd67ea0210 find -> rindex 2014-05-13 17:55:57 +04:00
Alexander Mordvintsev
120b3a1e77 Work on python wrapped generation automation:
- all parsed headers are included into "cv2.cpp" with "pyopencv_generated_include.h"
 - types starting with "Ptr_" converted to "Ptr<...>" form (avoids many typedefs in "cv2.cpp")
2014-05-12 15:49:54 +04:00
Roman Donchenko
dadee3752c Adapt Python bindings to the new Ptr. 2013-09-05 19:03:00 +04:00
Gabe Schwartz
bb209193c9 Updated usage of METH_X definitions for python 3.
Python 3 requires METH_VARARGS | METH_KEYWORDS, not just METH_KEYWORDS.
2013-06-13 20:10:01 -04:00
Gabe Schwartz
931ebab822 Updated generator and parser to support Python 3. 2013-06-13 18:39:47 -04:00
Andrey Kamaev
298ccf6487 Turn pyopencv_to and pyopencv_from into templates
This protects from unwanted implicit conversions between types at compile time.
2013-04-13 01:02:57 +04:00
Andrey Kamaev
f886651cf0 Drop old python samples and tests 2013-04-12 19:37:40 +04:00