python批量识别图片指定区域文字内容,供大家参考,具体内容如下
简介
对于一张图片,需求识别指定区域的内容
1.截取原始图上的指定图片当做模板
2.根据模板相似度去再原始图片上识别准确坐标
3.根据坐标剪切出指定位置图片,也就是所需的内容区域
4.对指定位置图片进行ocr识别
环境
Ubuntu18.04
Python2.7
所需Python模块
1.aircv
用于识别模板再原始图的位置坐标 pip install aircv
2.Pillow
用于剪裁图片 pip install Pillow
3.Tesseract
文字识别
在此也可以用平台端的API进行更精准的识别
ubuntu下Tesseract环境安装 sudo apt-get install libpng12-dev
sudo apt-get install libjpeg62-dev
sudo apt-get install libtiff4-dev
sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install automake
1.tesseract-ocr安装 sudo apt-get install tesseract-ocr
2.pytesseract安装 pip install pytesseract
Python代码
识别对应位置 #!/usr/bin/python2.7
# -*- coding: utf-8 -*-
import aircv