Opencv Python 简明教程

OpenCV Python - Environment Setup

在大多数情况下,使用 pip 就足以在电脑上安装 OpenCV-Python。

In most of the cases, using pip should be sufficient to install OpenCV-Python on your computer.

用于安装 pip 的命令如下 −

The command which is used to install pip is as follows −

pip install opencv-python

建议在新虚拟环境中执行此安装。当前版本的 OpenCV-Python 是 4.5.1.48,可以通过以下命令进行验证 −

Performing this installation in a new virtual environment is recommended. The current version of OpenCV-Python is 4.5.1.48 and it can be verified by following command −

>>> import cv2
>>> cv2.__version__
'4.5.1'

由于 OpenCV-Python 依赖于 NumPy,后者也将自动安装。根据选择,你可以安装 Matplotlib 来渲染某些图形化输出。

Since OpenCV-Python relies on NumPy, it is also installed automatically. Optionally, you may install Matplotlib for rendering certain graphical output.

在 Fedora 上,你可以通过下面提到的命令安装 OpenCV-Python −

On Fedora, you may install OpenCV-Python by the below mentioned command −

$ yum install numpy opencv*

OpenCV-Python 也可以通过从 http://sourceforge.net 获得的源构建来安装。请按照为其提供的安装说明进行操作。

OpenCV-Python can also be installed by building from its source available at http://sourceforge.net Follow the installation instructions given for the same.