Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork56.4k
Closed
Description
Currently OpenCV Python bindings "automatically" converts 3D NumPy arrays into 2Dcv::Mat with wrapping last dimension onto number of channels (to simulateImage with colors):
a = np.zeros((2,3,4), dtype='f')print(a.shape)info = cv.utils.dumpInputArray(a)print(info)output:
(2, 3, 4)InputArray: empty()=false kind=0x00010000 flags=0x01010000 total(-1)=6 dims(-1)=2 size(-1)=3x2 type(-1)=CV_32FC4Related code ishere (previous variant of similar code ishere from 2010). By initial design there is support for 2D matrices and 1D arrays only.
So currently there is no way to pass 3Dcv::Mat (1-channel) from Python to C++ code.
Just changing of mentioned code is not an option due to breaking of many user applications.
Compatibility should be preserved.
Note: There is such issue in Java because Java'sMat type is used.
Python's bindings relies onnp.array type which leads to mentioned reinterpretation issues.