`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.
G-API: Wrap render functionality to python
* Wrap render Rect prim
* Add all primitives and tests
* Cover mosaic and image
* Handle error in pyopencv_to(Prim)
* Move Mosaic and Rect ctors wrappers to shadow file
* Use GAPI_PROP_RW
* Fix indent
G-API: New python operations API
* Reimplement test using decorators
* Custom python operation API
* Remove wip status
* python: support Python code in bindings (through loader only)
* cleanup, skip tests for Python 2.x (not supported)
* python 2.x can't skip unittest modules
* Clean up
* Clean up
* Fix segfault python3.9
Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
this corrects bug #16592 where a Stream is created at
each GpuMat::load(arr,stream) call
a correct solution would have been to add a default to GpuMat::load
but due to circular dependence between Stream and GpuMat, this is not possible
add test_cuda_upload_download_stream to test_cuda.py
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.
* Add Python Bindings for getCacheDirectory function
* Added getCacheDirectory interop test with image codecs.
Co-authored-by: Sergey Slashchinin <sergei.slashchinin@xperience.ai>
[G-API] Introduce cv.gin/cv.descr_of for python
* Implement cv.gin/cv.descr_of
* Fix macos build
* Fix gcomputation tests
* Add test
* Add using to a void exceeded length for windows build
* Add using to a void exceeded length for windows build
* Fix comments to review
* Fix comments to review
* Update from latest master
* Avoid graph compilation to obtain in/out info
* Fix indentation
* Fix comments to review
* Avoid using default in switches
* Post output meta for giebackend
[G-API] Introduce GOpaque and GArray for python
* Introduce GOpaque and GArray for python
* Fix ctor
* Avoid code duplication by using macros
* gapi: move Python-specific files to misc/python
* Fix windows build
Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
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.
Return accumulator value in HoughLines algorithm
* try to solve #17050
use cv_wrap_as
add python test
parameters
* review
* move wrapper to imgproc/bindings.hpp