opencv / opencv/opencv-python

How to convert cv2.Mat() to cv2.UMat()

Open
#1,030 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.4k
Forks
1k
Avg merge
22h 17m
Merged PRs (30d)
3

Description

Hello, I am trying to write some glue code for a third-party library.
In the code, I need to return a data of type cv2.UMat.
Now I can use cv2.Mat(descs) to get a Mat, but I can't find a way to convert cv2.Mat to cv2.UMat.
I tried umat = cv.UMat(mat), mat.copyTo(umat), umat = cv.UMat(descs.shape[0], descs.shape[1], descs.dtype, cv.USAGE_DEFAULT), but none of them worked.
I found on the Internet that there seems to be such a method in C to convert Mat to UMat, but I can't seem to find it in Python.
Can you give some suggestions?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported conversions with cv2.Mat and cv2.UMat, then inspect the Python binding entry points for these types and compare them with the available C API. Done means the supported conversion path is identified and covered by an appropriate binding change or documented limitation, but the issue names no files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.