-
Notifications
You must be signed in to change notification settings - Fork 862
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
opencv GUI does not work #46
Comments
On which operating system? This is probably a bug in OpenCV or in your code and there's nothing I can do about it. And no need to report Qt version, wheels have Qt 4.8.7 embedded inside them. They do not use your system's Qt version. Are you sure you are using the prebuilt wheels? |
yepp, using prebuilt wheels. It is on ubuntu 14.04 |
I get the same error when attempting I'm on Ubuntu 16.04. |
@braindevices @TechnoConserve can you provide more information about your Ubuntu environment, the output of |
That does seem puzzling to me since it only picked up pip in one of my virtual environments regardless of whether I have the opencv virtual environment active or not.
|
Same error (also on 16.04 with python 3.5) |
Same error on Ubuntu 16.04 with python 3.5. Beaks at cv2.imshow('Test', img) |
Same error on Ubuntu 16.04 with python 2.7. Prints hundreds of error:
When calling cv2.waitKey() for the first time in a process. No other effects but the messages are very annoying. |
Same here, opencv 3.3.0 and ubuntu 16.04
And I already have installed libgtk2.0-dev and pkg-config |
Same here, opencv 3.3.0.10 and ubuntu 16.04 with python 3.5.2 cv2.imshow("image", image) |
GUI problem with opencv 3.4.0 and ubuntu 16.04 - python 2.7 |
First, uninstall any versions of OpenCV you may have installed. If you installed using pip: sudo pip uninstall opencv-python sudo apt-get install libopencv-dev python-opencv |
@caixiaofan This simply lets you use the opencv binding shipped in apt-get and stop using this repo. IMHO issues in this repo should focus on how to solve problems in this library. |
I guess the problem is that Ubuntu 16.04 opencv libraries are 2.4.9.1 and that doesn't work with opencv-python 3.x. I've got the same problem here - the apt-installed opencv-python 2.4.9.1 works fine but pip-installed opencv-python 3.4.0 fails with the very same program (simple imread()/imshow()) with:
Unfortunately opencv-python 2.4.9 doesn't support Python3 as far as I know so I'm stuck with Python2 for now. |
I'm sorry but I'm still unable to replicate this issue. I took a fresh Ubuntu 16.04.3 Virtualbox image and run multiple different tests and even tried to deliberately break the installation. No errors. Test script which I used:
Dynamic linking is OK. The static library which ships with these wheels should look like below when inspected through readelf and ldd. RPATH entry should point to the .libs/ folder which should contain these files:
Readelf:
ldd:
I did also To be able to fix this or to provide some solution, I still need more information. This means that every thing related to these is important:
Please note that
Releases page contains changelogs for this package: https://github.com/skvark/opencv-python/releases |
Hi. Having the same problem!
print("first window 1") cv2.namedWindow('test', cv2.WINDOW_AUTOSIZE) print("second window 2") cv2.imshow('test', black) print("third window 3") cv2.imshow('test', black) cv2.destroyAllWindows()`
The error that is showing to me is: QObject::moveToThread: Current thread (0x1697100) is not the object's thread (0x170e9a0). when it gets to the execution of cv2.imshow('test') Thank you for your help! I'm really stucked in here! |
@saeedranjbar12 I run into this problem too, So how to solve it? |
I have the same problem with opencv-python 3.4.0.12 (installed via pip) python 3.5.2, ubuntu 16.04.4 LTS, whenever I use cv2.namedWindow or cv2.imshow. No virtualenv, nothing fancy is needed:
Same is true for opencv-contrib-python. |
As I have written earlier, I can't replicate this behaviour with clean Ubuntu 16.04.4 image. Those two lines of code are not enough. I need more information about the environment because issue is most likely in some combination of other installed software (like PyQt) and |
Same error at all imshow calls It works well with smaller images (and stop working with
My workaround is this |
This comment has been minimized.
This comment has been minimized.
Could anyone give a good answer? The same problem happened to me as well. |
There's no solution but I suspect that the issue has something to do with conflicts between multiple Qt's. |
@skvark Thanks for your quick response. |
I didn't have this issue at first, then cv2.namedWindow just stopped working for me without me making any system changes. I noticed in dmesg the following: After a quick Google, I found this thread, which recommended removing the libqt5x11extras5 package. I just removed that (and the 121 dependent packages), and it's working properly again. So like @skvark mentioned, it's probably due to Qt conflicts. |
@coxbrandon thank you very much! Same problem, that solution worked like a charm. Thanks a lot! (I also had that number of dependent packages - on Linux Mint). |
If you have this issue: try to remove libqt5x11extras5 package (see @coxbrandon's message above) and please report here if that solution works for you. Note: do this at your own risk. |
I advise strongly against removing libqt5x11extras5 unless you know exactly what you are doing. It killed my lightdm display manager, and, sadly, didn't fix the issue for me. |
I did this and now I can't login on my Kubuntu.
Now I am trying to fix and then I will post the solution... |
@areche hats off to you debugging skills, it solved my problem in no time.. |
Areche debugging procedure above worked for me. In my case the problem library was kdelibs5-plugins which i think got installed with amarok, the music player. I guessed this was the problem library because i saw libQtCore being a part of this library in the output file. Thanks areche! |
Next |
How? It's going to conflict with any other Qt5 installation present just the same. |
It's the same major version so I assume it should have better compatibility. But of course there might be still some conflicts. Edit: by the same version I mean that most of the systems use Qt5 nowadays. Qt4 is very old and the issues might be related only to Qt4 versions. |
Thanks @NikkoWei. As I don't want to break my KDE DE I followed your instruction. test code runs perfectly.
|
you saved my day! |
FYI, it is possible to link to Qt statically, and we would have to either
For the 2nd option,
I.e. this is not any easier at all than providing the source code in the first place. So, I conclude that it would be much easier to update OpenCV to support namespaced Qt -- especially since supporting it is pretty straightforward -- and link against such a Qt.
|
I don't have segfaults or crashes; the window just shows up with no content (black bar?) when trying to import cv2
img = cv2.imread('/tmp/foo.png')
cv2.imshow('output', img)
cv2.waitKey(0) with the aforementioned moveToThread messages:
I am on a Manjaro system with python 3.8.3, opencv-python 4.3.0.36, KDE and Qt5 (although this should not matter as opencv-python ships with own version of Qt). Looking through the LD_DEBUG output, I can see the system Qt libs being loaded as a result of an indirect dependency from the opencv-python shipped Qt libs!
As you can see, the opencv-python provided libQtCore is dynamically loading this It would be great if some of the people on this thread with the same issue can check if they have the |
@freakabcd See #362 The latest issue with Qt4 is related to the |
Starting from 3.4.10.37 and 4.3.0.38 the pre-built wheels will include Qt 5.15 which has been built in a namespace so the conflict issue should be fixed. The new releases should be up in the next 24 hours. However, please note that I cannot guarantee that the wheels will work on all GNU/Linux systems. The new releases will include also source distributions which should allow to build the wheels locally if you encounter issues with the OpenCV GUI functions. |
I would just like to add that I get this same error on 4.3.0.38 and forward but not on 4.3.0.36. I'm running Elementary OS 5.1.7 Hera (Ubuntu based). I tried updating because cv2.imshow wasn't showing all of my images properly (some were just showing a small box instead of the image) and after updating they show as they should but I'm getting the same QObject::moveToThread error. |
@joelcma Yeah, that "small box" bug was this one which was also caused by a Qt conflict: #362 Can't help much with that QObject::moveToThread error. Just make sure that your Python environment is consistent and you have removed all old versions of |
It seem that I soved |
It didn't work for me, I have to submit a project but nothing seems to be working. I have Ubuntu 20.04 LTS, working in Spyder but unable to take videocapture. Please help. |
What do we do if we are still having this issue? (version 4.6) |
For those having this issue in Anaconda installation, just
that should fix your problems. |
1. Force to use scikit-learn>=1.3 to avoid `DeprecationWarning` from NumPy. 2. Use opencv-contrib-python-headless to avoid conflicts with PyQt installed with conda (https://stackoverflow.com/q/46449850 opencv/opencv-python#46 (comment)).
cv2.namedWindow('test', cv2.WINDOW_AUTOSIZE)
results in an error:here is the version:
The text was updated successfully, but these errors were encountered: