Skip to content

[FIX #18553] Enable imshow to take GpuMat inputs in Python#18588

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
damonmo:fix-issue-18553
Oct 19, 2020
Merged

[FIX #18553] Enable imshow to take GpuMat inputs in Python#18588
opencv-pushbot merged 1 commit intoopencv:masterfrom
damonmo:fix-issue-18553

Conversation

@damonmo
Copy link
Copy Markdown

@damonmo damonmo commented Oct 14, 2020

This pull request fixes #18553 by making the Python bindings generator create a declaration for 'imshow' that works with GpuMat inputs under Python.

Pull Request Readiness Checklist

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work

@alalek
Copy link
Copy Markdown
Member

alalek commented Oct 14, 2020

Bindings generator should stay universal to avoid maintenance hell. It should not known about exact functions.

What is about cv.cuda.imshow() wrapper?

@damonmo
Copy link
Copy Markdown
Author

damonmo commented Oct 14, 2020

Bindings generator should stay universal to avoid maintenance hell. It should not known about exact functions.

What is about cv.cuda.imshow() wrapper?

Thanks for your comment and the hard work you put in this project @alalek, I understand your concern, though from the users perspective I believe it is more intuitive to use cv2.imshow regardless of the input type as it is described in the documentation rather than having a separate function for GpuMat inputs.

In any case leaving it up to your criteria, we can either move on with the current PR or modify it / create a new one with a cv.cuda.cuda_imshow wrapper function (I tried to name it cv.cuda.imshow but I got name conflict errors while building it, I can see if it is a solvable problem though).

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for looking into this!
I agree, that updating of bindings generator require much more hard work. Both UMat and GpuMat additions need to be refactored.

Lets put this hack for now. Hopefully we didn't get here very long list of functions here.

decls.append(decl)

if self._generate_gpumat_decls and "cv.cuda" in decl[0]:
if self._generate_gpumat_decls and any(x in decl[0] for x in ("cv.cuda", "imshow")):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition looks weak.
Please add this decl[0] == 'cv.imshow' instead.


Or in this form for easy expansion (one new line per case):

delc[0] in [
    'cv.imshow',  # https://github.com/opencv/opencv/issues/18553
]

@damonmo
Copy link
Copy Markdown
Author

damonmo commented Oct 19, 2020

Thanks @alalek , I have updated the PR with your suggested change, let me know if anything else is required.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 👍

@opencv-pushbot opencv-pushbot merged commit 1729297 into opencv:master Oct 19, 2020
@alalek alalek mentioned this pull request Nov 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python cv2.imshow does not work for GpuMat inputs

3 participants