Install OpenCV for Python3 on Ubuntu

在terminal上输入以下命令:
pip install opencv-python -i https://pypi.doubanio.com/simple/
输出如下:

Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.doubanio.com/simple/
Collecting opencv-python
Downloading https://pypi.doubanio.com/packages/99/e6/c36487aacc7c37697634cf07b7c02684b292ea5cd5b6054a75f7e7d28d31/opencv_python-4.3.0.36-cp37-cp37m-manylinux2014_x86_64.whl (43.7 MB)
|████████████████████████████████| 43.7 MB 315 kB/s
Collecting numpy>=1.14.5
Downloading https://pypi.doubanio.com/packages/a8/31/e2c3eda7afe7dab08e1f24767b8e38ff2f30dc82bd74aa3a5324c550366a/numpy-1.19.0-cp37-cp37m-manylinux2010_x86_64.whl (14.6 MB)
|████████████████████████████████| 14.6 MB 1.2 MB/s
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.19.0 opencv-python-4.3.0.36


更新pip的源为豆瓣的源,清华的源太不好用了!
pip config set global.index-url https://pypi.doubanio.com/simple/
输出如下:

Writing to /home/zzx/.config/pip/pip.conf


cv2的含义

安装好opencv后,导入时用:
import cv2
cv的英文全称是computer vision.
cv2”中的”2”并不表示OpenCV的版本号。OpenCV是基于C/C++的,”cv”和”cv2”表示的是底层C API和C++API的区别,”cv2”表示使用的是C++API。这主要是一个历史遗留问题,是为了保持向后兼容性。

你可能感兴趣的:(Install OpenCV for Python3 on Ubuntu)