diff --git a/README.md b/README.md index 77ee0115..2a50c6ce 100644 --- a/README.md +++ b/README.md @@ -20,4 +20,4 @@ opencv for python ## 实践教程 ## -[opencv for python环境搭建](doc/环境搭建.md) \ No newline at end of file +[opencv python环境搭建](doc/环境搭建.md) \ No newline at end of file diff --git "a/doc/opencv\350\215\211\347\250\277\346\226\207\346\241\243.doc" "b/doc/opencv\350\215\211\347\250\277\346\226\207\346\241\243.doc" deleted file mode 100644 index f4b2ea54..00000000 Binary files "a/doc/opencv\350\215\211\347\250\277\346\226\207\346\241\243.doc" and /dev/null differ diff --git "a/doc/\347\216\257\345\242\203\346\220\255\345\273\272.md" "b/doc/\347\216\257\345\242\203\346\220\255\345\273\272.md" index 69df7162..d2cbb7ef 100644 --- "a/doc/\347\216\257\345\242\203\346\220\255\345\273\272.md" +++ "b/doc/\347\216\257\345\242\203\346\220\255\345\273\272.md" @@ -7,11 +7,11 @@ > 系统环境:windows 10 + python 3.6 + opencv 3.4.1 -### 安装python ### +### 一、安装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) -### 安装numpy模块 ### +### 二、安装numpy模块 ### 根据上文提示,现在我们已经正确安装了python和pip(安装和管理python包的工具),在正式安装opencv之前,首先我们要安装numpy模块。 numpy:是一个定义了数值数组和矩阵类型和它们的基本运算的语言扩展,opencv引用了numpy模块,所以安装opencv之前必须安装numpy。 @@ -19,10 +19,55 @@ numpy:是一个定义了数值数组和矩阵类型和它们的基本运算的 本文安装python模块使用的是.whl文件安装的。 **whl文件是什么?** + whl是一个python的压缩包,其中包含了py文件以及经过编译的pyd文件。 **whl安装命令** > pip install 存放路径\xxx.whl +回到主题,我们是要安装numpy模块的。 + +首先去网站下载对应的numpy版本,下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy 本人是64为系统python3.6所以对应的最新版本是:numpy‑1.14.2+mkl‑cp36‑cp36m‑win_amd64.whl,点击下载到D:根目录。 + +第2步,启动命令窗体运行 +> pip install d:\numpy‑1.14.2+mkl‑cp36‑cp36m‑win_amd64.whl + +命令窗体显示: + +Processing d:\numpy-1.14.2+mkl-cp36-cp36m-win_amd64.whl + +Installing collected packages: numpy + +Successfully installed numpy-1.14.2+mkl + +说明已经安装成功。 + + +### 三、安装opencv ### +同样安装opencv模块和numpy方式类似,实现去网站下载opencv对于的.whl版本压缩包,网址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv 本人下载的版本是:opencv_python‑3.4.1‑cp36‑cp36m‑win_amd64.whl 64位系统对应python3.6的,下载到d盘根目录。 + +第2步,启动命令窗体运行 +> pip install d:\opencv_python-3.4.1-cp36-cp36m-win_amd64.whl + +窗体显示: + +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 ### +到此,我们的环境配置已经完成了,终于到了可以撸代码的时刻了,想想还有一点小激动呢。 + + +``` python +import cv2 +print(cv2.__version__) +# 输出:3.4.1 +``` +上面我们简单的打印了opencv的版本号,如果能正常输出不报错,说明我们已经把opencv的python环境搭建ok了。 \ No newline at end of file diff --git a/opencvLab/.vscode/launch.json b/opencvLab/.vscode/launch.json new file mode 100644 index 00000000..0d231151 --- /dev/null +++ b/opencvLab/.vscode/launch.json @@ -0,0 +1,91 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Current File", + "type": "python", + "request": "launch", + "program": "${file}" + }, + { + "name": "Python: Attach", + "type": "python", + "request": "attach", + "localRoot": "${workspaceFolder}", + "remoteRoot": "${workspaceFolder}", + "port": 3000, + "secret": "my_secret", + "host": "localhost" + }, + { + "name": "Python: Terminal (integrated)", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "integratedTerminal" + }, + { + "name": "Python: Terminal (external)", + "type": "python", + "request": "launch", + "program": "${file}", + "console": "externalTerminal" + }, + { + "name": "Python: Django", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/manage.py", + "args": ["runserver", "--noreload", "--nothreading"], + "debugOptions": ["RedirectOutput", "Django"] + }, + { + "name": "Python: Flask (0.11.x or later)", + "type": "python", + "request": "launch", + "module": "flask", + "env": { + "FLASK_APP": "${workspaceFolder}/app.py" + }, + "args": ["run", "--no-debugger", "--no-reload"] + }, + { + "name": "Python: Module", + "type": "python", + "request": "launch", + "module": "module.name" + }, + { + "name": "Python: Pyramid", + "type": "python", + "request": "launch", + "args": ["${workspaceFolder}/development.ini"], + "debugOptions": ["RedirectOutput", "Pyramid"] + }, + { + "name": "Python: Watson", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/console.py", + "args": ["dev", "runserver", "--noreload=True"] + }, + { + "name": "Python: All debug Options", + "type": "python", + "request": "launch", + "pythonPath": "${config:python.pythonPath}", + "program": "${file}", + "module": "module.name", + "env": { + "VAR1": "1", + "VAR2": "2" + }, + "envFile": "${workspaceFolder}/.env", + "args": ["arg1", "arg2"], + "debugOptions": ["RedirectOutput"] + } + ] +} diff --git a/opencvLab/img/meinv.png b/opencvLab/img/meinv.png new file mode 100644 index 00000000..47d66e3a Binary files /dev/null and b/opencvLab/img/meinv.png differ diff --git a/opencvLab/imgDemo.py b/opencvLab/imgDemo.py new file mode 100644 index 00000000..3e323b3e --- /dev/null +++ b/opencvLab/imgDemo.py @@ -0,0 +1,8 @@ +import cv2 + +filepath = "img/meinv.png" +img = cv2.imread(filepath) +cv2.namedWindow('Image') +cv2.imshow('Image', img) +cv2.waitKey(0) +cv2.destroyAllWindows() diff --git a/opencvLab/versionDemo.py b/opencvLab/versionDemo.py new file mode 100644 index 00000000..0ad2c5cc --- /dev/null +++ b/opencvLab/versionDemo.py @@ -0,0 +1,5 @@ +import cv2 + +print(cv2.__version__) + +# 输出:3.4.1 diff --git a/res/show-meinv.png b/res/show-meinv.png new file mode 100644 index 00000000..03e0675c Binary files /dev/null and b/res/show-meinv.png differ