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()
I have the error as
QObject::moveToThread: Current thread (0x1d2c9cf0) is not the object's thread (0x1d347b20). Cannot move to target thread (0x1d2c9cf0)
I debug and found that it happened when I use cv2.waitKey(0)
. How should I fix it? Thanks
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
I got same problem, it was from opencv-python
version problem for me.
My Linux machine's environment is as following:
$ cat /etc/lsb-release ... DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS" $ date Tue Aug 11 11:43:16 KST 2020 $ python --version Python 3.7.8 $ pip list|grep Qt PyQt5 5.15.0 PyQt5-sip 12.8.0 $ pip list|grep opencv-python opencv-python 4.3.0.38
I downgraded opencv-python 4.3.0.38 to 4.3.0.36.
$ pip uninstall opencv-python $ pip install opencv-python==4.3.0.36 $ pip list|grep opencv-python opencv-python 4.3.0.36
First, uninstall any versions of OpenCV you may have installed. If you installed using pip
:
sudo pip uninstall opencv-python
Next, try installing OpenCV using your Linux distro's package manager. For Ubuntu/Debian, this is:
sudo apt-get install libopencv-dev python-opencv
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With