Open Source Computer Vision Library
Go to file
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
.github Updated more links to forum.opencv.org 2021-01-19 21:55:45 +03:00
3rdparty Merge pull request #20493 from abhi-bhatra:patch-1 2021-08-04 20:28:59 +03:00
apps Fix typo 'Applicatioin' 2020-11-17 15:02:55 +00:00
cmake Fixed typo in error message in OpenCVDetectCUDA.cmake 2021-07-26 14:54:27 +10:00
data fix files permissions 2020-04-13 04:29:55 +00:00
doc add links in python and js contours tutorial 2021-08-05 14:21:34 +03:00
include add missing DNN header to opencv2/opencv.hpp 2018-02-15 15:59:14 +01:00
modules feat: update conversion logic for std::vector<T> in Python bindings 2021-09-01 13:00:21 +03:00
platforms Merge pull request #20493 from abhi-bhatra:patch-1 2021-08-04 20:28:59 +03:00
samples Merge pull request #20564 from AleksandrPanov:update_kalman_sample 2021-08-20 10:57:05 +00:00
.editorconfig add .editorconfig 2018-10-11 17:57:51 +00:00
.gitattributes cmake: generate and install ffmpeg-download.ps1 2018-06-09 13:19:48 +03:00
.gitignore Ignore Visual Studio cmake configuration file 2020-03-17 21:12:54 +03:00
CMakeLists.txt Merge pull request #20399 from pablorcum:3.4 2021-07-13 19:40:15 +00:00
CONTRIBUTING.md migration: github.com/opencv/opencv 2016-07-12 12:51:12 +03:00
LICENSE copyright: 2021 2021-01-01 13:40:32 +00:00
README.md update forum link 2021-01-11 18:39:46 +00:00

OpenCV: Open Source Computer Vision Library

Resources

Contributing

Please read the contribution guidelines before starting work on a pull request.

Summary of the guidelines:

  • One pull request per issue;
  • Choose the right base branch;
  • Include tests and documentation;
  • Clean up "oops" commits before submitting;
  • Follow the coding style guide.