Skip to content

Commit

Permalink
Merge pull request vipstone#18 from archersmind/add_en_doc_01
Browse files Browse the repository at this point in the history
Doc: Translate settingup.md into English
  • Loading branch information
vipstone authored Jul 20, 2018
2 parents 978155c + 7b651de commit e3efc61
Showing 1 changed file with 48 additions and 57 deletions.
105 changes: 48 additions & 57 deletions doc-en/settingup.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,85 @@
# OpenCV环境搭建 #
# OpenCV Setting up and Introducation #

本文将介绍OpenCV在Python3.x上的实现,分为Window版和Linux版。
This tutorial is going to illustrate the installation of Python3.x on both Linux and Windows.
And introduce OpenCV on top of Python.

## Windows版环境搭建 ##
## OpenCV setting up in Windows ##

> 系统环境:windows 10 + python 3.6 + OpenCV 3.4.1
> Env:windows 10 + python 3.6 + OpenCV 3.4.1

### 一、安装python ###
### 1 Install Python ###

python的安装之前在[python自学笔记](https://github.com/vipstone/python)的项目中描述了,在这不做重复说明,有需要的朋友,点击查看:[python环境安装](https://github.com/vipstone/python/blob/master/%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.md)
In this [Pthon study note](https://github.com/vipstone/python)I've elaborated the Python install instructions:[Python setup](https://github.com/vipstone/python/blob/master/%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.md)

### 二、安装numpy模块 ###
### 2 Install Python package NumPy ###

根据上文提示,现在我们已经正确安装了python和pip(安装和管理python包的工具),在正式安装OpenCV之前,首先我们要安装numpy模块。
numpy:是一个定义了数值数组和矩阵类型和它们的基本运算的语言扩展,OpenCV引用了numpy模块,所以安装OpenCV之前必须安装numpy。
After above step, we should have Python and pip (package management system used to install and manage software packages written in Python) installed. Before OpenCV acutal installed we should have Numpy settled, which is a fundamental package for scientific computing with Python, OpenCV depends on Numpy, so it's the prerequisite for OpenCV.

本文安装python模块使用的是.whl文件安装的。
we're using .whl files to install Python packages.

**whl文件是什么?**
**What is a whl file ?**

whl是一个python的压缩包,其中包含了py文件以及经过编译的pyd文件。
whl file are compressed built-package format used for Python.

**whl安装命令**
> pip3 install 存放路径\xxx.whl
**Install whl package for Python**
> pip3 install path_to\xxx.whl
回到主题,我们是要安装numpy模块的。
Go back the Numpy installation.

第一步:先去网站下载对应的numpy版本,下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy 本人是64为系统python3.6所以对应的最新版本是:numpy‑1.14.2+mkl‑cp36‑cp36m‑win_amd64.whl,点击下载到D:根目录。
Step 1:Download corresponding whl files from here:https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
E.g. Windows 64 with Python 3.6 should download this file: numpy‑1.14.2+mkl‑cp36‑cp36m‑win_amd64.whl

百度云链接https://pan.baidu.com/s/10RefansrC4_0zsNehjyKTg
Download from Baidu Yunpanhttps://pan.baidu.com/s/10RefansrC4_0zsNehjyKTg

提取密码:gua3
Password:gua3


第2步:启动命令窗体运行
Step 2:Input Command-line in a terminal
> pip3 install d:\numpy‑1.14.2+mkl‑cp36‑cp36m‑win_amd64.whl
命令窗体显示
Output

Processing d:\numpy-1.14.2+mkl-cp36-cp36m-win_amd64.whl

Installing collected packages: numpy

Successfully installed numpy-1.14.2+mkl

说明已经安装成功。

### 3 Install OpenCV as Python package ###
Similar way to install OpenCV.

### 三、安装OpenCV ###
同样安装OpenCV模块和numpy方式类似。
Step 1:Download corresponding whl files from here:https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv E.g Windows 64 with Python 3.6 should download this file::opencv_python‑3.4.1‑cp36‑cp36m‑win_amd64.whl

第1步:首先去网站下载OpenCV对应的.whl版本压缩包,网址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv 本人下载的版本是:opencv_python‑3.4.1‑cp36‑cp36m‑win_amd64.whl 64位系统对应python3.6的,下载到d盘根目录。
Download from Baidu Yunpan:https://pan.baidu.com/s/10RefansrC4_0zsNehjyKTg

百度云链接:https://pan.baidu.com/s/10RefansrC4_0zsNehjyKTg
Password:gua3

提取密码:gua3

第2步:启动命令窗体运行
Step 2:Input Command-line in a terminal
> pip3 install d:\opencv_python-3.4.1-cp36-cp36m-win_amd64.whl
窗体显示
Output

Processing d:\opencv_python-3.4.1-cp36-cp36m-win_amd64.whl

Installing collected packages: opencv-python

Successfully installed opencv-python-3.4.1

说明安装成功。

### 四、运行OpenCV ###
到此,我们的环境配置已经完成了,终于到了可以撸代码的时刻了,想想还有一点小激动呢。

### 4 OpenCV examples ###

``` python
import cv2

print(cv2.__version__)

# 输出:3.4.1
# Output:3.4.1
```
上面我们简单的打印了OpenCV的版本号,如果能正常输出不报错,说明我们已经把OpenCV的python环境搭建ok了。
If the version number can be print out correctly which means OpenCV-Python is settled.

什么?感觉还不过瘾,那就来撸一张图,用OpenCV把它展示出来,代码如下
Show an image with OpenCV
``` python
import cv2

Expand All @@ -95,55 +91,50 @@ cv2.waitKey(0)
cv2.destroyAllWindows()
```

展示效果如图:![正在加载图片](https://raw.githubusercontent.com/vipstone/opencvLab/master/res/show-meinv.png)



----------
## Linux版环境搭建 ##
## OpenCV setting up in Linux ##

>Ubuntu 18.04
>Python 3.6.5
>Pip 10.0.1
>Numpy 1.14.3
>OpenCV 3.4.0
Ubuntu有一个好处就是内置Python环境,不需要像Windows那样在为Python环境折腾了,但要注意的是Ubuntu本身自带的apt-get和安装的pip的数据源是国外的,所以使用起来都很慢,一定要把apt-get和pip的数据源更换成国内的,请移步到:[《Ubuntu apt-get和pip源更换》](http://www.cnblogs.com/vipstone/p/9038023.html)
Ubuntu already had Python built in which is easier for setting campare to Windows, so just using apt-get command in Ubuntu for software package installation. Please refer this [tutorial](http://www.cnblogs.com/vipstone/p/9038023.html) for software sources updating (if needed).

### Installation ###

### 正式安装 ###
根据上面的提示,你已经配置好了开发环境,现在需要正式安装了,当然Ubuntu的安装也比Windows简单很多,只需要使用pip安装包,安装相应的模块即可。
It's easier in Ubuntu than Windows for OpenCV installation, basically we only need pip command to do all the work.

#### 安装Numpy ####
使用命令:pip3 install numpy
#### Install Numpy ####
CLI:pip3 install numpy

使用命令:python3,进入python脚本执行环境,输入代码查看numpy是否安装成功,以及numpy的安装版本:
Try below Python code to see if Numpy settled
```
import numpy
numpy.__version__
```
正常输入版本号,证明已经安装成功。

如图:![](http://icdn.apigo.cn/numpy-setup-success.png)
If version number print out correctly which means Numpy installed successfully.

#### 安装OpenCV ####
OpenCV的安装在Ubuntu和numpy相似,使用命令:
#### Install OpenCV ####
Similar way to install OpenCV:
>pip3 install opencv-python
使用命令:python3,进入python脚本执行环境,输入代码查看OpenCV版本:
Try below Python code to see if OpenCV settled
```
import cv2
cv2.__version__
```
正常输出版本号,证明已经安装成功。
If version number print out correctly which means OpemCV installed successfully.

# 常见错误 #
# FAQ #

错误一、python3: Relink `/lib/x86_64-linux-gnu/libudev.so.1` with `/lib/x86_64-linux-gnu/librt.so.1` for IFUNC symbol `clock_gettime`
[1] python3: Relink `/lib/x86_64-linux-gnu/libudev.so.1` with `/lib/x86_64-linux-gnu/librt.so.1` for IFUNC symbol `clock_gettime`
Segmentation fault (core dumped)

解决方案:apt install python3-opencv
Answer:apt install python3-opencv


----------
Expand Down

0 comments on commit e3efc61

Please sign in to comment.