Repository: opencv
Issue: Support for array-like classes in Python
Labels: feature,category: python bindings

##### System information (version)
- OpenCV => 4.4
- NumPy => 1.16
- Operating System / Platform => Windows 64 Bit

##### Detailed description

NumPy allows [writing custom N-dimensional array containers](https://numpy.org/doc/stable/user/basics.dispatch.html) by relying on `__array__` interface.
We can convert such classes to a numpy array using `numpy.array` or `numpy.asarray`, which will call its `__array__` method to obtain a standard `numpy.ndarray`. If we operate on arr with a numpy function, numpy will again use the `__array__` interface to convert it to an array and then apply the function in the usual way.

However OpenCV ignores this interface. It forces user to pass `numpy.ndarray` or `cv2.UMat` instances, but not classes with `__array__` interface.

##### Steps to reproduce

```.py
import cv2
import numpy as np

class ArrayLike:
    def __array__(self):
        return np.arange(25, dtype='u1').reshape(5, 5)

arr = ArrayLike()

# This works, type of `x` is `np.ndarray`, conversion happens implicitly
x = np.add(arr, 5)  

# This also works
cv2.add(np.array(arr), 5)

# But this fails with `TypeError: Expected Ptr<cv::UMat> for argument 'src1'`
cv2.add(arr, 5)
```

##### Issue submission checklist

 - [x] I report the issue, it's not a question
   <!--
   OpenCV team works with answers.opencv.org, Stack Overflow and other communities
   to discuss problems. Tickets with question without real issue statement will be
   closed.
   -->
 - [x] I checked the problem with documentation, FAQ, open issues,
       answers.opencv.org, Stack Overflow, etc and have not found solution
   <!--
   Places to check:
   * OpenCV documentation: https://docs.opencv.org
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ
   * OpenCV forum: https://answers.opencv.org
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
   -->
 - [x] I updated to latest OpenCV version and the issue is still there
   <!--
   master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
   OpenCV team supports only latest release for each branch.
   The ticket is closed, if the problem is not reproduced with modern version.
   -->
 - [x] There is reproducer code and related data files: videos, images, onnx, etc
   <!--
   The best reproducer -- test case for OpenCV that we can add to the library.
   Recommendations for media files and binary files:
   * Try to reproduce the issue with images and videos in opencv_extra repository
     to reduce attachment size
   * Use PNG for images, if you report some CV related bug, but not image reader
     issue
   * Attach the image as archive to the ticket, if you report some reader issue.
     Image hosting services compress images and it breaks the repro code.
   * Provide ONNX file for some public model or ONNX file with with random weights,
     if you report ONNX parsing or handling issue. Architecture details diagram
     from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
   -->