opencv/modules/python/test
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
..
CMakeLists.txt python: discover tests from module/misc/python/test paths 2019-04-10 18:35:35 +00:00
test_algorithm_rw.py Fix spelling typos 2019-12-27 12:46:53 +00:00
test_async.py core: Async API / AsyncArray 2019-05-18 19:32:23 +00:00
test_camshift.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_dft.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_filestorage_io.py Merge pull request #17436 from vpisarev:fix_python_io 2020-06-01 11:33:09 +00:00
test_fitline.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_gaussian_mix.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_grabcut.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_houghcircles.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_houghlines.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_kmeans.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_legacy.py feat: update conversion logic for std::vector<T> in Python bindings 2021-09-01 13:00:21 +03:00
test_misc.py feat: update conversion logic for std::vector<T> in Python bindings 2021-09-01 13:00:21 +03:00
test_morphology.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_mser.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_norm.py Merge pull request #15915 from VadimLevin:dev/norm_fix 2020-01-13 18:11:34 +03:00
test_persistence.py Fix spelling typos 2019-12-27 12:46:53 +00:00
test_squares.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_texture_flow.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test_umat.py test: Add test to verify correct mat substitution into the template in header parser 2020-03-04 08:14:19 +03:00
test_watershed.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00
test.py fix python test runner wildcard handling 2021-01-26 19:05:40 +01:00
tests_common.py 3.4: fixes 2018-09-18 08:31:11 +00:00
tst_scene_render.py python: 'cv2.' -> 'cv.' via 'import cv2 as cv' 2017-12-11 13:46:55 +03:00