-
Notifications
You must be signed in to change notification settings - Fork 882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cv2.imshow() not working consistently #362
Comments
Yeah, probably same issue as here: #356 I have no idea what causes that behavior. Qt4 version is the same, only the base image where the wheels and Qt4 are built was changed from |
@skvark Do you know any workaround to solve this? it happens on any version of opencv-contrib-python using ubuntu 20 |
I had a look at the linked OpenCV issue and it seems that this issue is related to Qt conflicts. There is no proper workaround for the latest wheels (see next message for some options). Best option would be to bundle Qt5 to the wheels (Qt4 is very old and does not behave well with other global Qt system installations) but there were major issues when I tried that during the manylinux version upgrade (#309). Auditwheel might as well cause the issue, it bundles the dependencies into the wheels and it might be doing something wrong. |
How to avoid this issue until it's solved:
|
I will rebuild the |
That didn't help, I'll need to probably start looking into Qt5 again... |
Looks like I got the Qt5 builds working (at least Travis tests are passing), but I need to still check that GUI functions actually work. Edit: still segfaulting... |
I patched |
This issue should be now fixed. Fixed wheels (3.4.10.37 and 4.3.0.38) will be soon up in PyPI. It will take probably about ~24 hours for all builds to finish. Please open a new issue if there are still problems related to GUI functions. |
What's the solution finally? |
Solution to this issue? Upgrade your |
upgrading to 4.3.0.38 did not work, still facing the same issue |
Please post exact install steps and how you are using |
upgrading to 4.4.0 fixed it, thank you! |
OpenCV 4.4 worked to show the image. But the warning is still there. |
@ahmad-sulehari Upgrading to 38+ resulted in the same issue as you. |
With 4.3.0.36, and only that version, I no longer get the original warning, but multiple windows open up when reusing (One thing I do notice is that it's easy to end up with an opencv-contrib-python package that is not the same version as opencv-python itself, which may add to some people's confusion in fiddling version installs). |
4.3.0.36 is known to have this broken behavior. These packages ship with their own copy of Qt. The Qt issues are always related to some other Qt installation on your system. Unfortunately, the only way to avoid conflicts between other Qt installations completely on Linux is to build this package from sources against your system Qt.
You should never install both |
Thanks a lot. Would you happen to recall how to build OpenCV from source in a way that gets picked up within a conda environment? |
I don't know about conda, these packages are for PyPI and |
In case it ever helps anyone for that qt compatibility situation, here's how to manage building from source for a conda environment, which I didn't see documented anywhere else. |
Use pip install opencv-python==4.2.0.34 . It worked for me. No warning and working consistently without any black image. |
got the same problem on 4.5.3.56, OS is Debian 11 |
Same problem with 4.5.3.56 on Ubuntu 18.04 and Python 3.8. |
Using the latest OpenCV at the moment(4.5.5.64) Ubuntu 18.04 and Python 3.8, but this behaviour is still happening. Any suggestions? |
If it everything is update per the previous comments. I found out it could be the image size, try using: def rescaleFram(frame, scale=0.75): 14.23 seconds in the video |
it same as me.. i using python 3.8 , ubuntu 20.04 and opencv version 4.8.0.76 and same problem happen.. are there any solution??? |
Expected behaviour
imshow displays image
Actual behaviour
when calling cv2.imshow(), I mostly get a small window with the correct name but containing only a black screen. It does work sometimes however but it is unpredictable. This issue was not encountered in previous versions of opencv-contrib-python.

Steps to reproduce
import cv2
import os
import imutils
image = cv2.imread("ref_image.png")
cv2.imshow("test", image)
cv2.waitKey(0)
cv2.destroyAllWindows()
The text was updated successfully, but these errors were encountered: