opencv/modules/core
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
..
3rdparty/SoftFloat Add install component for 3rdparty libraries licenses 2018-03-06 16:32:30 +03:00
doc docs: intro formatting update, minor cleanup 2018-11-04 02:36:24 +00:00
include/opencv2 feat: update conversion logic for std::vector<T> in Python bindings 2021-09-01 13:00:21 +03:00
misc Fix/optimize Android put/get functions 2021-02-19 17:10:11 +09:00
perf Relax accuracy requirements in the OpenCL sqrt perf arithmetic test. 2021-04-06 17:32:48 +01:00
src feat: update conversion logic for std::vector<T> in Python bindings 2021-09-01 13:00:21 +03:00
test add test case 2021-08-25 14:32:40 +02:00
CMakeLists.txt core: rework code locality 2021-03-02 23:24:28 +00:00