Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加命令行安装Numpy、whl、OpenCV #51

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions doc/settingup.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@
> 系统环境:windows 10 + python 3.6 + OpenCV 3.4.1


### 一、安装python ###
### 一、安装python和pip ###

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)

### 二、安装numpy模块 ###

根据上文提示,现在我们已经正确安装了python和pip(安装和管理python包的工具),在正式安装OpenCV之前,首先我们要安装numpy模块。
numpy:是一个定义了数值数组和矩阵类型和它们的基本运算的语言扩展,OpenCV引用了numpy模块,所以安装OpenCV之前必须安装numpy。
`pip install numpy`

本文安装python模块使用的是.whl文件安装的。

**whl文件是什么?**

whl是一个python的压缩包,其中包含了py文件以及经过编译的pyd文件。
`pip install wheel`

**whl安装命令**
> pip3 install 存放路径\xxx.whl
Expand Down Expand Up @@ -50,7 +52,9 @@ Successfully installed numpy-1.14.2+mkl

### 三、安装OpenCV ###
同样安装OpenCV模块和numpy方式类似。

命令行安装:
`pip install opencv-python`
手动安装:
第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盘根目录。

百度云链接:https://pan.baidu.com/s/10RefansrC4_0zsNehjyKTg
Expand Down Expand Up @@ -79,15 +83,15 @@ import cv2

print(cv2.__version__)

# 输出:3.4.1
# 输出:4.2.0
```
上面我们简单的打印了OpenCV的版本号,如果能正常输出不报错,说明我们已经把OpenCV的python环境搭建ok了。

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

filepath = "img/meinv.png"
filepath = "img/meinv.png" #这里替换为你电脑照片的路径,注意不要包含中文,斜杠和反斜杠务必转换
img = cv2.imread(filepath)
cv2.namedWindow('Image')
cv2.imshow('Image', img)
Expand Down
11 changes: 8 additions & 3 deletions doc/tesseractOCR.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ Tesseract的OCR引擎最先由HP实验室于1985年开始研发,至1995年时
使用命令,查看版本号和支持语言:

>cd C:\Users\Administrator\AppData\Local\Tesseract-OCR
>tesseract -v
>tesseract --list-langs  #查看Tesseract-OCR支持语言
>tesseract -v
>tesseract --list-langs  #查看Tesseract-OCR的版本和支持语言,下文中的语言只能从这里的结果选取

三、配置tesseract运行文件

C:\Python36\Lib\site-packages\pytesseract\pytesseract.py
找到文件:
>tesseract_cmd = 'tesseract'

修改为:
修改为(根据刚才的安装目录修改)
>tesseract_cmd = 'C:/Program Files (x86)/Tesseract-OCR/tesseract.exe'

四、代码识别
Expand All @@ -48,3 +48,8 @@ print(text)
```

作为非常优秀的Ocr识别库,tesseract当然可以训练自己的数据模型,从而达到为我所用的目的,后续文章会介绍如何训练自己的文字识别库。

2020.4.16
采用Windows安装包选择中文简体+中文繁体语言最后安装失败,仅成功安装eng和osd语言。
解决办法参考:https://blog.csdn.net/weixin_43031092/article/details/105561486
最新打包的中文语言包:https://pan.baidu.com/s/11vlNct2oxO_ATfsBhyGv8Q 提取码:fi33