Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Python: unable to pass 3D matrix to C++ code #19091

Closed
@alalek

Description

@alalek

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_32FC4

Related 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.


relates#17272
relates#19001
probably relates#18413#17456

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp