How to fix the error “QObject::moveToThread:” in opencv in python?

前端 未结 15 2154
栀梦
栀梦 2020-12-10 11:18

I am using opencv2 in python with the code

import cv2
cv2.namedWindow(\"output\", cv2.WINDOW_NORMAL)       
cv2.imshow(\"output\",im)
cv2.resizeWindow(\'outp         


        
15条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 11:59

    I solved this issue and I posted my solution in related issue on OpenCV github page. But for your convenience, I will post it here also.

    In my case, I did almost all the solutions:

    • installing using pip3 install opencv-python
    • installing using apt install python-opencv
    • I followed @areche solution, I end up with kdelibs5-plugins which was an important module for most of my desktop environments, so I give up on uninstalling it.

    Finally, I found a solution for my case

    • pip uninstall opencv-python on all instances of my python and virtual environments
    • pip3 uninstall opencv-python on all instances of my python and virtual environments
    • sudo apt remove python-opencv

    then I downloaded the most recent opencv, in my case opencv-4.1.1 , I build it. for building :

    mkdir build; cd build; ccmake .. then I pressed pressed c, again pressed c, then pressed g to generate make files, then sudo make -j8 after successful building, I copied build\lib\python3\cv2.cpython.xxxxxx.so to usr/local/lib/python3.5/dist-packages/ and renamed it to cv2.so Do the same for each virtualenv that you have. ( I'm not sure if it is logical, but it worked for me).

    then everything worked fine without any error.

提交回复
热议问题