Commit Graph

556 Commits

Author SHA1 Message Date
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
Alexander Alekhin 5dae278652 bindings: "inline namespace" 2020-11-11 10:38:15 +00:00
Alexander Alekhin 50ff40d684 pre: OpenCV 3.4.12 (version++) 2020-09-06 22:26:32 +00:00
Alexander Alekhin 442999dcdb core: fix handling of ND-arrays in dumpInputArray() helpers 2020-06-12 10:23:32 +00:00
Alexander Alekhin a43e3bebe6 pre: OpenCV 3.4.11 (version++) 2020-06-08 18:46:27 +00:00
Vadim Pisarevsky 5489735258 Merge pull request #17436 from vpisarev:fix_python_io
* fixed #17044
1. fixed Python part of the tutorial about using OpenCV XML-YAML-JSON I/O functionality from C++ and Python.
2. added startWriteStruct() and endWriteStruct() methods to FileStorage
3. modifed FileStorage::write() methods to make them work well inside sequences, not only mappings.

* try to fix the doc builder

* added Python regression test for FileStorage I/O API ([TODO] iterating through long sequences can be very slow)

* fixed yaml testing
2020-06-01 11:33:09 +00:00
Vadim Levin 1d8c73cf6c feature: Added explicit support to header parser
- It is safe to remove `explicit` keyword for constructors with 1
argument, because it is C++ specific keyword and does not affect any of
the generated binding.
2020-04-15 14:25:39 +03:00
Alexander Alekhin 4b47c7dbd2 cmake(python): handle PYTHON3_LIMITED_API
- python-3.x => python-3
- config-3.x.py => config-3.py
2020-03-18 23:10:06 +00:00
Alexander Alekhin 7080c783d1 cmake: fix missing project() warning in Python standalone builds 2020-03-12 14:29:31 +03:00
Alexander Alekhin b7ecaceda8 pre: OpenCV 3.4.10 (version++)
- Android Manager version is not increased (stuck on 3.49)
2020-03-10 14:53:43 +03:00
Vadim Levin 90ec651bd7 test: Add test to verify correct mat substitution into the template in header parser 2020-03-04 08:14:19 +03:00
Zach Lowry 0aa5391c4b Use argument value for 'mat' in call to format for vector_mat and vector_mat_template
The hard-coded string value "Mat" was used in the two format strings for vector_mat and vector_mat_template, preventing UMat arguments to functions that have these types from working correctly. as noted in #12231.
2020-03-04 08:14:11 +03:00
cyy 450b96510e fixes #16500 2020-02-20 11:10:12 +08:00
Pavel Rojtberg e13a73d084 core: export getCPUFeaturesLine to bindings 2020-02-10 14:06:43 +01: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
Brian Wignall f9c514b391 Fix spelling typos
backport commit 659ffaddb4
2019-12-27 12:46:53 +00:00
Alexander Alekhin a45928045a Merge pull request #16150 from alalek:cmake_avoid_deprecated_link_private
* cmake: avoid deprecated LINK_PRIVATE/LINK_PUBLIC

see CMP0023 (CMake 2.8.12+)

* cmake: fix 3rdparty list

- don't include OpenCV modules
2019-12-13 17:52:40 +03:00
Alexander Alekhin 15612ebd39 python: enable Python 3.8 2019-12-11 16:52:38 +03:00
Alexander Alekhin 4ec4ec844f python: fix issue with bindings loading on Python 3.8 2019-12-10 19:00:10 +00:00