route for none-computer users' openCV lessons with examples and source code
重点利用Opencv积极联系Python的技能
- introdue to compter vision (cv2)
- Tricks of install cv 如何安装技巧
- loading pictrure/camera/movie 加载图片和摄像头或视频
- cvui 简单的图形界面 headfile GUI for openCV
- Tesseract-ocr 识别与训练
- basic image processing 基本图像处理
- TrainData DIY 字体识别库diy
- Image prop. correction methods 图片透视校正
- Table/grid/web data fetch 表格数据榨取
- install python 2.6
- install cv2 numpy matplotlib cvui
pip install --upgrade setuptools
pip install matplotlib
pip install numpy
pip install opencv-python==版本号
- Via pip you can specify the package version to install using the following: 指定版本号
pip install opencv-python==2.4.9
However, that package does not seem to be available on pypi. A little trick for checking available versions:
pip install opencv-python
import cv2
print cv2.CV_AA
- loading picture
- loading video data
import cv2
import numpy as np
img = cv2.imread("girl.jpg",0)
height, width = img.shape
cv2.imshow("Hello World",img)
cv2.waitKey(0)
cv2.destroyAllWindows()
# use computer
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH,1080)
cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT,720)
while(1):
# get a frame
ret, frame = cap.read()
# show a frame
cv2.imshow(" Video example exit by 'q' ", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('messi5.jpg',0)
plt.imshow(img, cmap = 'gray', interpolation = 'bicubic')
plt.xticks([]), plt.yticks([]) # to hide tick values on X and Y axis
plt.show()
A (very) simple UI lib built on top of OpenCV drawing primitives. Other UI libs, such as imgui, require a graphical backend (e.g. OpenGL) to work, so if you want to use imgui in a OpenCV app, you must make it OpenGL enabled, for instance. It is not the case with cvui, which uses only OpenCV drawing primitives to do all the rendering (no OpenGL or Qt required).
CVUI 是一个基于 OpenCV 自建绘图模块的图形界面库,其他的图形界面库,如imgui,需要界面后台库Opengl或QT支持,如果我们只需要使用一些比较常见的UI功能,我们只需要OpenCV来完成所有的渲染功能。
import numpy as np
import cv2
import cvui
WINDOW_NAME = 'CVUI Test'
cvui.init(WINDOW_NAME)
frame = np.zeros((200, 400, 3), np.uint8)
while True:
frame[:] = (49, 52, 49)
cvui.text(frame, 10, 15, 'Hello world!')
# Update cvui internal stuff
cvui.update()
# Show window content
cv2.imshow(WINDOW_NAME, frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
- NOTES change code CV2_LINE to CV_AA
创建一个可以显示摄像头内容的窗体,在窗体内部放置一个checkbox,通过checkbox 来改变图形的性质 比如颜色图像或黑白图像
pip install pytesseract
C:\Python27\Lib\site-packages\pytesseract
tesseract_cmd = 'tesseract'
改成如下
tesseract_cmd = 'c:/Program Files (x86)/Tesseract-OCR/tesseract.exe'
识别图片中的英文文字
import cv2
import pytesseract
from PIL import Image
import os
text = pytesseract.image_to_string(Image.open("testocr.jpg"))
print(text)
识别图片中的中文文字
#coding=utf-8
#coding=utf-8import cv2
import pytesseract
try:
from PIL import Image
except ImportError:
import Image
import pytesseract
import os
text = pytesseract.image_to_string(Image.open("testocr.tif"),lang='chi_sim')
print(text)
opencv_for_human.md 文件 可以用 GitHub tajpure/vortex 编辑 地址 https://github.com/tajpure/vortex