【发布时间】:2018-03-09 01:24:03
【问题描述】:
我在python中使用opencv2的代码
import cv2
cv2.namedWindow("output", cv2.WINDOW_NORMAL)
cv2.imshow("output",im)
cv2.resizeWindow('output', 400,400)
cv2.waitKey(0)
cv2.destroyAllWindows()
我的错误是
QObject::moveToThread: Current thread (0x1d2c9cf0) is not the object's thread (0x1d347b20).
Cannot move to target thread (0x1d2c9cf0)
我调试发现是在我使用cv2.waitKey(0)的时候出现的。我应该如何解决它?谢谢
更新:我使用的是 3.3.0.0。如果我使用旧版本,我有错误
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvDestroyAllWindows, file /io/opencv/modules/highgui/src/window.cpp, line 577
Traceback (most recent call last):
File "tools/demo_handbone.py", line 220, in <module>
demo(net, im_name)
File "tools/demo_handbone.py", line 159, in demo
cv2.destroyAllWindows()
cv2.error: /io/opencv/modules/highgui/src/window.cpp:577: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon 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
【问题讨论】:
-
我的猜测是 Qt 或最新版本的 opencv2 可能有错误发生了一些奇怪的事情。你最近升级了一个包吗?
-
对。我重新安装了opencv2,我遇到了问题。
-
尝试安装旧版本。你是用pip安装的吗?
-
是的。我用点子。如何在 python 中安装旧版本的 opencv?谢谢
-
pip install opencv-python==将列出可用的版本。然后你就用pip install opencv-python==3.1.0.0,例如。
标签: python python-2.7 opencv