OpenCV not working properly with python on Linux with anaconda. Getting error that cv2.imshow() is not implemented

后端 未结 14 736
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 09:24

This is the exact error that I am getting. My OS is Ubuntu 16.10.

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with

相关标签:
14条回答
  • 2020-12-02 09:34

    If you installed OpenCV using the opencv-python pip package at any point in time, be aware of the following note, taken from https://pypi.python.org/pypi/opencv-python

    IMPORTANT NOTE MacOS and Linux wheels have currently some limitations:

    • video related functionality is not supported (not compiled with FFmpeg)
    • for example cv2.imshow() will not work (not compiled with GTK+ 2.x or Carbon support)

    Also note that to install from another source, first you must remove the opencv-python package

    0 讨论(0)
  • 2020-12-02 09:35

    I followed this tutorial (OpenCV GTK+2.x error) and did the following. It worked for me :

    1. install the packages : libgtk2.0-dev and pkg-config
    2. cd to your opencv directory
    3. mkdir Release
    4. cd Release
    5. Run the command : cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_GTK=ON -D WITH_OPENGL=ON ..
    6. make
    7. sudo make install
    0 讨论(0)
  • 2020-12-02 09:35

    My Envirment is Win10, and I added the anaconda path to the environment variables's PATH’,the cv2.imshow worked

    C:\Users\user\Anaconda3
    C:\Users\user\Anaconda3\Scripts
    

    Then restart the windows

    0 讨论(0)
  • 2020-12-02 09:38

    Although this is already answered, for me conda-forge solution worked with a hack. My workstation is a centos 6 machine, and I use conda virtual environment (anaconda 2). Create an environment

    conda create --name test python=2.7
    

    and then activate it

    conda activate test
    

    Now install opencv from conda-forge

    conda install -c conda-forge opencv
    

    Now install matplotlib in this environment (and this is hack 1)

    conda install matplotlib
    

    Let's check now imshow works or not. In a terminal, activate test environment and start python. In the interpreter, do

    import cv2
    import matplotlib.pyplot as plt # hack 2
    img = cv2.imread('your_image_file',0)
    cv2.imshow('image',img)
    

    This should pop up a window showing image. I did not further research how this solved the case.

    Note 1: You may see some error related to xkb, then in your .bashrc file add

    export QT_XKB_CONFIG_ROOT=/usr/share/X11/xkb

    Note 2: You may see some error related to XDG_RUNTIME_DIR, then in your .bashrc file also add

    export XDG_RUNTIME_DIR=.tmp/myruntime and define myruntime by mkdir -p .tmp/myruntime

    0 讨论(0)
  • 2020-12-02 09:40

    Notice that it is complaining for libgtk2.0-dev and pkg-config. Here is the solution. Uninstall your existing openCV installation.

    conda remove opencv3

    Install these packages before installing opencv- conda install gtk2 pkg-config

    Now install opencv from menpo conda install -c https://conda.anaconda.org/menpo opencv3

    0 讨论(0)
  • 2020-12-02 09:41

    I have had to deal with this issue a couple of times, this is what has worked consistently thus far:

    conda remove opencv
    conda install -c menpo opencv
    pip install --upgrade pip
    pip install opencv-contrib-python
    
    0 讨论(0)
提交回复
热议问题