如何修复错误"QObject :: moveToThread:";在python中的opencv中? [英] How to fix the error "QObject::moveToThread:" in opencv in python?

查看:147
本文介绍了如何修复错误"QObject :: moveToThread:";在python中的opencv中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在python代码中使用opencv2

I am using opencv2 in python with the code

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)时发生的.我该如何解决?谢谢

I debug and found that it happened when I use cv2.waitKey(0). How should I fix it? Thanks

更新:我正在使用3.3.0.0.如果我使用的是旧版本,则会出现错误

Update: I am using 3.3.0.0. If I use older version, I have error

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

推荐答案

首先,卸载可能已安装的任何版本的OpenCV.如果您使用pip安装:

First, uninstall any versions of OpenCV you may have installed. If you installed using pip:

sudo pip uninstall opencv-python

接下来,尝试使用Linux发行版的软件包管理器安装OpenCV.对于Ubuntu/Debian,这是:

Next, try installing OpenCV using your Linux distro's package manager. For Ubuntu/Debian, this is:

sudo apt-get install libopencv-dev python-opencv

这篇关于如何修复错误"QObject :: moveToThread:";在python中的opencv中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆