zoukankan      html  css  js  c++  java
  • Install OpenCV-Python in Ubuntu

    安装系统python下的opencv

    Install package python-opencv with following command in terminal (as root user).
    $ sudo apt-get install python-opencv
    
    Open Python IDLE (or IPython) and type following codes in Python terminal.
    import cv2 as cv
    print(cv.__version__)
    
    If the results are printed out without any errors, congratulations !!! You have installed OpenCV-Python successfully.
    
    

    针对conda环境下env安装python-opencv

    • 发现有些坑
    • 首先,我们直接编译opencv应该就有python的接口:/usr/local/lib/python3.5/dist-packages;发现有cv2.cpython-35m-x86_64-linux-gnu.so文件,说的直接拷贝到env下的site-packages,结果报错;
    • 然后我们本身直接sudo apt-get install python-opencv安装的是直接可以使用的;
    • sudo直接安装按系统默认的python2.7上:/usr/lib/python2.7/dist-packages下面有cv2.x86_64-linux-gnu.so;
    rjw@rjw:~$ /usr/bin/python
    Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
    [GCC 5.4.0 20160609] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import cv2
    >>> cv2.__version__
    '2.4.9.1'
    
    (tensorflow) rjw@rjw:~$ python
    Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 21:41:56) 
    [GCC 7.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import cv2
    >>> cv2.__version__
    '3.2.0'
    
    
    • 直接conda install python-opencv在conda环境下找不到包

    • update2018.11.11;今天遇到个问题:

    UnsatisfiableError: The following specifications were found to be in conflict:   - opencv3 -> python
    
    • 重新使用:pip install opencv-python
    (maskrcnn_benchmark) rjw@rjw:~/desktop$ pip install opencv-python
    Collecting opencv-python
      Downloading https://files.pythonhosted.org/packages/d2/cf/1e5774811aa1b656fba8476e98edab2f99a7683c3aaeede057cdc9959c24/opencv_python-3.4.3.18-cp37-cp37m-manylinux1_x86_64.whl (25.0MB)
        100% |████████████████████████████████| 25.0MB 72kB/s 
    Requirement already satisfied: numpy>=1.14.5 in /home/rjw/anaconda3/envs/maskrcnn_benchmark/lib/python3.7/site-packages (from opencv-python) (1.15.4)
    Installing collected packages: opencv-python
    Successfully installed opencv-python-3.4.3.18
    
    
    • 可以想想,在anaconda下怎么使用自己编译的opencv,这样就可以万能使用!!!

    其他错误

    >>> import cv2
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0: undefined symbol: hb_font_funcs_set_variation_glyph_func
    
    
  • 相关阅读:
    Linux和Windows下查看环境变量方法对比zz
    建议在虚拟机下使用网银,
    visualfirebug
    JavaScript Guide
    JavaScript Guide
    virtualbox for windows的版本可以好好读一读
    Crossfire
    How To: Convert VirtualPC .vhd hard drives to VirtualBox .vdi hard drives (or viceversa)
    中文网页重设与排版:TYPO.CSS
    AppFuse QuickStart
  • 原文地址:https://www.cnblogs.com/ranjiewen/p/9737346.html
Copyright © 2011-2022 走看看