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

后端 未结 14 742
佛祖请我去吃肉
佛祖请我去吃肉 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: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

提交回复
热议问题