Commit Graph

574 Commits

Author SHA1 Message Date
Alexander Alekhin
a494c75bfe pre: OpenCV 3.4.19 (version++) 2022-12-25 16:59:47 +00:00
Alexander Alekhin
eace6adb6d Merge pull request #22934 from alalek:fix_filestorage_binding 2022-12-17 03:28:13 +00:00
Alexander Alekhin
6a8c5a1d27 python: resolve Ptr<FileStorage> requirement issue 2022-12-16 00:47:44 +00:00
Alexander Smorkalov
52709c7771
Merge pull request #22954 from VadimLevin:dev/vlevin/fix-merge-artifacts-in-python-misc-tests
fix: remove function duplicates in test_misc.py
2022-12-14 09:42:43 +03:00
Vadim Levin
3f5f09e730 fix: add _ suffix to properties having reserved keyword names 2022-12-13 20:56:39 +03:00
Vadim Levin
253a4c113e fix: remove function duplicates in test_misc.py 2022-12-13 19:14:52 +03:00
Andrey Senyaev
1feabf4275 Fixed an issue with a recursion of cv2 in python 2022-07-19 13:52:29 +03:00
Tomoaki Teshima
87ef6a9cc1 build: suppress the warning
DRY
bump the version
2022-07-12 19:42:39 +09:00
Alexander Alekhin
400906b433 pre: OpenCV 3.4.18 (version++) 2022-05-23 19:18:02 +00:00
Alexander Alekhin
386df457a9 python: ensure publishing of subclasses before derived types 2022-03-27 12:49:22 +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
ef85b24a78 fix: wrong reference counter after module initialization 2022-01-27 12:05:06 +03: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
cdfa8a668b python: use '((x,y), (w,h), angle)' in std::vector<RotatedRect> 2021-12-24 15:01:45 +00:00
Alexander Alekhin
b1a57c4cb2 fix 3.4 links 2021-12-22 12:38:21 +00:00
Alexander Alekhin
60c093f086 pre: OpenCV 3.4.17 (version++) 2021-12-17 10:05:52 +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
Alexander Alekhin
ebef84e9ea pre: OpenCV 3.4.16 (version++) 2021-10-04 20:47:07 +00:00
Alexander Smorkalov
2cc14bd0fb Verbose output for errors found by header parser. 2021-09-27 10:53:23 +03:00
Dale Phurrough
068f33cfdf
add nodiscard to features2d clone funcs 2021-09-09 15:20:45 +02: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 Alekhin
c08897cd10 cmake: handle empty CVPY_SUFFIX 2021-08-19 20:06:41 +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
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
Alexander Alekhin
bd26104088 python(loader): add workaround to detect and patch sys.path[0] 2021-06-09 09:51:07 +00:00
Alexander Alekhin
43940f7ffc pre: OpenCV 3.4.15 (version++) 2021-06-07 20:10:34 +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
7f664850f5 Merge pull request #19825 from alalek:cmake_fix_headers_order_python_3.4 2021-04-01 12:34:10 +00:00
Alexander Alekhin
1b3e0b27af cmake: fix files order in Python bindings
- with changes backport from 4.x
2021-04-01 09:48:50 +00:00
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
Alexander Alekhin
a123c48d4d pre: OpenCV 3.4.14 (version++) 2021-03-02 20:47:29 +00:00
Pavel Rojtberg
6c1a433c4c python: also catch general c++ exceptions
they might be thrown from third-party code (notably Ogre in the ovis
module).
While Linux is kind enough to print them, they cause instant termination
on Windows.
Arguably, they do not origin from OpenCV itself, but still this helps
understanding what went wrong when calling an OpenCV function.
2021-02-02 21:16:01 +01:00
Alexander Alekhin
cdf73f2e05 Merge pull request #19427 from alalek:issue_19426 2021-01-31 14:24:37 +00:00
Alexander Alekhin
c5bf15e009 build: fix cv2.cpp compilation 2021-01-30 11:32:27 +00:00
Alexander Alekhin
ca9cbab532 Merge pull request #19403 from diablodale:fix_19402_python_test_filter_34 2021-01-26 19:23:12 +00:00
Dale Phurrough
5c70a2015f
fix python test runner wildcard handling
* fix opencv/opencv#19402
2021-01-26 19:05:40 +01:00
Vadim Levin
1d3207d7c7 feat: common fixed size sequence conversion for Python bindings 2021-01-25 08:08:38 +03:00
Vadim Levin
a0bdb78a99 feat: add overload resolution exception for Python bindings 2021-01-18 16:29:17 +03:00
Alexander Alekhin
b51ae87828 samples: check for Python 3.9 2020-12-21 14:59:34 +00:00
Vadim Levin
7b0d7d0c9a fix: conversion to string in python bindings
If provided `PyObject` can't be converted to string `TypeError` is
 reported instead of `SytemError` without any message.
2020-12-16 15:11:58 +03:00
Alexander Alekhin
3e5d7e1718 imgproc: fix minAreaRect() 2020-12-10 08:57:58 +00:00
Alexander Alekhin
b31ce408ae cmake: fix processing order of <wrapper>_bindings_generator
- ensure that wrapped modules are already processed
2020-12-03 13:01:46 +00:00
Alexander Alekhin
36d771affc python: restore sys.path in bootstrap()
- multiprocessing need to start from bootstrap code
- loading may fail due to missing os.add_dll_directory() calls
2020-11-26 13:10:25 +00:00
Alexander Alekhin
9485113923 pre: OpenCV 3.4.13 (version++) 2020-11-17 21:50:30 +00:00