You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 manylinux1 to manylinux2014.
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.
I patched auditwheel and got Qt 5.15 working. Qt is also built in a namespace so it should not conflict with other systems Qt installations in the future. There is still some font related finetuning to do but it's far more easier to fix than the segmentation fault issue.
Reacted by DuncanMcRae, John Hagen and Thys Meintjes
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.
Please post exact install steps and how you are using opencv-python and please upgrade to 4.4.0. This issue has been fixed, the issue is very likely in your environment.
I am using the latest conda version for Debian on parrot OS security(updated to latest version)
I'm running my script in a venv with python3.7, qt5.9, OpenCV-python4.4.0.44
with this: QObject::moveToThread: Current thread (0x55e37f4716b0) is not the object's thread (0x55e37f6733f0).
Cannot move to target thread (0x55e37f4716b0)
I am using the latest conda version for Debian on parrot OS security(updated to latest version)
I'm running my script in a venv with python3.7, qt5.9, OpenCV-python4.4.0.44
with this: QObject::moveToThread: Current thread (0x55e37f4716b0) is not the object's thread (0x55e37f6733f0).
Cannot move to target thread (0x55e37f4716b0)
With 4.3.0.36, and only that version, I no longer get the original warning, but multiple windows open up when reusing imshow(), which was not the case before. Whereas installing 4.4.0.42 reverts back to the original problem of showing that warning message about thread switching that is mentioned above. This seems to be a known issue as described here. So I will really try to get to fix the underlying qt library conflict somehow.
(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).
With 4.3.0.36, and only that version, I no longer get the original warning, but multiple windows open up when reusing imshow(), which was not the case before. Whereas installing 4.4.0.42 reverts back to the original problem of showing that warning message about thread switching that is mentioned above. This seems to be a known issue as described here. So I will really try to get to fix the underlying qt library conflict somehow.
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.
(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).
You should never install both opencv-python and opencv-contrib-python. This will break your environment and may as well cause issues you are seeing. Follow the install instructions in the README and install only one package.
I don't know about conda, these packages are for PyPI and pip. If you use pip, follow the manual build instructions in the README. Conda has also their own OpenCV packages here: https://github.com/conda-forge/opencv-feedstock
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.
Activity
skvark commentedon Jul 16, 2020
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
manylinux1tomanylinux2014.skvark commentedon Jul 18, 2020
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.
skvark commentedon Jul 18, 2020
How to avoid this issue until it's solved:
manylinux1(4.2.0 and 3.4.9)skvark commentedon Jul 20, 2020
I will rebuild the
manylinux2014images and check if that fixes this issue, auditwheel has had some updates since the last build.skvark commentedon Jul 21, 2020
That didn't help, I'll need to probably start looking into Qt5 again...
skvark commentedon Jul 29, 2020
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...
skvark commentedon Aug 6, 2020
I patched
auditwheeland got Qt 5.15 working. Qt is also built in a namespace so it should not conflict with other systems Qt installations in the future. There is still some font related finetuning to do but it's far more easier to fix than the segmentation fault issue.skvark commentedon Aug 9, 2020
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.
ParthikB commentedon Aug 12, 2020
What's the solution finally?
skvark commentedon Aug 12, 2020
Solution to this issue? Upgrade your
opencv-pythonto version 4.3.0.38 or greater.SiddhantKumar14 commentedon Sep 15, 2020
upgrading to 4.3.0.38 did not work, still facing the same issue
skvark commentedon Sep 15, 2020
Please post exact install steps and how you are using
opencv-pythonand please upgrade to 4.4.0. This issue has been fixed, the issue is very likely in your environment.SiddhantKumar14 commentedon Sep 15, 2020
upgrading to 4.4.0 fixed it, thank you!
ahmad-sulehari commentedon Oct 6, 2020
I am using the latest conda version for Debian on parrot OS security(updated to latest version)

I'm running my script in a venv with python3.7, qt5.9, OpenCV-python4.4.0.44
with this: QObject::moveToThread: Current thread (0x55e37f4716b0) is not the object's thread (0x55e37f6733f0).
Cannot move to target thread (0x55e37f4716b0)
ganler commentedon Nov 15, 2020
OpenCV 4.4 worked to show the image. But the warning is still there.
ikram-hamizi commentedon Apr 25, 2021
@ahmad-sulehari Upgrading to 38+ resulted in the same issue as you.
To solve the
QObject::moveToThread:problem, only opencv==4.3.0.36 worked for me (following the comment here: #Yuliang-Liu/Curve-Text-Detector#11 (comment))matanox commentedon May 24, 2021
With 4.3.0.36, and only that version, I no longer get the original warning, but multiple windows open up when reusing
imshow(), which was not the case before. Whereas installing 4.4.0.42 reverts back to the original problem of showing that warning message about thread switching that is mentioned above. This seems to be a known issue as described here. So I will really try to get to fix the underlying qt library conflict somehow.(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).
skvark commentedon May 24, 2021
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
opencv-pythonandopencv-contrib-python. This will break your environment and may as well cause issues you are seeing. Follow the install instructions in the README and install only one package.matanox commentedon May 24, 2021
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?
skvark commentedon May 24, 2021
I don't know about conda, these packages are for PyPI and
pip. If you usepip, follow the manual build instructions in the README. Conda has also their own OpenCV packages here: https://github.com/conda-forge/opencv-feedstockmatanox commentedon May 25, 2021
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.
pk16514 commentedon Jul 29, 2021
Use pip install opencv-python==4.2.0.34 . It worked for me. No warning and working consistently without any black image.
leosongwei commentedon Sep 2, 2021
got the same problem on 4.5.3.56, OS is Debian 11
vocdex commentedon Apr 21, 2022
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?
angeliquemccl commentedon Jul 14, 2022
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
https://www.youtube.com/watch?v=oXlwWbU8l2o
apolloo43 commentedon Mar 24, 2024
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???