Commit Graph

726 Commits

Author SHA1 Message Date
Alexander Alekhin
13a995cc1d Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2022-04-02 19:45:44 +00:00
Alexander Alekhin
386df457a9 python: ensure publishing of subclasses before derived types 2022-03-27 12:49:22 +00:00
Vadim Levin
4d46958c82 fix: inline namespace handling in header parser
`inline namespace` should be skipped in header parser namespaces list.
Example:
```cpp
namespace cv {
inline namespace inlined {
namespace inner {
// content
} // namespace inner
} // namespace inlined
} // namespace cv
```
Before fix `inner` is registered as `cv..inner`
After fix: `cv.inner`
2022-03-25 15:36:31 +03:00
Alexander Alekhin
901e0ddfe4 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2022-03-05 19:46:28 +00:00
Vadim Levin
ccebbbc0ac feature: submodule or a class scope for exported classes
All classes are registered in the scope that corresponds to C++
namespace or exported class.

Example:
`cv::ml::Boost` is exported as `cv.ml.Boost`
`cv::SimpleBlobDetector::Params` is exported as
`cv.SimpleBlobDetector.Params`

For backward compatibility all classes are registered in the global
module with their mangling name containing scope information.
Example:
`cv::ml::Boost` has `cv.ml_Boost` alias to `cv.ml.Boost` type
2022-03-02 14:30:52 +03:00
Vadim Levin
119d8b3aca
Merge pull request #21553 from VadimLevin:dev/vlevin/scope-for-classes-4x-port
4.x: submodule or a class scope for exported classes

* feature: submodule or a class scope for exported classes

All classes are registered in the scope that corresponds to C++
namespace or exported class.

Example:
`cv::ml::Boost` is exported as `cv.ml.Boost`
`cv::SimpleBlobDetector::Params` is exported as
`cv.SimpleBlobDetector.Params`

For backward compatibility all classes are registered in the global
module with their mangling name containing scope information.
Example:
`cv::ml::Boost` has `cv.ml_Boost` alias to `cv.ml.Boost` type

* refactor: remove redundant GAPI aliases

* fix: use explicit string literals in CVPY_TYPE macro

* fix: add handling for class aliases
2022-02-25 01:17:43 +03:00
Vadim Levin
ef85b24a78 fix: wrong reference counter after module initialization 2022-01-27 12:05:06 +03:00
Vadim Levin
d88730685e fix: submodules creation and registration
- Add special case handling when submodule has the same name as parent
- `PyDict_SetItemString` doesn't steal reference, so reference count
  should be explicitly decremented to transfer object life-time
  ownership
- Add sanity checks for module registration input
- Add Python 2 and Python 3 reference counting handling
2022-01-27 11:06:06 +03:00
Alexander Alekhin
6ae8103022 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2022-01-19 19:29:58 +00:00
Vadim Levin
eca2d92791 fix: submodules creation and registration
- Add special case handling when submodule has the same name as parent
- `PyDict_SetItemString` doesn't steal reference, so reference count
  should be explicitly decremented to transfer object life-time
  ownership
- Add sanity checks for module registration input
2022-01-19 18:06:58 +03:00
Vadim Levin
76e34d6f2c fix: handle possible PyModule_AddObject failure
Comment from Python documentation:
Unlike other functions that steal references, `PyModule_AddObject()` only
decrements the reference count of value on success.
This means that its return value must be checked, and calling code must
`Py_DECREF()` value manually on error.
2022-01-18 11:38:33 +03:00
Alexander Alekhin
217fea9667 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-12-24 16:48:07 +00:00
Alexander Alekhin
cdfa8a668b python: use '((x,y), (w,h), angle)' in std::vector<RotatedRect> 2021-12-24 15:01:45 +00:00
Alexander Alekhin
c78a8dfd2d fix 4.x links 2021-12-22 13:24:30 +00:00
Alexander Alekhin
b1a57c4cb2 fix 3.4 links 2021-12-22 12:38:21 +00:00
Alexander Alekhin
07dca8cc03 pre: OpenCV 4.5.5 (version++) 2021-12-17 10:12:11 +00:00
Alexander Alekhin
60c093f086 pre: OpenCV 3.4.17 (version++) 2021-12-17 10:05:52 +00:00
Alexander Alekhin
d24befa0bc Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-12-11 15:18:57 +00:00
Andrey Senyaev
d6891c705e
Merge pull request #21219 from asenyaev:asen/remove_distutils
* Replaced distutils module to sysconfig

* Fixed getting a path to python lib
2021-12-08 18:51:34 +00:00
Maksim Shabunin
973e1acb67
Merge pull request #21182 from mshabunin:split-cv2cpp
Split cv2.cpp

* split cv2.cpp: util, numpy

* split cv2.cpp: convert

* split cv2.cpp: highgui, more utils

* split cv2.cpp: fix numpy import
2021-12-05 12:49:36 +00:00
Alexander Alekhin
40c748a2ae python: properly handle step for multichannel case 2021-10-29 18:29:19 +00:00
Alexander Alekhin
a590682764 cmake: update installation of python extra submodules
- support Python standalone builds
- loader installs submodules unconditionally
2021-10-15 14:21:31 +00:00
Alexander Alekhin
3e6f27522b pre: OpenCV 4.5.4 (version++) 2021-10-04 22:35:47 +00:00
Alexander Alekhin
ebef84e9ea pre: OpenCV 3.4.16 (version++) 2021-10-04 20:47:07 +00:00
Alexander Alekhin
37c3f0d8a0 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-10-02 17:57:18 +00:00
Alexander Smorkalov
2cc14bd0fb Verbose output for errors found by header parser. 2021-09-27 10:53:23 +03:00
Alexander Alekhin
0c10ae1861 python: cv.Mat wrapper over numpy.ndarray 2021-09-21 04:14:15 +00:00
Vadim Levin
3c89a28a06
Merge pull request #20611 from VadimLevin:dev/vlevin/pure-python-modules
* feat: OpenCV extension with pure Python modules

* feat: cv2 is now a Python package instead of extension module

Python package cv2 now can handle both Python and C extension modules
properly without additional "subfolders" like "_extra_py_code".

* feat: can call native function from its reimplementation in Python
2021-09-18 10:02:55 +03:00
Alexander Alekhin
c3ac834526 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-09-11 21:27:26 +00:00
Dale Phurrough
068f33cfdf
add nodiscard to features2d clone funcs 2021-09-09 15:20:45 +02:00
Alexander Alekhin
5aa7435d25 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-09-02 15:24:04 +00:00
Vadim Levin
390957fec4 fix: NumPy array allocation error message in vector conversion 2021-09-02 10:32:17 +03:00
Vadim Levin
16b9514543 feat: update conversion logic for std::vector<T> in Python bindings
`PyObject*` to `std::vector<T>` conversion logic:
- If user passed Numpy Array
  - If array is planar and T is a primitive type (doesn't require
    constructor call) that matches with the element type of array, then
    copy element one by one with the respect of the step between array
    elements. If compiler is lucky (or brave enough) copy loop can be
    vectorized.
    For classes that require constructor calls this path is not
    possible, because we can't begin an object lifetime without hacks.
  - Otherwise fall-back to general case
- Otherwise - execute the general case:
  If PyObject* corresponds to Sequence protocol - iterate over the
  sequence elements and invoke the appropriate `pyopencv_to` function.

`std::vector<T>` to `PyObject*` conversion logic:
- If `std::vector<T>` is empty - return empty tuple.
- If `T` has a corresponding `Mat` `DataType` than return
  Numpy array instance of the matching `dtype` e.g.
  `std::vector<cv::Rect>` is returned as `np.ndarray` of shape `Nx4` and
  `dtype=int`.
  This branch helps to optimize further evaluations in user code.
- Otherwise - execute the general case:
  Construct a tuple of length N = `std::vector::size` and insert
  elements one by one.

Unnecessary functions were removed and code was rearranged to allow
compiler select the appropriate conversion function specialization.
2021-09-01 13:00:21 +03:00
Alexander Panov
6f4160c014
Merge pull request #20584 from AleksandrPanov:fix_HoughCircles_ALT_dimensions
Fix hough circles alt dimensions

* fix OutputArray _circles dimensions

* add houghcircles_alt test

* fix warnings

* add shape assert

* change asserts
2021-08-24 19:29:40 +00:00
Alexander Alekhin
6fbfc58602 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-08-21 17:25:18 +00:00
Alexander Alekhin
c08897cd10 cmake: handle empty CVPY_SUFFIX 2021-08-19 20:06:41 +00:00
Alexander Alekhin
424eaba4c5 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-08-07 17:25:06 +00:00
Duong Dac
cefa602601 Avoid adding false UMat/GpuMat declaration 2021-08-04 15:17:25 +02:00
Vadim Levin
531ea5b3a2 fix: convert arguments names that are keywords reserved by Python 2021-08-01 12:02:36 +03:00
Alexander Alekhin
4ab0377c6e Merge pull request #20143 from rogday:base64_encoding 2021-07-19 20:43:19 +00:00
Alexander Alekhin
39b91c97f0 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-07-16 10:35:42 +00:00
Alexander Alekhin
eb9218a86b Merge pull request #20420 from berak:python_fix_trackbar_warning 2021-07-15 20:06:22 +00:00
berak
9f2dcc3f13 python: fix trackbar warning 2021-07-15 17:42:06 +02:00
Smirnov Egor
b42623ff9d port base64 encoding from 3.4 2021-07-08 10:42:44 +03:00
Anatoliy Talamanov
9fe49497bb
Merge pull request #20284 from TolyaTalamanov:at/wrap-render
G-API: Wrap render functionality to python

* Wrap render Rect prim

* Add all primitives and tests

* Cover mosaic and image

* Handle error in pyopencv_to(Prim)

* Move Mosaic and Rect ctors wrappers to shadow file

* Use GAPI_PROP_RW

* Fix indent
2021-07-01 09:36:19 +00:00
Anatoliy Talamanov
fb7ef76e74
Merge pull request #20271 from TolyaTalamanov:at/extend-python-bindings
G-API: Extend python bindings

* Extend G-API bindings

* Wrap timestamp, seqNo, seq_id
* Wrap copy
* Wrap parseSSD, parseYolo

* Rewrap cv.gapi.networks

* Add test for metabackend in pytnon

* Remove int64 pyopencv_to
2021-06-30 09:04:09 +00:00
Alexander Alekhin
c82e4596e4 cmake: fix installation of python extra code 2021-06-10 13:51:30 +03:00
Alexander Alekhin
bc1af6227a Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-06-09 10:58:37 +00:00
Alexander Alekhin
bd26104088 python(loader): add workaround to detect and patch sys.path[0] 2021-06-09 09:51:07 +00:00
Alexander Alekhin
b57faa41c2 pre: OpenCV 4.5.3 (version++) 2021-06-08 08:52:20 +00:00