Commit Graph

718 Commits

Author SHA1 Message Date
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 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
Alexander Alekhin 43940f7ffc pre: OpenCV 3.4.15 (version++) 2021-06-07 20:10:34 +00:00
Anatoliy Talamanov c4df8989e9 Merge pull request #19982 from TolyaTalamanov:at/new-python-operation-api
G-API: New python operations API

* Reimplement test using decorators

* Custom python operation API

* Remove wip status

* python: support Python code in bindings (through loader only)

* cleanup, skip tests for Python 2.x (not supported)

* python 2.x can't skip unittest modules

* Clean up

* Clean up

* Fix segfault python3.9

Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
2021-05-20 18:59:53 +00:00
David Geldreich 6a4bfc0863 Stream default to Stream::Null() when no default in function prototype
this corrects bug #16592 where a Stream is created at
each GpuMat::load(arr,stream) call

a correct solution would have been to add a default to GpuMat::load
but due to circular dependence between Stream and GpuMat, this is not possible
add test_cuda_upload_download_stream to test_cuda.py
2021-05-01 10:03:28 +00:00
Alexander Alekhin cfb77091ca Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-04-15 20:50:26 +00:00
CSBVision ec32061f5f Update __init__.py to support symbolic links
Currently, the LOADER_DIR is set as os.path.dirname(os.path.abspath(__file__)). This does not point to the true library path if the cv2 folder is symlinked into the Python package directory such that importing cv2 under Python fails. The proposed change only resolves symbolic links correctly by calling os.path.realpath(__file__) first and does not change anything if __file__ contains no symbolic link.
2021-04-14 16:13:45 +00:00
Alexander Alekhin 12d80b9e64 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2021-04-01 21:48:52 +00:00
Alexander Alekhin 7f664850f5 Merge pull request #19825 from alalek:cmake_fix_headers_order_python_3.4 2021-04-01 12:34:10 +00:00
Alexander Alekhin 69341edfe6 Merge pull request #19816 from alalek:python_customize_namespaces 2021-04-01 12:27:04 +00:00