Skip to content

opencv GUI does not work #46

Closed
Closed

Description

@braindevices

cv2.namedWindow('test', cv2.WINDOW_AUTOSIZE) results in an error:

QObject::moveToThread: Current thread (0xca9110) is not the object's thread (0x1256140).
Cannot move to target thread (0xca9110)

here is the version:

cv2.__version__
Out[3]: '3.3.0'
QtCore.QT_VERSION_STR
Out[7]: '5.6.2'

Activity

  1. skvark commented on Sep 12, 2017

    @skvark
    Member

    On which operating system? This is probably a bug in OpenCV or in your code and there's nothing I can do about it.

    And no need to report Qt version, wheels have Qt 4.8.7 embedded inside them. They do not use your system's Qt version.

    Are you sure you are using the prebuilt wheels?

  2. braindevices commented on Sep 12, 2017

    @braindevices
    Author

    yepp, using prebuilt wheels. It is on ubuntu 14.04

  3. skvark commented on Sep 12, 2017

    @skvark
    Member

    Works fine on Ubuntu 14.04:

    screenshot from 2017-09-12 17_02_04

    Can you post more code?

  4. TechnoConserve commented on Sep 22, 2017

    @TechnoConserve

    I get the same error when attempting cv2.namedWindow('test', cv2.WINDOW_AUTOSIZE), but only when using python3.5

    I'm on Ubuntu 16.04.

  5. techdragon commented on Oct 4, 2017

    @techdragon
    Contributor

    @braindevices @TechnoConserve can you provide more information about your Ubuntu environment, the output of which -a python3, which -a pip, pip freeze, env (Always remember to check for any secret information that shouldn't be shared such as API keys or other items before you post the output of env) , and apt list --installed would all prove useful.

  6. TechnoConserve commented on Oct 4, 2017

    @TechnoConserve
    uname -a
    Linux ave-GL552VW 4.10.0-35-generic #39~16.04.1-Ubuntu SMP Wed Sep 13 09:02:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    
    which -a python3
    /home/ave/venv/opencv/bin/python3
    /home/ave/venv/potato/bin/python3
    /usr/bin/python3
    
    which -a pip
    /home/ave/venv/potato/bin/pip
    /home/ave/.local/bin/pip
    /usr/local/bin/pip
    /usr/bin/pip
    

    That does seem puzzling to me since it only picked up pip in one of my virtual environments regardless of whether I have the opencv virtual environment active or not.

    pip freeze
    apparmor==2.10.95
    apparmor.click==0.3.13.1
    apt-xapian-index==0.47
    apturl==0.5.2
    awscli==1.11.155
    beautifulsoup4==4.6.0
    blinker==1.3
    botocore==1.7.13
    Brlapi==0.6.4
    certifi==2017.7.27.1
    chardet==3.0.4
    checkbox-support==0.22
    click==0.4.43+16.4.20170613.0ubuntu1
    colorama==0.3.7
    command-not-found==0.3
    cryptography==1.2.3
    defer==1.0.6
    Django==1.11.5
    django-modelcluster==3.1
    django-taggit==0.22.1
    django-treebeard==4.1.2
    djangorestframework==3.6.4
    docutils==0.14
    feedparser==5.1.3
    guacamole==0.9.2
    html5lib==0.999
    httplib2==0.9.1
    idna==2.6
    Jinja2==2.8
    jmespath==0.9.3
    language-selector==0.1
    LibAppArmor==2.10.95
    louis==2.6.4
    lxml==3.5.0
    Mako==1.0.3
    MarkupSafe==0.23
    numpy==1.13.1
    oauthlib==1.0.3
    onboard==1.2.0
    opencv-python==3.3.0.10
    padme==1.1.1
    pexpect==4.0.1
    Pillow==3.1.2
    pkg-resources==0.0.0
    plainbox==0.25
    psycopg2==2.7.3.1
    ptyprocess==0.5
    pyasn1==0.3.5
    pycups==1.9.73
    pycurl==7.43.0
    pygobject==3.20.0
    PyJWT==1.3.0
    pyparsing==2.0.3
    python-apt==1.1.0b1
    python-dateutil==2.6.1
    python-debian==0.1.27
    python-gnupg==0.3.8
    python-systemd==231
    pytz==2017.2
    pyxdg==0.25
    PyYAML==3.12
    reportlab==3.3.0
    requests==2.18.4
    rsa==3.4.2
    s3transfer==0.1.11
    sessioninstaller==0.0.0
    six==1.11.0
    system-image==3.1
    system-service==0.3
    ubuntu-drivers-common==0.0.0
    ufw==0.35
    unattended-upgrades==0.1
    Unidecode==0.4.21
    unity-scope-calculator==0.1
    unity-scope-chromiumbookmarks==0.1
    unity-scope-colourlovers==0.1
    unity-scope-devhelp==0.1
    unity-scope-firefoxbookmarks==0.1
    unity-scope-manpages==0.1
    unity-scope-openclipart==0.1
    unity-scope-texdoc==0.1
    unity-scope-tomboy==0.1
    unity-scope-virtualbox==0.1
    unity-scope-yelp==0.1
    unity-scope-zotero==0.1
    urllib3==1.22
    usb-creator==0.3.0
    uWSGI==2.0.15
    wagtail==1.12.2
    Willow==0.4
    xdiagnose==3.8.4.1
    xkit==0.0.0
    XlsxWriter==0.7.3
    
    env
    XDG_VTNR=7
    KDE_MULTIHEAD=false
    SSH_AGENT_PID=2482
    XDG_SESSION_ID=2
    PAM_KWALLET5_LOGIN=/tmp/kwallet5_ave.socket
    TERM=xterm
    SHELL=/bin/bash
    KONSOLE_DBUS_SERVICE=:1.31
    GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/ave/.gtkrc-2.0:/home/ave/.config/gtkrc-2.0
    KONSOLE_PROFILE_NAME=Green
    QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1
    GS_LIB=/home/ave/.fonts
    GTK_RC_FILES=/etc/gtk/gtkrc:/home/ave/.gtkrc:/home/ave/.config/gtkrc
    WINDOWID=58720261
    OLDPWD=/home/ave/PycharmProjects/potato-project/potato
    SHELL_SESSION_ID=b8195832c1774000aa88ccc122cc6b7b
    GTK_MODULES=gail:atk-bridge
    XDG_SESSION_CLASS=user
    KDE_FULL_SESSION=true
    USER=ave
    QT_ACCESSIBILITY=1
    LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
    XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1
    XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
    SSH_AUTH_SOCK=/tmp/ssh-YXVwNQB4fLBl/agent.2436
    SESSION_MANAGER=local/ave-GL552VW:@/tmp/.ICE-unix/2732,unix/ave-GL552VW:/tmp/.ICE-unix/2732
    DEFAULTS_PATH=/usr/share/gconf//usr/share/xsessions/plasma.default.path
    VIRTUAL_ENV=/home/ave/venv/opencv
    XDG_CONFIG_DIRS=/etc/xdg/xdg-/usr/share/xsessions/plasma:/etc/xdg:/usr/share/kubuntu-default-settings/kf5-settings
    DESKTOP_SESSION=/usr/share/xsessions/plasma
    PATH=/home/ave/venv/opencv/bin:/home/ave/venv/potato/bin:/home/ave/bin:/home/ave/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
    QT_IM_MODULE=compose
    QT_QPA_PLATFORMTHEME=kde
    PWD=/home/ave/venv
    XDG_SESSION_TYPE=x11
    LANG=en_US.UTF-8
    KDE_SESSION_UID=1000
    MANDATORY_PATH=/usr/share/gconf//usr/share/xsessions/plasma.mandatory.path
    PS1=(opencv) \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ 
    KONSOLE_DBUS_SESSION=/Sessions/1
    GTK2_MODULES=overlay-scrollbar
    COLORFGBG=15;0
    HOME=/home/ave
    SHLVL=2
    XDG_SEAT=seat0
    KDE_SESSION_VERSION=5
    LANGUAGE=
    XCURSOR_THEME=breeze_cursors
    LOGNAME=ave
    XDG_SESSION_DESKTOP=KDE
    DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-UiuOcMuIpB,guid=2d3de9776ef25a2171e6481959c98ad4
    XDG_DATA_DIRS=/usr/share//usr/share/xsessions/plasma:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
    LESSOPEN=| /usr/bin/lesspipe %s
    XDG_RUNTIME_DIR=/run/user/1000
    DISPLAY=:0
    PROFILEHOME=
    XDG_CURRENT_DESKTOP=KDE
    PAM_KWALLET_LOGIN=/tmp/kwallet_ave.socket
    LESSCLOSE=/usr/bin/lesspipe %s %s
    ZADDR=zcbZsZdkHfGqbgUjZuM7KiJ7x2ayXLLbXfB8eryRqatW64hhqRK7W74Whjq95jFHKzyTYbnTFnNZBRM8cJ9Q6hVcGGWd7BT
    XAUTHORITY=/tmp/xauth-1000-_0
    _=/usr/bin/env
    
  7. dzimmerer commented on Oct 20, 2017

    @dzimmerer

    Same error (also on 16.04 with python 3.5)

  8. djokjulapfe commented on Oct 21, 2017

    @djokjulapfe

    Same error on Ubuntu 16.04 with python 3.5. Beaks at cv2.imshow('Test', img)

  9. sibojia commented on Nov 15, 2017

    @sibojia

    Same error on Ubuntu 16.04 with python 2.7. Prints hundreds of error:

    
    QObject::moveToThread: Current thread (0x5563aa165a20) is not the object's thread (0x5563aa278b20).
    Cannot move to target thread (0x5563aa165a20)
    

    When calling cv2.waitKey() for the first time in a process. No other effects but the messages are very annoying.
    cv2.__version__ = 3.3.0

  10. ridho9 commented on Nov 19, 2017

    @ridho9

    Same here, opencv 3.3.0 and ubuntu 16.04
    Trying cv2.namedWindow('test', cv2.WINDOW_AUTOSIZE) with 3.3.0.10 returns the same QObject error, but using 3.2.0.8 returns

    <ipython-input-3-2efaecccc8a8> in <module>()
    ----> 1 cv2.namedWindow('test', cv2.WINDOW_AUTOSIZE)
    
    error: /io/opencv/modules/highgui/src/window.cpp:565: 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 cvNamedWindow
    

    And I already have installed libgtk2.0-dev and pkg-config

  11. ibrmora commented on Dec 11, 2017

    @ibrmora

    Same here, opencv 3.3.0.10 and ubuntu 16.04 with python 3.5.2 cv2.imshow("image", image)

  12. saeedranjbar12 commented on Jan 9, 2018

    @saeedranjbar12

    GUI problem with opencv 3.4.0 and ubuntu 16.04 - python 2.7

  13. caixiaofan commented on Jan 18, 2018

    @caixiaofan

    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

    copy from https://reformatcode.com/code/python/how-to-fix-the-error-quotqobjectmovetothreadquot-in-opencv-in-python

  14. sibojia commented on Jan 19, 2018

    @sibojia

    @caixiaofan This simply lets you use the opencv binding shipped in apt-get and stop using this repo. IMHO issues in this repo should focus on how to solve problems in this library.

  15. 68 remaining items

  16. skvark commented on Apr 7, 2020

    @skvark
    Member

    Next opencv-python release will include Qt5 instead of Qt4. That change will most likely solve this issue.

    How? It's going to conflict with any other Qt5 installation present just the same.

    It's the same major version so I assume it should have better compatibility. But of course there might be still some conflicts.

    Edit: by the same version I mean that most of the systems use Qt5 nowadays. Qt4 is very old and the issues might be related only to Qt4 versions.

  17. anik-kucse commented on Apr 7, 2020

    @anik-kucse

    Thanks @NikkoWei. As I don't want to break my KDE DE I followed your instruction. test code runs perfectly.

    It's risky to remove libqt5x11extras5 or kde-style-breeze-qt4 for environment which need the modules.
    In my case, I work on Ubuntu with KDE. So libqt5x11extras5 or kde-style-breeze-qt4 are important for my desktop environment.

    I found there are Qt conflicts between those in opencv-python package and those in system path. The steps to find the problem are the same as @areche:

    1. Display the library loading problems
        export LD_DEBUG=all
    1. Edit script to cause the problem
    # fail.py
    import cv2
    im = cv2.imread('img.jpg')
    cv2.imshow('image',im)
    cv2.waitKey(0)
    1. Export the library loading information
        python fail.py 2>output.txt
    1. I found there are two version of Qt are used by loader in output.txt:
        ...
    
         10836:	symbol=_ZNSbIwSt11char_traitsIwESaIwEEC1ERKS2_;  lookup in file=/home/lnwei/.conda/envs/opencv_test/lib/python3.6/site-packages/cv2/.libs/libQtGui-903938cd.so.4.8.7 [0]
         10836:	symbol=_ZNSbIwSt11char_traitsIwESaIwEEC1ERKS2_;  lookup in file=/home/lnwei/.conda/envs/opencv_test/lib/python3.6/site-packages/cv2/.libs/libQtTest-1183da5d.so.4.8.7 [0]
         10836:	symbol=_ZNSbIwSt11char_traitsIwESaIwEEC1ERKS2_;  lookup in file=/home/lnwei/.conda/envs/opencv_test/lib/python3.6/site-packages/cv2/.libs/libQtCore-6df570dd.so.4.8.7 [0]
    
         ...
    
         10836:	symbol=_ZTI14QWindowSurface;  lookup in file=/usr/lib/x86_64-linux-gnu/libQtDBus.so.4 [0]
         10836:	symbol=_ZTI14QWindowSurface;  lookup in file=/usr/lib/x86_64-linux-gnu/libQtCore.so.4 [0]
         10836:	symbol=_ZTI14QWindowSurface;  lookup in file=/usr/lib/x86_64-linux-gnu/libQtGui.so.4 [0]
    
         ...
    

    As you see, there are two version Qtlib are used: 4.8.7 in the python packages path(I use conda environment) and 4 in the system path.
    So it's probably the Qt conflicts.

    There are 2 ways to solve this problem:

    1. Rebuild opencv by source to link Qtlib in system path. After make -j8, move the python library of opencv to overwrite the library in your python packages environment

      cp /path/to/build/lib/python3/cv2.cpython-36m-x86_64-linux-gnu.so /home/lnwei/.conda/envs/opencv_test/lib/python3.6/site-packages/cv2/cv2.cpython-36m-x86_64-linux-gnu.so
    2. Just replace Qtlib in the python packages by Qtlib in system (according to output.txt)

      cp /usr/lib/x86_64-linux-gnu/libQtGui.so.4 ./libQtGui-903938cd.so.4.8.7
      
      cp /usr/lib/x86_64-linux-gnu/libQtCore.so.4 ./libQtCore-6df570dd.so.4.8.7 

      I can't find libQtTest in my system path but it make no difference.

    The 2 solution are OK for my case.

  18. hedoluna commented on Apr 28, 2020

    @hedoluna

    I didn't have this issue at first, then cv2.namedWindow just stopped working for me without me making any system changes. I noticed in dmesg the following:
    python[29883]: segfault at 0 ip 00007fa8c3c114be sp 00007ffcf5c34740 error 4 in libxcb.so.1.1.0[7fa8c3c07000+21000]

    After a quick Google, I found this thread, which recommended removing the libqt5x11extras5 package. I just removed that (and the 121 dependent packages), and it's working properly again. So like @skvark mentioned, it's probably due to Qt conflicts.

    you saved my day!

  19. native-api commented on Apr 28, 2020

    @native-api
    Contributor

    Anyway, without knowing if linking statically is even possible and solves the problem, legal debates are over nothing.

    FYI, it is possible to link to Qt statically, and we would have to either

    • provide opencv-python and OpenCV source code (and require anyone else who conveys it to do the same) -- i.e. relicense opencv-python as strong copyleft; or
    • provide object files for the closed-source parts that a user would be able to link (statically) with a modified (static) Qt, as well as instructions on how to do this, in some form.

    For the 2nd option,

    • I believe the temporary cmake-build directory tree, without the resulting Python module, would qualify. In essence, we need the makefiles to pick up the object files without recompiling them and perform linking for whatever links to Qt and all the way up to the extension module as usual. Not sure if CMake-generated makefiles can do that, or they would complain and require OpenCV sources as well to check if the object files are up to date.
    • An archive of this tree for each release with static Qt would need to be available to opencv-python users somehow -- e.g. at Github releases page (for at least 3 years since release date).
    • LICENSE-3RD-PARTY.txt would need to refer to that location in its Qt section.
    • Anyone who conveys opencv-python would have the same obligation and would either have to rely on us, or (e.g. if they make modifications), provide such an archive themselves and update LICENSE-3RD-PARTY.txt accordingly.

    I.e. this is not any easier at all than providing the source code in the first place.


    So, I conclude that it would be much easier to update OpenCV to support namespaced Qt -- especially since supporting it is pretty straightforward -- and link against such a Qt.

    • In Linux, it's as trivial as adding a configuration switch to dockerfiles since we compile Qt ourselves
    • In OSX, will have to make a custom Qt formula and compile it from source just like for FFMpeg.
  20. freakabcd commented on Jul 26, 2020

    @freakabcd

    I don't have segfaults or crashes; the window just shows up with no content (black bar?) when trying to imshow with the following code:

    import cv2
    img = cv2.imread('/tmp/foo.png')
    cv2.imshow('output', img)
    cv2.waitKey(0)

    with the aforementioned moveToThread messages:

    QObject::moveToThread: Current thread (0x55bb9bd3a9f0) is not the object's thread (0x55bb9bf9a6e0).
    Cannot move to target thread (0x55bb9bd3a9f0)
    

    output

    /tmp/foo.png is a colour image of size 512x512.

    I am on a Manjaro system with python 3.8.3, opencv-python 4.3.0.36, KDE and Qt5 (although this should not matter as opencv-python ships with own version of Qt). Looking through the LD_DEBUG output, I can see the system Qt libs being loaded as a result of an indirect dependency from the opencv-python shipped Qt libs!

       1262759:     file=/usr/lib/qt4/plugins/imageformats/libqgif.so [0];  dynamically loaded by /home/freakabcd/.virtualenvs/opencv/lib/python3.8/site-packages/cv2/../opencv_python.libs/libQtCore-6b7bca35.so.4.8.7 [0]
       1262759:     file=/usr/lib/qt4/plugins/imageformats/libqgif.so [0];  generating link map
       1262759:       dynamic: 0x00007f38b9c68bf8  base: 0x00007f38b9c5f000   size: 0x000000000000a030
       1262759:         entry: 0x00007f38b9c62020  phdr: 0x00007f38b9c5f040  phnum:                  9
       1262759:     
       1262759:     
       1262759:     file=libQtGui.so.4 [0];  needed by /usr/lib/qt4/plugins/imageformats/libqgif.so [0]
       1262759:     find library=libQtGui.so.4 [0]; searching
       1262759:      search cache=/etc/ld.so.cache
       1262759:       trying file=/usr/lib/libQtGui.so.4
       1262759:     
       1262759:     file=libQtGui.so.4 [0];  generating link map
       1262759:       dynamic: 0x00007f38b9ba3540  base: 0x00007f38b909b000   size: 0x0000000000b202c0
       1262759:         entry: 0x00007f38b926c020  phdr: 0x00007f38b909b040  phnum:                  9
       1262759:     
       1262759:     
       1262759:     file=libQtCore.so.4 [0];  needed by /usr/lib/qt4/plugins/imageformats/libqgif.so [0]
       1262759:     find library=libQtCore.so.4 [0]; searching
       1262759:      search cache=/etc/ld.so.cache
       1262759:       trying file=/usr/lib/libQtCore.so.4
       1262759:     
       1262759:     file=libQtCore.so.4 [0];  generating link map
       1262759:       dynamic: 0x00007f38b9094920  base: 0x00007f38b8d98000   size: 0x0000000000302410
       1262759:         entry: 0x00007f38b8e30f60  phdr: 0x00007f38b8d98040  phnum:                 12
    

    As you can see, the opencv-python provided libQtCore is dynamically loading this libqgif.so because it is present in some known path to it /usr/lib/qt4/plugins/imageformats. Given that @areche mentions /usr/lib/kde4/plugins/styles/breeze.so being loaded on their system, it could be that the 4.8.7 Qt shipped with opencv-python is not built correctly to ignore loading plugins from well known "system" paths. I am not even sure if such an option exists in the Qt build configuration as it has been many years since I have built Qt from source.

    It would be great if some of the people on this thread with the same issue can check if they have the /usr/lib/qt4/plugins or /usr/lib/kde4/plugins paths showing up in their debug logs (LD_DEBUG=all python myfile.py). If other people can confirm one (or both) of these paths is appearing in their output, someone can check if there is a Qt build config to get rid of searching system paths for plugins to load dynamically.

  21. skvark commented on Jul 28, 2020

    @skvark
    Member

    @freakabcd See #362

    The latest issue with Qt4 is related to the manylinux2014 upgrade. I had to use qt-devel directly from CentOS 7 repos because there were some compiler related issues when I tried to compile Qt4 manually. In older manylinux1 releases Qt4 was compiled manually. Please check the Dockerfiles in the docker folder in this repo for more info. I'll try to upgrade to Qt5 before next release which hopefully solves some of these issues. Plugins path can be set as an env var in Qt5 (like it is set currently in macOS builds in __init__.py), but not in Qt4 based on some fast searches I did earlier.

  22. skvark commented on Aug 9, 2020

    @skvark
    Member

    Starting from 3.4.10.37 and 4.3.0.38 the pre-built wheels will include Qt 5.15 which has been built in a namespace so the conflict issue should be fixed. The new releases should be up in the next 24 hours. However, please note that I cannot guarantee that the wheels will work on all GNU/Linux systems. The new releases will include also source distributions which should allow to build the wheels locally if you encounter issues with the OpenCV GUI functions.

  23. joelcma commented on Sep 4, 2020

    @joelcma

    I would just like to add that I get this same error on 4.3.0.38 and forward but not on 4.3.0.36. I'm running Elementary OS 5.1.7 Hera (Ubuntu based).

    I tried updating because cv2.imshow wasn't showing all of my images properly (some were just showing a small box instead of the image) and after updating they show as they should but I'm getting the same QObject::moveToThread error.

  24. skvark commented on Sep 4, 2020

    @skvark
    Member

    @joelcma Yeah, that "small box" bug was this one which was also caused by a Qt conflict: #362

    Can't help much with that QObject::moveToThread error. Just make sure that your Python environment is consistent and you have removed all old versions of opencv-python from there. I have done everything I can to fix the issue.

  25. parluo commented on Nov 27, 2020

    @parluo

    It seem that I soved QObject::moveToThread: Current thread is not the objects thread. Cannot move to target thread, byconda uninstall pyqt. But I don't make sure its feasibility. And I found the QT about libs in /usr/lib/x86_64-linux-gnu whill be removed after the commond and every thing is fine now.

  26. js899 commented on Dec 2, 2020

    @js899

    My problem was caused by QT. before I install QT, my opencv was fine.
    I uninstalled QT but it did not help. I finally was able to make it work through "sudo apt-get autoremove libqt5x11extras5".

    It didn't work for me, I have to submit a project but nothing seems to be working. I have Ubuntu 20.04 LTS, working in Spyder but unable to take videocapture. Please help.

  27. GhostDog98 commented on Dec 19, 2022

    @GhostDog98

    Next opencv-python release will include Qt5 instead of Qt4. That change will most likely solve this issue.

    What do we do if we are still having this issue? (version 4.6)

  28. Coderx7 commented on Sep 1, 2023

    @Coderx7

    For those having this issue in Anaconda installation, just pip uninstall your opencv-python , and install opencv using conda :

    conda install -c conda-forge opencv
    

    that should fix your problems.

  29. added a commit that references this issue on Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions