安装opencv python headless时未实现cv2.destroyAllWindows()
为了解决:错误简要说明如下:安装opencv python headless时未实现cv2.destroyAllWindows(),python,qt,opencv,computer-vision,pyqt5,Python,Qt,Opencv,Computer Vision,Pyqt5,为了解决:错误简要说明如下: Got keys from plugin meta data ("xcb") loaded library "/home/mona/venv/vision/lib/python3.8/site-packages/cv2/qt/plugins/platforms/libqxcb.so" QObject::moveToThread: Current thread (0x34390e0) is not the object's th
Got keys from plugin meta data ("xcb")
loaded library "/home/mona/venv/vision/lib/python3.8/site-packages/cv2/qt/plugins/platforms/libqxcb.so"
QObject::moveToThread: Current thread (0x34390e0) is not the object's thread (0x3527410).
Cannot move to target thread (0x34390e0)
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/mona/venv/vision/lib/python3.8/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.
根据Qt论坛上的建议,我决定删除opencvpython
并安装opencvpython headless
这最初解决了问题,但现在抛出以下opencv错误
如何解决此opencv错误
(vision) mona@goku:~/research/code/vision/integration$ pip install --upgrade pip
Requirement already satisfied: pip in /home/mona/venv/vision/lib/python3.8/site-packages (20.3.3)
Collecting pip
Downloading pip-21.0-py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 3.6 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.3.3
Uninstalling pip-20.3.3:
Successfully uninstalled pip-20.3.3
Successfully installed pip-21.0
(vision) mona@goku:~/research/code/vision/integration$ pip install opencv-python-headless
Collecting opencv-python-headless
Using cached opencv_python_headless-4.5.1.48-cp38-cp38-manylinux2014_x86_64.whl (37.6 MB)
Requirement already satisfied: numpy>=1.17.3 in /home/mona/venv/vision/lib/python3.8/site-packages (from opencv-python-headless) (1.19.5)
Installing collected packages: opencv-python-headless
Successfully installed opencv-python-headless-4.5.1.48
运行我的代码后,出现以下错误:
cv2.destroyAllWindows()
cv2.error: OpenCV(4.5.1) /tmp/pip-req-build-jhawztrk/opencv/modules/highgui/src/window.cpp:645: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvDestroyAllWindows'
我安装的最新版本opencv python导致pyqt5出现问题。因此,我卸载了它并安装了以下版本:
$ pip install opencv-python==4.3.0.36
添加以下信息,以防对未来读者有所帮助
以下是我的pyqt版本:
$ pip list|grep Qt
PyQt5 5.15.2
PyQt5-sip 12.8.1
$ python
Python 3.8.5 (default, Jul 28 2020, 12:59:40)
[GCC 9.3.0] on linux
$ pip --version
pip 21.0 from /home/mona/venv/vision/lib/python3.8/site-packages/pip (python 3.8)
$ lsb_release -a
LSB Version: core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
信用证:您引用的链接似乎已断开。你能更新它吗?
headless
=没有GUI支持(它甚至在。。。。但由于某种原因,您试图调用GUI函数。@YunusTemurlenk链接没有断开,我又试了一次now@MonaJalal您是否尝试过此处显示的任何建议:。看起来这可能是由于您的系统pyqt与内置于opencv中的系统pyqt之间存在冲突造成的。@MonaJalal不要只看接受的答案,因为“接受”通常并不意味着“正确”。通读所有答案和评论,因为你可能会从中学到更多。