【发布时间】:2021-04-29 20:37:58
【问题描述】:
为了解决:https://pastebin.com/raw/my6VXj3H错误简述如下:
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 论坛中的建议,我决定删除 opencv-python 并安装 opencv-python-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'
【问题讨论】:
-
您引用的链接似乎已损坏。你能更新一下吗?
-
headless= 不支持 GUI(它甚至在 package description 中解释了这一点)......但由于某种原因,您试图调用 GUI 函数。 -
@YunusTemurlenk 链接没有损坏我现在又试了一次
-
@MonaJalal 您是否尝试过此处显示的任何建议:How to fix the error “QObject::moveToThread:” in opencv in python?。看起来这可能是由您的系统 pyqt 和 opencv 内置的系统之间的冲突引起的。
-
@MonaJalal 不要只看接受的答案,因为“接受”通常并不意味着“正确”。通读所有答案以及 cmets,因为您可能会从中学到更多。
标签: python qt opencv computer-vision pyqt5